fixed item system
This commit is contained in:
parent
711778d91c
commit
729751b57f
@ -226,7 +226,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 365318976786001977}
|
||||
m_LocalRotation: {x: 0.0718026, y: -0.0602704, z: 0.016577827, w: 0.99545825}
|
||||
m_LocalRotation: {x: 0.050803177, y: 0.24604334, z: -0.062553294, w: 0.9659031}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -474,7 +474,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 365318977167042193}
|
||||
m_LocalRotation: {x: 0.09804932, y: 0.000000017650475, z: -0.0000000017389965, w: 0.99518156}
|
||||
m_LocalPosition: {x: 0, y: 1.32, z: -3}
|
||||
m_LocalPosition: {x: -1.6996615, y: 1.32, z: -2.4720743}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
@ -777,7 +777,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 365318977785173328}
|
||||
m_LocalRotation: {x: 0.05368384, y: -0.060561996, z: 0.015478803, w: 0.9965996}
|
||||
m_LocalRotation: {x: 0.03322547, y: 0.2471404, z: -0.05806753, w: 0.9666674}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -989,7 +989,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 365318978058098897}
|
||||
m_LocalRotation: {x: 0.03559524, y: -0.060832832, z: 0.014377572, w: 0.9974095}
|
||||
m_LocalRotation: {x: 0.015683249, y: 0.24815318, z: -0.053574488, w: 0.96711105}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -1078,8 +1078,8 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 365318978543542559}
|
||||
m_LocalRotation: {x: 0.15114106, y: -0.061787855, z: 0.009466156, w: 0.9865339}
|
||||
m_LocalPosition: {x: -0.000023298204, y: 1.3199862, z: -2.4649107}
|
||||
m_LocalRotation: {x: 0.14482042, y: 0.14063732, z: -0.020799974, w: 0.97919124}
|
||||
m_LocalPosition: {x: -1.0329641, y: 1.3199979, z: -2.4649105}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@ -1149,8 +1149,8 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 23c1ce4fb46143f46bc5cb5224c934f6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
clearColorMode: 0
|
||||
backgroundColorHDR: {r: 0.025, g: 0.07, b: 0.19, a: 0}
|
||||
clearColorMode: 1
|
||||
backgroundColorHDR: {r: 0, g: 0, b: 0, a: 0}
|
||||
clearDepth: 1
|
||||
volumeLayerMask:
|
||||
serializedVersion: 2
|
||||
@ -1312,7 +1312,7 @@ MonoBehaviour:
|
||||
debug: 1
|
||||
mask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_Bits: 64
|
||||
range: 1
|
||||
--- !u!1 &365318978817215852
|
||||
GameObject:
|
||||
@ -1905,14 +1905,30 @@ PrefabInstance:
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -3.1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 506506833991321686, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3}
|
||||
propertyPath: m_Size.y
|
||||
value: 1.5481672
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 506506833991321686, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3}
|
||||
propertyPath: m_Center.y
|
||||
value: -0.2740825
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 800476564762967425, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3}
|
||||
propertyPath: m_Height
|
||||
value: 2.3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1296952523545964610, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3}
|
||||
propertyPath: m_Materials.Array.data[0]
|
||||
value:
|
||||
objectReference: {fileID: 2100000, guid: e1fe5134720cba140901cf75d1d6080f, type: 2}
|
||||
- target: {fileID: 1296952523545964610, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3}
|
||||
propertyPath: m_Materials.Array.data[1]
|
||||
value:
|
||||
objectReference: {fileID: 2100000, guid: 53ab8bcce7ce70342a13f65c0c773d03, type: 2}
|
||||
- target: {fileID: 1830643123924126821, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3}
|
||||
propertyPath: pistol
|
||||
value:
|
||||
objectReference: {fileID: 3430889494742284928}
|
||||
- target: {fileID: 1830643123924126821, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3}
|
||||
propertyPath: flashlight
|
||||
value:
|
||||
@ -2040,56 +2056,127 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 3442891603357720395}
|
||||
m_Modifications:
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2548026318584717246, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -0.05
|
||||
value: -0.083
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0.213
|
||||
value: 0.232
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0.057
|
||||
value: 0.063
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: -0.61237246
|
||||
value: -0.7401139
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.61237246
|
||||
value: -0.021586848
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.35355335
|
||||
value: 0.6718124
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0.35355335
|
||||
value: 0.020823253
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 90
|
||||
value: 179.772
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 180
|
||||
value: 95.532
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2870092814380004342, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: -120
|
||||
value: -183.43
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3215375081412045132, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Pistol1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5870767500957406260, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -0.78
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5870767500957406260, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0.28
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5870767500957406260, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5870767500957406260, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5870767500957406260, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: -90
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7836552235224166431, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
propertyPath: firePower
|
||||
value: 40
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
--- !u!114 &3430889494742284928 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 7836552235224166431, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3}
|
||||
m_PrefabInstance: {fileID: 4854301426680056479}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a0bc8aa373bfbe44e91f0625324088be, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &5526373308689778747
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DoorInteractable : InteractableItem
|
||||
public class DoorInteractable : HeavyItemReceiver
|
||||
{
|
||||
[SerializeField]
|
||||
private Transform powerCoreCenter;
|
||||
@ -91,6 +91,8 @@ public override bool Interact(ref Inventory inventory,ref HeavyInteractableItem
|
||||
else if(insertedCore!=null&&heavyInvent==null)
|
||||
{
|
||||
heavyInvent = insertedCore;
|
||||
print("Picked up:" + heavyInvent.name);
|
||||
insertedCore = null;
|
||||
//get ref of player perhaps
|
||||
return true;
|
||||
}
|
||||
|
13
Assets/Scripts/Item/HeavyItemReceiver.cs
Normal file
13
Assets/Scripts/Item/HeavyItemReceiver.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class HeavyItemReceiver : InteractableItem
|
||||
{
|
||||
protected HeavyInteractableItem item;
|
||||
[SerializeField]
|
||||
[Tooltip("Specify the keyword search in the name of the item!")]
|
||||
protected string searchString;
|
||||
|
||||
|
||||
}
|
11
Assets/Scripts/Item/HeavyItemReceiver.cs.meta
Normal file
11
Assets/Scripts/Item/HeavyItemReceiver.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aef7fff75652a9a499e312b65c8f91b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -43,7 +43,6 @@ private void FixedUpdate()
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 50))
|
||||
{
|
||||
print(hit.transform.name);
|
||||
targetObject.gameObject.transform.position = hit.point;
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,21 @@ void Start()
|
||||
flashlightEnabled = this.flashlight.gameObject.activeSelf;
|
||||
}
|
||||
|
||||
private bool receiverInRange(out int index)
|
||||
{
|
||||
int i = 0;
|
||||
foreach(InteractableItem item in this.itemsInRange)
|
||||
{
|
||||
if(item is HeavyItemReceiver)
|
||||
{
|
||||
index = i;
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
index = -1;
|
||||
return false;
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
@ -87,6 +102,8 @@ void Update()
|
||||
else if (heavyItemsInRange.Count > 0)
|
||||
{
|
||||
pickupFound = true;
|
||||
|
||||
|
||||
heavyInvent = heavyItemsInRange[0];
|
||||
|
||||
heavyInvent.transform.parent = carryingPos;
|
||||
@ -95,6 +112,7 @@ void Update()
|
||||
heavyItemsInRange.Remove(heavyItemsInRange[0]);
|
||||
heavyInvent.Disable();
|
||||
heavyInvent.DisableAll();
|
||||
|
||||
}
|
||||
if (!pickupFound)
|
||||
{
|
||||
@ -105,6 +123,20 @@ void Update()
|
||||
if (!item.Interact(ref invent, ref heavyInvent))
|
||||
{
|
||||
item.Interact();
|
||||
}else if(item is HeavyItemReceiver)
|
||||
{
|
||||
if(heavyInvent != null)
|
||||
{
|
||||
heavyInvent.transform.parent = carryingPos;
|
||||
heavyInvent.transform.localPosition = Vector3.zero;
|
||||
heavyInvent.transform.localEulerAngles = Vector3.zero;
|
||||
heavyItemsInRange.Remove(heavyInvent);
|
||||
heavyInvent.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
|
||||
heavyInvent.GetComponent<Rigidbody>().isKinematic = true;
|
||||
heavyInvent.Disable();
|
||||
heavyInvent.DisableAll();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -112,11 +144,22 @@ void Update()
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int refIndex;
|
||||
if (itemsInRange.Count > 0&&receiverInRange(out refIndex)) {
|
||||
((HeavyItemReceiver)itemsInRange[refIndex]).Interact(ref this.invent, ref heavyInvent);
|
||||
heavyInvent = null;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
heavyInvent.transform.parent = null;
|
||||
heavyInvent.GetComponent<Rigidbody>().isKinematic = false;
|
||||
heavyInvent.EnableAll();
|
||||
heavyInvent = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -126,7 +169,7 @@ void Update()
|
||||
}
|
||||
if (Input.GetButtonDown("Fire2"))
|
||||
{
|
||||
print(this.GunEnabled);
|
||||
//print(this.GunEnabled);
|
||||
if (!this.GunEnabled)
|
||||
{
|
||||
|
||||
@ -170,7 +213,7 @@ void Update()
|
||||
}
|
||||
public void EnableFlashlight()
|
||||
{
|
||||
print("Enabling Flashlight...");
|
||||
|
||||
flashlight.gameObject.SetActive(true);
|
||||
flashlight3D.GetComponent<MeshRenderer>().materials[materialIndex].SetColor("_BaseColor", initColor);
|
||||
selMaterial.SetColor("_EmissionColor", new Color(255, 255, 255, 255));
|
||||
@ -179,7 +222,7 @@ public void EnableFlashlight()
|
||||
}
|
||||
public void DisableFlashlight()
|
||||
{
|
||||
print("Disabling Flashlight...");
|
||||
|
||||
flashlight.gameObject.SetActive(false);
|
||||
flashlight3D.GetComponent<MeshRenderer>().materials[materialIndex].SetColor("_BaseColor", new Color(0, 0, 0));
|
||||
selMaterial.SetColor("_EmissionColor", new Color(0, 0, 0, 0));
|
||||
|
Loading…
Reference in New Issue
Block a user