Beispiel #1
0
 public override void Update()
 {
     sinceLastShot += Time.deltaTime;
     if (sinceLastShot >= shotFrequency)
     {
         turretBattery.fire(player.transform.position);
         sinceLastShot = 0f;
     }
 }
Beispiel #2
0
 public override void Update()
 {
     if (player != null)
     {
         sinceLastShot += Time.deltaTime;
         if (sinceLastShot >= shotFrequency)
         {
             turretBattery.fire(player.transform.position);
             sinceLastShot = 0f;
         }
     }
     else
     {
         sinceLastShot = 0f;
         player        = GameObject.Find("Player");
     }
 }
Beispiel #3
0
    public override void Update()
    {
        //Shield logic
        if (Input.GetKeyDown("k"))
        {
            enableShield(1f);
        }

        //Shooting logic
        if (enemy != null)
        {
            if (autoFireMode && !primaryOverheated)
            {
                turretBattery.fire(enemy.position);
                primaryFireCooldown(primaryShotCooldownTime);
            }
            //Missiles controlled by button press
            if (GameController.Instance.missileButtonPressed || Input.GetKey("m"))
            {
                if (!secondaryOverheated)
                {
                    GameController.Instance.missileButtonPressed = false;
                    missileBattery.fire(enemy.position);
                    secondaryFireCooldown();
                }
            }

            float regularCooldown  = 0.1f;
            float postComboRecover = 0.6f;
            //Primary fire controlled by button press
            if (Input.GetKeyDown("l"))
            {
                switch (primaryComboState)
                {
                case 0:     //No combo/starting state
                    if (!primaryOverheated)
                    {
                        fireAndCool(enemy.position, regularCooldown, 0.2f);
                        primaryComboState = 1;
                        comboGUI.updateIntensity(primaryComboState);
                        powerComboWarmUp(0.3f);
                    }
                    break;

                case 1:                  //First shot already away
                    if (powerComboReady) //Just right
                    {
                        fireAndCool(enemy.position, regularCooldown, 0.6f);
                        powerComboWarmUp(0.3f);
                        primaryComboState = 2;     //Move to final combo stage
                        comboGUI.updateIntensity(primaryComboState);
                    }
                    else       //Too slow or too fast
                    {
                        fireAndCool(enemy.position, regularCooldown, 0.2f);
                        powerComboWarmUp(0.3f);
                    }
                    break;

                case 2:                  //Second shot already away
                    if (powerComboReady) //COMBO ACHIEVED
                    {
                        fireAndCool(enemy.position, postComboRecover, 1f);
                        missileBattery.fire(enemy.position);
                        primaryComboState = 0;     //Combo achieved
                        comboGUI.updateIntensity(3);
                    }
                    else     //shot attempt while overheated
                    {
                        fireAndCool(enemy.position, regularCooldown, 0.2f);
                        powerComboWarmUp(0.3f);
                        primaryComboState = 1;     //Combo breaker
                        comboGUI.updateIntensity(primaryComboState);
                    }
                    break;
                }
            }
        }
        else if (enemy == null)
        {
            GameObject[] enemiesGO = GameObject.FindGameObjectsWithTag("Enemy");
            Transform[]  enemies   = new Transform[enemiesGO.Length];
            if (enemies.Length != 0)
            {
                for (int i = 0; i < enemies.Length; i++)
                {
                    enemies[i] = enemiesGO[i].transform;
                }
            }
            enemy = GetClosestEnemy(enemies);
        }

        /* Fire zone gameplay test */
        //if(openFirePrimary && !primaryOverheated)
        //{
        //    turretBattery.fire(fireZonePos);
        //    primaryFireCooldown(primaryShotCooldownTime);
        //}
    }