Пример #1
0
    private void Setup(GunSO gunSO)
    {
        this.gunSO = gunSO;
        GetComponentInChildren <SpriteRenderer>().sprite = gunSO.gunSprite;

        firePosition.localPosition = new Vector3(0, gunSO.fireOffset, 0);
    }
Пример #2
0
 public bool CanEquipItem(ItemSO item)
 {
     if (item as ShoeSO)
     {
         if (playerShoes == null)
         {
             playerShoes = (ShoeSO)item;
             return(true);
         }
     }
     else if (item as ArmorSO)
     {
         if (playerArmor == null)
         {
             playerArmor = (ArmorSO)item;
             return(true);
         }
     }
     else if (item as GunSO)
     {
         if (playerGun == null)
         {
             playerGun = (GunSO)item;
             return(true);
         }
     }
     return(false);
 }
Пример #3
0
    public void EquipItem(ItemSO item)
    {
        Debug.LogError("Getting item: " + item.itemName);

        if (item as ShoeSO)
        {
            if (playerShoes == null)
            {
                playerShoes = (ShoeSO)item;
            }
        }
        else if (item as ArmorSO)
        {
            if (playerArmor == null)
            {
                playerArmor = (ArmorSO)item;
                this.armor  = playerArmor.armourAmount;
                Debug.LogError("Setting Armor: " + playerArmor.armourAmount + " from: " + playerArmor.itemName);
            }
        }
        else if (item as GunSO)
        {
            if (playerGun == null)
            {
                playerGun = (GunSO)item;
                this.ammo = playerGun.ammoAmount;
                Debug.LogError("Setting ammo: " + playerGun.ammoAmount + " from: " + playerGun.itemName);
            }
        }
    }
Пример #4
0
 public void UnEquipItem(int index)
 {
     if (index == 0)
     {
         playerShoes = null;
     }
     else if (index == 1)
     {
         playerArmor = null;
     }
     else if (index == 2)
     {
         playerGun = null;
     }
 }
 void DetermineGun()
 {
     if (playerGuns.value[0] != null)
     {
         for (int i = 0; i < playerGuns.value.Length; i++)
         {
             if (gun != null)
             {
                 if (playerGuns.value[i] != null && playerGuns.value[i].level > gun.level)
                 {
                     gun = playerGuns.value[i];
                 }
             }
             else
             {
                 gun = playerGuns.value[0];
             }
         }
     }
 }
Пример #6
0
    public void PickUpItem()
    {
        Collider2D[] item = Physics2D.OverlapBoxAll(this.transform.position, playerPickUpRange, 0, ItemLayers);
        if (item.Length != 0)
        {
            int _index = gameManager.itemBank.itemList.FindIndex(x => x.itemName == item[0].gameObject.GetComponent <PickableItem>().pickableItem.itemName);
            if (this.playerItems.CanEquipItem(gameManager.itemBank.itemList[_index]))
            {
                Debug.LogError("Pickup!");

                //this.playerItems.EquipItem(gameManager.itemBank.itemList[_index]);
                if (gameManager.itemBank.itemList[_index] as GunSO)
                {
                    GunSO gun = (GunSO)gameManager.itemBank.itemList[_index];
                    this.playerItems.ammo = gun.ammoAmount;
                }
                photonView.RPC("RPC_EquipItem", RpcTarget.AllBuffered, _index);
                gameManager.getPlayerItemsUI.UpdatePlayerItemUI(gameManager.itemBank.itemList[_index]);
                PlaySound("ItemPickUp");
            }
        }
    }
Пример #7
0
    // Start is called before the first frame update

    public bool CanShoot()
    {
        if (playerGun != null)
        {
            if (ammo > 0)
            {
                ammo -= 1;

                if (ammo <= 0)
                {
                    playerGun = null;
                }
                if (playerGun == null)
                {
                    GameManager.getInstance.getPlayerItemsUI.UnEquipUI(2);
                }

                return(true);
            }
        }

        return(false);
    }
Пример #8
0
 public void ChangeGun(GunSO newGun)
 {
     enumMapping[newGun.Gun].ChangeGun(newGun);
 }
Пример #9
0
 void Start()
 {
     thisGun = GetComponent <GunHolder>().gunType;
     button  = GetComponent <Button>();
 }
Пример #10
0
 public void UpdateItemsUI(ShoeSO shoe, ArmorSO armor, GunSO gun)
 {
     SetActiveItemImage(shoe, 0);
     SetActiveItemImage(armor, 1);
     SetActiveItemImage(gun, 2);
 }
Пример #11
0
 private void SetGun()
 {
     scriptableObject = _guns[gunsIndexValue];
 }