public void set_ammo_amount(int ammo, int amount)
        {
            Debug.Log("set ammo");
            EAmmoType ammo_t = (EAmmoType)ammo;

            ammo_amount[ammo_t] = amount;
            remove_ammo(ammo_t, amount);
        }
        private void add_ammo_item_to_inventory(EAmmoType type, int amount)
        {
            GameObject ammobox = get_object_from_path(Common.ammo_type_to_path[type]);

            ammobox.name = ammobox.name.Replace("(Clone)", "");
            Items.AmmoBox script = ammobox.GetComponent <Items.AmmoBox>();
            script.on_pickup();
            items_in_backpack.Add(script);
            //Destroy(ammobox);
            Debug.Log("Add ammo " + amount);
        }
Exemple #3
0
        private void deploy_weapon(Vector3 position)
        {
            int weapon_id = Mathf.RoundToInt(Random.Range(-0.4f, 12.4f));

            while (weapon_id > weapon_prefabs.Count - 1)
            {
                Debug.Log("ERR (DeployItems.cs): weapon_id > weapon_prefabs.Count - 1");
                weapon_id = Mathf.RoundToInt(Random.Range(0.0f, 12.0f));
            }
            ammo_type_to_use = (EAmmoType)weapon_prefabs[weapon_id].get_ammo_type();
            Instantiate(weapon_prefabs[weapon_id], position, new Quaternion(10.0f, 0.0f, 5.0f, 0.0f));
        }
Exemple #4
0
        private void deploy_ammo(Vector3 position)
        {
            int change_ammo = Mathf.RoundToInt(Random.Range(0.0f, 100.0f));

            if (change_ammo > 90.0f)
            {
                ammo_type_to_use = (EAmmoType)get_int_ammo_type();
            }
            for (int i = 0; i < 2; i++)
            {
                Instantiate(ammobox_prefabs[(int)ammo_type_to_use], position, new Quaternion(50.0f, 20.0f, 10.0f, 0.0f));
            }
        }
        private Pair <EAmmoType, int> get_ammo <T>(T item) where T : Items.Item
        {
            System.Type item_type = item.GetType();
            string[]    arr       = item_type.ToString().Split('.');
            string      type      = arr[arr.Length - 1];

            if (type == "AmmoBox")
            {
                EAmmoType ammo_type   = ((Items.AmmoBox)(Object) item).ammo_type;
                int       ammo_amount = ((Items.AmmoBox)(Object) item).ammo_amount;
                return(new Pair <EAmmoType, int>(ammo_type, ammo_amount));
            }
            return(null);
        }
Exemple #6
0
    public void CheckAmmoType(EAmmoType hitAmmoType)
    {
        if (hitAmmoType == desiredAmmoType)
        {
            bIsRightAmmoType = true;
        }

        if (bIsRightAmmoType)
        {
            if (bShouldLoadScene)
            {
                StartCoroutine(LoadScene());
            }
            else
            {
                OpenDoor();
            }
        }
    }
    public void ModCharge(float ModAmount, EAmmoType hitAmmoType)
    {
        ChargeMod            = ModAmount;
        CurrentChargeAmount += ChargeMod;
        if (CurrentChargeAmount >= ChargeLimit)
        {
            Debug.Log("Limit has been reached!");
            bIsCharged = true;
            StopCoroutine(DecreaseChargeOverTime());
            boundGO.SendMessage("OnChargerEvent");
        }
        if (CurrentChargeAmount <= 0)
        {
            StopCoroutine(DecreaseChargeOverTime());
        }

        if (hitAmmoType != desiredAmmoType)
        {
            StopCoroutine(DecreaseChargeOverTime());
            //CurrentChargeAmount = CurrentChargeAmount - WrongAmmoTypeMod;
        }
    }
 public void remove_ammo(EAmmoType type, int ammo_left)
 {
     remove_ammo(Common.ammo_type_to_string[type]);
     if (ammo_left > 0)
     {
         Debug.Log("Ammoleft" + (ammo_left > 0));
         while (ammo_left > 0)
         {
             Debug.Log("Ammo left " + ammo_left);
             int ammo_packs = ammo_left / Common.max_ammo;
             if (ammo_packs >= 1)
             {
                 add_ammo_item_to_inventory(type, Common.max_ammo);
                 ammo_left -= Common.max_ammo;
             }
             else if (ammo_left > 0)
             {
                 add_ammo_item_to_inventory(type, ammo_left);
                 ammo_left = 0;
             }
         }
     }
 }
        public int get_ammo_amount(int ammo)
        {
            EAmmoType ammo_t = (EAmmoType)ammo;

            return(ammo_amount[ammo_t]);
        }