示例#1
0
 /**
  * Called if the player X press the fire button
  *
  * */
 void TryToFire()
 {
     if (weaponState == WeaponState.READY)
     {
         if (timer >= shootFrequenzy)
         {
             timer = 0;
             for (int i = 0; i < bulletCount; i++)
             {
                 GameObject       obj          = Instantiate(bullet, firePoint.position, firePoint.rotation);
                 MachineGunBullet bulletOrigin = obj.GetComponent <MachineGunBullet>();
                 bulletOrigin.player = GetComponentInParent <CharacterControll>().gameObject;
                 obj.SetActive(true);
             }
             setAmmunition(currentAmmunition - 1);
         }
     }
     else if (weaponState == WeaponState.REALOAD)
     {
     }
     else if (weaponState == WeaponState.OUT_OF_AMMO)
     {
     }
     else
     {
         throw new NotImplementedException();
     }
 }
示例#2
0
    private void Shoot(IGetDamage target)
    {
        IBullet bullet = new MachineGunBullet(bulletType, currentMachineGunStats.damage);

        target.GetDamage(bullet);
        machineGunClip--;
    }
示例#3
0
    public void ApplyDamage(MachineGunBullet bullet)
    {
        float damage = bullet.damage;

        foreach (GameObject obj in bullet.tables)
        {
            if (this.tables.Contains(obj))
            {
                damage = damage * (1 - protectionFactor);
                break;
            }
        }

        if (currentLive > 0)
        {
            setLive(currentLive - damage);

            if (currentLive <= 0)
            {
                bullet.player.GetComponent <CharacterControll>().addToScore(SCORE_ON_DEATH);
            }
        }
    }
示例#4
0
using UnityEngine;