Exemplo n.º 1
0
 public void PlayerInteraction()
 {
     if (intDetector != null)
     {
         Interaction interaction = intDetector.GetClosestInteraction();
         if (interaction is WeaponItem && inventory != null)
         {
             WeaponItemData weaponItemData = ((WeaponItem)interaction).GetWeaponItemData();
             inventory.AddWeapon(weaponItemData);
             Destroy(interaction.gameObject);
             //If this is the only weapon in inventory, and no weapon is equiped, equip it
             if (inventory.GetArsenalSize() == 1 && equippedWeapon == null)
             {
                 InstantiateWeapon(weaponItemData.GetPrefabPath());
             }
             Debug.Log(interaction.gameObject.name);
         }
         else if (interaction is Door)
         {
             Door door = (Door)interaction;
             if (door.IsInteractive())
             {
                 door.Open();
             }
         }
     }
     else
     {
         Debug.Log("Interaction detector not found on " + gameObject.name);
     }
 }
Exemplo n.º 2
0
    public IEnumerator ChangeWeapon(int input)
    {
        WeaponItemData weaponItemData = null;

        //check if changing weapon is possible (more than 1 weapon in inventory)
        if (HasInventory() && input != 0 && inventory.GetArsenalSize() > 1 && CanChangeWeapon())
        {
            ChangeWeaponAxisInUse = true;
            Debug.Log(input);
            if (input < 0)
            {
                weaponItemData = inventory.SelectNextWeapon();
            }
            else if (input > 0)
            {
                weaponItemData = inventory.SelectPreviousWeapon();
            }
            if (weaponItemData != null)
            {
                InstantiateWeapon(weaponItemData.GetPrefabPath());
                yield return(weaponSwapDelaySeconds);
            }
        }
        ChangeWeaponAxisInUse = false;
    }
Exemplo n.º 3
0
    public IEnumerator EquipLatestWeapon()
    {
        WeaponItemData weaponItemData = null;

        //check if changing weapon is possible (more than 1 weapon in inventory)
        if (HasInventory() && inventory.GetArsenalSize() > 1 && CanChangeWeapon())
        {
            weaponItemData        = inventory.SelectLatestWeapon();
            ChangeWeaponAxisInUse = true;
            if (weaponItemData != null && weaponItemData.GetPrefabPath() != weapon.GetPrefab())
            {
                InstantiateWeapon(weaponItemData.GetPrefabPath());
                yield return(weaponSwapDelaySeconds);
            }
        }
        ChangeWeaponAxisInUse = false;
    }
Exemplo n.º 4
0
    public IEnumerator EquipWeaponSlot(int slot)
    {
        WeaponItemData weaponItemData = null;

        if (HasInventory() && CanChangeWeapon())
        {
            weaponItemData        = inventory.SelectWeaponSlot(slot);
            ChangeWeaponAxisInUse = true;
            if (weaponItemData != null)
            {
                InstantiateWeapon(weaponItemData.GetPrefabPath());
                yield return(weaponSwapDelaySeconds);
            }
        }
        ChangeWeaponAxisInUse = false;
    }