Exemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag != "Player")
        {
            return;
        }

        Inventory inventory = PlayerController.player.GetComponent <Inventory>();

        List <Drop> owned   = drops.ContainsWeapon(inventory.arsenal);
        List <Drop> unowned = drops.DiscontainsWeapon(inventory.arsenal);

        if (unowned.Count > 0 && Chance(.01f * unowned.Count))
        {
            // drop new weapon
            Drop drop = GetRandomWeaponFrom(unowned, true);
            NewWeapon(drop.weapon, drop.GetAmmo(), inventory);
        }
        else
        {
            // drop ammo
            if (unowned.Count == 0 || Chance(.6f))
            {
                // for owned weapon
                Drop drop = GetRandomWeaponFrom(owned, false);
                MoreAmmo(drop.weapon, drop.GetAmmo());
            }
            else
            {
                // for unowned weapon
                Drop drop = GetRandomWeaponFrom(unowned, false);
                MoreAmmo(drop.weapon, drop.GetAmmo());
            }
        }

        Destroy(gameObject);
    }