Ejemplo n.º 1
0
    public void SetBomb()
    {
        bool ins = false;;

        if (inventory.limitedAmmoSearch.ContainsKey(2))
        {
            ammo = inventory.limitedAmmoSearch[2];
            if (ammo.selected)
            {
                ins = true;
            }
        }
        else
        {
            ammo = null;
        }
        if (ins)
        {
            if (ammo != null && ammo.CheckAmmo())
            {
                GameObject mb = Instantiate(ammo.ammoPrefab, firePoint.position, Quaternion.identity) as GameObject;
                ammo.ActualAmmoCount(-1);
            }
            else if (inventory.CheckItem(6) && canInstantiate)//bomb
            {
                GameObject mb = Instantiate(beams.bomb, firePoint.transform.position, Quaternion.identity);
                canInstantiate = false;
                Invoke("InsBomb", 1f);
            }
        }
    }
Ejemplo n.º 2
0
    private void ReserveAcquired(ReserveAcquired reserve)
    {
        itemGot = reserve.gameObject;
        var ammo       = inventory.limitedAmmo;
        var ammoSearch = inventory.limitedAmmoSearch;

        switch (reserve.ItemType)
        {
        case ReserveType.Missile:
            ammo[0].AddCapacity(999);
            break;

        case ReserveType.SuperMissile:
            //Check if is the first time on get the item.
            if (!ammoSearch.ContainsKey(1))
            {
                PlayerInventory.CountableAmmo newAmmo =
                    new PlayerInventory.CountableAmmo(false, 1, defaultAmmoPrefabs[0], 0, 0);
                ammoSearch.Add(1, newAmmo);
                if (ammo.Count > 1)
                {
                    List <PlayerInventory.CountableAmmo> aux = new List <PlayerInventory.CountableAmmo>();
                    aux.Add(ammo[0]);
                    aux.Add(newAmmo);
                    aux.Add(ammo[1]);
                    inventory.limitedAmmo = aux;
                }
                else
                {
                    ammo.Add(newAmmo);
                }
                hudUI.AddAndSubscribe(1);
            }
            ammoSearch[1].AddCapacity(999);
            break;

        case ReserveType.SuperBomb:
            //Check if is the first time on get the item.
            if (!ammoSearch.ContainsKey(2))
            {
                PlayerInventory.CountableAmmo newAmmo =
                    new PlayerInventory.CountableAmmo(false, 2, defaultAmmoPrefabs[1], 0, 0);
                ammoSearch.Add(2, newAmmo);
                ammo.Add(newAmmo);
                hudUI.AddAndSubscribe(2);
            }
            ammoSearch[2].AddCapacity(20);
            break;

        case ReserveType.EnergyTank:
            GameEvents.healthTank.Invoke();
            break;
        }
        AddToPlayerInventory(reserve);
        audioPlayer.ClipAndPlay(reserveAcquired);
        panel.transform.GetChild(0).GetComponent <TextMeshProUGUI>().text = reserve.nameItem;
        Pause.onAnyMenu = true;
    }