Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        energyDrainTimer         += Time.deltaTime;
        firestormXChargeTimer    += Time.deltaTime;
        energyStatusBar.value     = playerStatus.energy;
        firestormXStatusBar.value = playerStatus.firestormXCharge;

        if (Input.GetKey(KeyCode.F))
        {
            foreach (LaserGun LaserGun in playerLaserGuns)
            {
                LaserGun.Shoot();
            }
        }

        if (Input.GetKeyDown(KeyCode.Alpha1)) // DEBUG
        {
            if (playerLaserGuns.Count < playerModifiers.maxCannons)
            {
                addCannon();
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (playerStatus.firestormXCharge >= 100)
            {
                playerStatus.firestormXCharge = 0;
                playerFirestormX.Shoot();
            }
        }

        if (energyDrainTimer >= playerModifiers.energyDrainRate)
        {
            energyDrainTimer = 0;
            playerStatus.energy--;
        }

        if (firestormXChargeTimer >= playerModifiers.firestormXChargeRate)
        {
            playerStatus.firestormXCharge++;
            if (playerStatus.firestormXCharge >= 100)
            {
                playerStatus.firestormXCharge = 100;
            }
            firestormXChargeTimer = 0;
        }

        if (playerStatus.energy <= 0)
        {
            playerDie();
        }
    }
 private void shoot()
 {
     if (fireRateTimer >= fireRate)
     {
         if (canShoot)
         {
             enemyLaserGun.Shoot();
         }
         resetFireRateOnce = false;
         fireRateTimer     = 0;
     }
 }
Esempio n. 3
0
    /// <summary>
    /// Alienin aseen ampumisen parametrit, mm. nopeus,,ammukset.
    /// </summary>
    private void AmmuVihu(LaserGun laserVihu)
    {
        PhysicsObject ammus = laserVihu.Shoot();

        if (ammus != null)
        {
            ammus.Width  = 35;
            ammus.Height = 4;
            ammus.Image  = LoadImage("laser");
            ammus.CollisionIgnoreGroup = 1;
            if (laserVihu.IsDestroyed == true)
            {
                ammus.Destroy();
                laserVihu.AttackSound = null;
            }
        }
        laserVihu.FireRate           = RandomGen.NextDouble(1, 3);
        laserVihu.Power.DefaultValue = 150;
        laserVihu.InfiniteAmmo       = true;
    }
Esempio n. 4
0
 public void Shoot()
 {
     laserGun.Shoot();
 }