updated shoot mechanics
This commit is contained in:
@ -85,62 +85,71 @@ public class PlayerInteractionHandler : MonoBehaviour
|
||||
}
|
||||
if(Input.GetButtonDown("Fire1"))
|
||||
{
|
||||
if (!IsCarrying)
|
||||
if (this.GunEnabled)
|
||||
{
|
||||
int t_index = 0;
|
||||
bool pickupFound = false;
|
||||
if (itemsInRange.Count > 0)
|
||||
{
|
||||
while (t_index<itemsInRange.Count&&!itemsInRange[t_index].CanPickup)
|
||||
{
|
||||
t_index++;
|
||||
}
|
||||
if (t_index != itemsInRange.Count)
|
||||
{
|
||||
pickupFound = true;
|
||||
invent.AddItem(itemsInRange[t_index]);
|
||||
itemsInRange[0].transform.gameObject.SetActive(false);
|
||||
itemsInRange.Remove(itemsInRange[t_index]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (heavyItemsInRange.Count > 0)
|
||||
{
|
||||
pickupFound = true;
|
||||
heavyInvent = heavyItemsInRange[0];
|
||||
|
||||
heavyInvent.transform.parent = carryingPos;
|
||||
heavyInvent.transform.localPosition = Vector3.zero;
|
||||
heavyInvent.GetComponent<Rigidbody>().isKinematic = true;
|
||||
heavyItemsInRange.Remove(heavyItemsInRange[0]);
|
||||
heavyInvent.Disable();
|
||||
heavyInvent.DisableAll();
|
||||
}
|
||||
if (!pickupFound)
|
||||
{
|
||||
foreach(InteractableItem item in itemsInRange)
|
||||
{
|
||||
if (!item.CanPickup)
|
||||
{
|
||||
if(!item.Interact(ref invent, ref heavyInvent))
|
||||
{
|
||||
item.Interact();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
this.pistol.Fire();
|
||||
}
|
||||
else
|
||||
{
|
||||
heavyInvent.transform.parent = null;
|
||||
heavyInvent.GetComponent<Rigidbody>().isKinematic = false;
|
||||
heavyInvent.EnableAll();
|
||||
heavyInvent = null;
|
||||
|
||||
if (!IsCarrying)
|
||||
{
|
||||
int t_index = 0;
|
||||
bool pickupFound = false;
|
||||
if (itemsInRange.Count > 0)
|
||||
{
|
||||
while (t_index < itemsInRange.Count && !itemsInRange[t_index].CanPickup)
|
||||
{
|
||||
t_index++;
|
||||
}
|
||||
if (t_index != itemsInRange.Count)
|
||||
{
|
||||
pickupFound = true;
|
||||
invent.AddItem(itemsInRange[t_index]);
|
||||
itemsInRange[0].transform.gameObject.SetActive(false);
|
||||
itemsInRange.Remove(itemsInRange[t_index]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (heavyItemsInRange.Count > 0)
|
||||
{
|
||||
pickupFound = true;
|
||||
heavyInvent = heavyItemsInRange[0];
|
||||
|
||||
heavyInvent.transform.parent = carryingPos;
|
||||
heavyInvent.transform.localPosition = Vector3.zero;
|
||||
heavyInvent.GetComponent<Rigidbody>().isKinematic = true;
|
||||
heavyItemsInRange.Remove(heavyItemsInRange[0]);
|
||||
heavyInvent.Disable();
|
||||
heavyInvent.DisableAll();
|
||||
}
|
||||
if (!pickupFound)
|
||||
{
|
||||
foreach (InteractableItem item in itemsInRange)
|
||||
{
|
||||
if (!item.CanPickup)
|
||||
{
|
||||
if (!item.Interact(ref invent, ref heavyInvent))
|
||||
{
|
||||
item.Interact();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
heavyInvent.transform.parent = null;
|
||||
heavyInvent.GetComponent<Rigidbody>().isKinematic = false;
|
||||
heavyInvent.EnableAll();
|
||||
heavyInvent = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (Input.GetButtonDown("Fire2"))
|
||||
{
|
||||
|
Reference in New Issue
Block a user