Beispiel #1
0
 // 2
 private void pickupAssaultRifleAmmo()
 {
     ammo.AddAmmo(Constants.AssaultRifle, 50);
     gameUI.SetPickUpText("Assault rifle ammo picked up + 50 ammo");
     if (gunEquipper.GetActiveWeapon().tag == Constants.AssaultRifle)
     {
         gameUI.SetAmmoText(ammo.GetAmmo(Constants.AssaultRifle));
     }
 }
Beispiel #2
0
 private void PickupAssaultRifleAmmo()
 {
     m_Ammo.AddAmmo(Constants.AssaultRifle, 50);
     GameUi.SetPickupText("Assault rifle ammo picked up + 50 ammo");
     if (m_GunEquipper.GetActiveWeapon().CompareTag(Constants.AssaultRifle))
     {
         GameUi.SetAmmoText(m_Ammo.GetAmmoCount(Constants.AssaultRifle));
     }
 }
Beispiel #3
0
 private void PickupPistolAmmo()
 {
     ammo.AddAmmo(Constants.Pistol, 20);
     gameUI.SetPickUpText("Pistol ammo picked up + 20 ammo");
     if (gunEquipper.GetActiveWeapon().tag == Constants.Pistol)
     {
         gameUI.SetAmmoText(ammo.GetAmmo(Constants.Pistol));
     }
 }
    public static void LoadFakeDebugSave()
    {
        dontWriteFiles = true;
        int       HP    = 99999;
        int       MaxHP = 99999;
        int       AP    = 99999;
        int       MaxAP = 99999;
        int       level = 1;
        ArmorType aType = ArmorType.Blue;

        string[] guns = new string[5] {
            "fists", "pistol", "shotgun", "rocket", "chaingun"
        };

        AmmoType[] ammoTypes = (AmmoType[])Enum.GetValues(typeof(AmmoType));
        Ammo[]     ammos     = new Ammo[ammoTypes.Length];
        for (int i = 0; i < ammoTypes.Length; i++)
        {
            AmmoType type = ammoTypes[i];
            Ammo     ammo = new Ammo(type);
            ammo.AddAmmo(999);
            ammos[i] = ammo;
        }

        save      = new SaveVariables(HP, MaxHP, AP, MaxAP, level, aType, guns, ammos);
        saveIndex = 0;
    }
    static SaveVariables DefaultSave()
    {
        int       HP    = 100;
        int       MaxHP = 200;
        int       AP    = 0;
        int       MaxAP = 100;
        int       level = 1;
        ArmorType aType = ArmorType.Green;

        string[] guns = new string[2] {
            "fists", "pistol"
        };

        AmmoType[] ammoTypes = (AmmoType[])Enum.GetValues(typeof(AmmoType));
        Ammo[]     ammos     = new Ammo[ammoTypes.Length];
        for (int i = 0; i < ammoTypes.Length; i++)
        {
            AmmoType type = ammoTypes[i];
            Ammo     ammo = new Ammo(type);
            if (type == AmmoType.Bullet)
            {
                ammo.AddAmmo(75);
            }
            ammos[i] = ammo;
        }

        return(new SaveVariables(HP, MaxHP, AP, MaxAP, level, aType, guns, ammos));
    }
Beispiel #6
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         ammoSlot.AddAmmo(ammoType);
         Destroy(gameObject);
     }
 }
Beispiel #7
0
 private void pickupSniperAmmo()
 {
     ammo.AddAmmo(Constants.Sniper, 5);
     gameUI.SetPickupText("Pickup: Ammo +5");
     if (gunEquipper.GetActiveWeapon().tag == Constants.Sniper)
     {
         gameUI.SetAmmoText(ammo.GetAmmo(Constants.Sniper));
     }
 }
Beispiel #8
0
    void OnPick(PlayerCharacterController p)
    {
        Ammo PlayerAmmo = p.GetComponent <Ammo>();

        if (PlayerAmmo)
        {
            PlayerAmmo.AddAmmo();
            pickup.PlayPickupFeedback();
            Destroy(gameObject);
        }
    }
Beispiel #9
0
    /*
     *  Adding ammo based on type.
     */
    public bool AddAmmo(AmmoType type, int amountToAdd)
    {
        for (int i = 0; i < ammos.Length; i++)
        {
            Ammo a = ammos[i];
            if (a.type == type)
            {
                inventoryUpdated = true;
                return(a.AddAmmo(amountToAdd));
            }
        }

        print($"Cannot add ammo of type {type.ToString()} as it doesn't exist in our inventory!");
        return(false);
    }
Beispiel #10
0
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipSlot;

        Equipment oldItem = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
            Destroy(currentMeshes[slotIndex].gameObject);
        }

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        currentEquipment[slotIndex] = newItem;
        GameObject newMesh = Instantiate <GameObject>(newItem.go);

        newMesh.transform.parent   = inventory.slots[(int)newItem.equipSlot].transform;
        newMesh.transform.position = inventory.slots[(int)newItem.equipSlot].transform.position;
        newMesh.transform.rotation = inventory.slots[(int)newItem.equipSlot].transform.rotation;
        currentMeshes[slotIndex]   = newMesh;

        if ((int)newItem.equipSlot == 1)
        {
            gun = newMesh.GetComponent <GunController>();

            if (newMesh.GetComponent <Throwable>())
            {
                currentEquipment[1] = null;
            }
        }

        if ((int)newItem.equipSlot == 2)
        {
            inventory.Remove(oldItem);
            ammo = newMesh.GetComponent <Ammo>();
            ammo.AddAmmo();
        }
    }
Beispiel #11
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            Debug.Log("Player hit resource pickup");
            GameObject player = collision.gameObject;
            switch (type)
            {
            case ResourceType.HEALTH:
                Health health = player.GetComponent <Health>();
                health.AddHealth(value);
                break;

            case ResourceType.AMMO:
                Ammo ammo = player.GetComponent <Ammo>();
                ammo.AddAmmo(value);
                break;

            case ResourceType.MAGIC:
                Magic magic = player.GetComponent <Magic>();
                magic.AddMagic(value);
                break;

            case ResourceType.STORY:
                panel.SetActive(true);
                break;

            case ResourceType.WEAPON:
                Shooting shooting = player.GetComponentInChildren <Shooting>();
                shooting.hasShotgun = true;
                panel.SetActive(true);
                break;

            default:
                break;
            }
            Destroy(gameObject);
        }
    }
Beispiel #12
0
    public bool Replenish(Item item)
    {
        Ammo newAmmo       = null;
        Item inventoryItem = null;
        Ammo inventoryAmmo = null;

        newAmmo = item.GetComponent <Ammo>();
        if (newAmmo != null)
        {
            inventoryItem = GetItem(newAmmo.ammoType);
            inventoryAmmo = inventoryItem?.GetComponent <Ammo>();
        }

        if (inventoryAmmo != null && newAmmo != null)
        {
            if (inventoryAmmo.ammoType == newAmmo.ammoType)
            {
                // swap items if picking up IUsable and we are only carrying ammo
                if (!(inventoryItem is IUsable) && item is IUsable)
                {
                    newAmmo.AddAmmo(inventoryAmmo.AllAmmo);
                    RemoveItem(inventoryItem);
                    PoolingManager.Remove(inventoryItem.gameObject, false);
                    EventManager.RaiseOnItemCollected();
                    return(false);
                }
                else if (inventoryAmmo.AddAmmo(newAmmo.AllAmmo))
                {
                    item.gameObject.SetActive(false);
                    PoolingManager.Remove(item.gameObject, false);
                    EventManager.RaiseOnItemCollected();
                    return(true);
                }
            }
        }
        return(false);
    }
Beispiel #13
0
 // 2
 private void pickupAssaultRifleAmmo()
 {
     ammo.AddAmmo(Constants.AssaultRifle, 50);
 }
Beispiel #14
0
 void pickupPistolAmmo()
 {
     ammo.AddAmmo(Constants.Pistol, 20);
 }