Ejemplo n.º 1
0
 protected void GiveItem(ItemBox.ItemType type, int amount)
 {
     if (type == ItemBox.ItemType.FirstAid)
     {
         GiveItemFirstAid(type, amount);
     }
     else
     {
         GiveItemWeapon(type, amount);
     }
 }
Ejemplo n.º 2
0
 protected void GiveItemFirstAid(ItemBox.ItemType type, int amount)
 {
     CmdHit(gameObject);
     CmdHeal(gameObject, amount);
 }
Ejemplo n.º 3
0
    protected void GiveItemWeapon(ItemBox.ItemType type, int amount)
    {
        CmdHit(gameObject);

        // Create a weapon reference
        Weapon currentWeapon = null;

        // Check if we already have an instance of this weapon
        for (int i = 0; i < weapons.Count; i++)
        {
            if (type == ItemBox.ItemType.Pistol && weapons[i] is Pistol)
            {
                currentWeapon = weapons[i];
            }
            else if (type == ItemBox.ItemType.MachineGun && weapons[i] is MachineGun)
            {
                currentWeapon = weapons[i];
            }
            else if (type == ItemBox.ItemType.Shotgun && weapons[i] is Shotgun)
            {
                currentWeapon = weapons[i];
            }
            else if (type == ItemBox.ItemType.Sniper && weapons[i] is Sniper)
            {
                currentWeapon = weapons[i];
            }
            else if (type == ItemBox.ItemType.RocketLauncher && weapons[i] is RocketLauncher)
            {
                currentWeapon = weapons[i];
            }
        }

        // If we don't have a weapon of this type, create one and
        // add it to the weapon list
        if (currentWeapon == null)
        {
            if (type == ItemBox.ItemType.Pistol)
            {
                currentWeapon = new Pistol();
            }
            else if (type == ItemBox.ItemType.MachineGun)
            {
                currentWeapon = new MachineGun();
            }
            else if (type == ItemBox.ItemType.Shotgun)
            {
                currentWeapon = new Shotgun();
            }
            else if (type == ItemBox.ItemType.Sniper)
            {
                currentWeapon = new Sniper();
            }
            else if (type == ItemBox.ItemType.RocketLauncher)
            {
                currentWeapon = new RocketLauncher();
            }
            weapons.Add(currentWeapon);
            weapons.Sort();
        }

        // Automatically equip if weapon still not available
        if (weapon == null)
        {
            SwitchWeapon(0);
        }

        currentWeapon.AddAmmunition(amount);
        currentWeapon.LoadClip();

        if (currentWeapon == weapon)
        {
            hud.UpdateWeapon(weapon);
        }
    }
Ejemplo n.º 4
0
    private void GiveItem(ItemBox.ItemType type, int amount)
    {
        // Create a weapon reference.
        Weapon currentWeapon = null;

        // Check if we already have an instance of this weapon.
        for (int i = 0; i < _weapons.Count; i++)
        {
            if (type == ItemBox.ItemType.Pistol && _weapons[i] is Pistol)
            {
                currentWeapon = _weapons[i];
            }
            else if (type == ItemBox.ItemType.MachineGun && _weapons[i] is MachineGun)
            {
                currentWeapon = _weapons[i];
            }
            else if (type == ItemBox.ItemType.Shotgun && _weapons[i] is Shotgun)
            {
                currentWeapon = _weapons[i];
            }
            else if (type == ItemBox.ItemType.Sniper && _weapons[i] is Sniper)
            {
                currentWeapon = _weapons[i];
            }
            else if (type == ItemBox.ItemType.RocketLauncher && _weapons[i] is RocketLauncher)
            {
                currentWeapon = _weapons[i];
            }
        }

        // If we don't have a weapon of this type, create one, and add it to the weapons list.
        if (currentWeapon == null)
        {
            if (type == ItemBox.ItemType.Pistol)
            {
                currentWeapon = new Pistol();
            }
            else if (type == ItemBox.ItemType.MachineGun)
            {
                currentWeapon = new MachineGun();
            }
            else if (type == ItemBox.ItemType.Shotgun)
            {
                currentWeapon = new Shotgun();
            }
            else if (type == ItemBox.ItemType.Sniper)
            {
                currentWeapon = new Sniper();
            }
            else if (type == ItemBox.ItemType.RocketLauncher)
            {
                currentWeapon = new RocketLauncher();
            }
            _weapons.Add(currentWeapon);
        }

        currentWeapon.AddAmmunition(amount);
        currentWeapon.LoadClip();

        if (currentWeapon == weapon)
        {
            _hud.UpdateWeapon(weapon);
        }
    }