示例#1
0
 void SwitchWeapn()
 {
     if (!weapon.IsReloading())
     {
         if (inventory[1] != null)
         {
             AudioSource.PlayClipAtPoint(switchWeaponClip, this.transform.position);
             if (weaponIndex != inventory.Length - 1)
             {
                 weapon = inventory[1];
                 InventoryWeapon.activeIndex = 1;
                 weaponIndex           = 1;
                 spriteRenderer.sprite = inventory[weaponIndex].sprite;
             }
             else
             {
                 weapon = inventory[0];
                 InventoryWeapon.activeIndex = 0;
                 weaponIndex           = 0;
                 spriteRenderer.sprite = inventory[weaponIndex].sprite;
             }
             weapon.UpdateAmmoText();
             InventoryWeapon.ChangeInventory(this.inventory);
         }
     }
 }
示例#2
0
    // Use this for initialization
    void Start()
    {
        Zombie.aliveZombies.Clear();
        life = maxLife;
        UpdateText();
        SetComponents();
        weapons.Add(gun);
        weapons.Add(shotgun);
        weapons.Add(rifle);
        weapons.Add(rpg);
        weapons.Add(sniper);

        foreach (Weapon weapon in weapons)
        {
            weapon.SetPlayerAttack(this);
        }
        weapon                = weapons[0];
        inventory[0]          = weapon;
        spriteRenderer.sprite = weapons[0].sprite;
        InventoryWeapon.ChangeInventory(this.inventory);
        foreach (Weapon weapon in inventory)
        {
            if (weapon)
            {
                weapon.UpdateAmmoText();
            }
        }
    }
示例#3
0
    void OnTriggerEnter2D(Collider2D collider2D)
    {
        PlayerAttack player = FindObjectOfType <PlayerAttack>();

        if (collider2D.gameObject.tag.Equals("Player") && collider2D == collider2D.gameObject.GetComponent <PlayerAttack>().body)
        {
            Destroy(gameObject);
            FindWeapon();
            if (weapon.gameObject.GetComponent <PlayerAttack>().GetWeapon() == weapon)
            {
                weapon.SetUpWeapon(true);
            }
            else
            {
                weapon.SetUpWeapon(false);
            }
            AudioSource.PlayClipAtPoint(pickupClip, this.transform.position);
            InventoryWeapon.ChangeInventory(player.inventory);
        }
    }