Ejemplo n.º 1
0
 void HealthCheck()
 {
     //this boss health check will see if the battery is below 0 if so then
     //it checks the oower level to recharge the battery
     //then lowers the power level and weaponstates.
     if (activeBattery.batteryHP <= 0)
     {
         if (powerLevel > 0)
         {
             activeBattery.RechargeBattery();
             powerLevel--;
             rHGunState -= 1;
             lHGunState -= 1;
         }
         else
         {
             CompleteObjective(this);
             bossState = StateBoss.dead;
             Instantiate(deathExplosion, transform.position, transform.rotation);
             gameObject.SetActive(false);
         }
     }
     else
     {
         bossState = StateBoss.alive;
     }
 }
Ejemplo n.º 2
0
    //void PlayerTouchControls()
    //{ // to use with touch joypad ui elements
    //   //// float horizTurn;
    //    float vertMove;
    //    float horizMove;

    //    //transform.Translate(new Vector2(horzStrafe, vert));
    //    //transform.Rotate(new Vector3(0, 0, horiz));


    //    if (joystick.Horizontal >= .2)
    //    {
    //        horizMove = moveSpeed * Time.deltaTime;

    //    }
    //    else if (joystick.Horizontal <= -.2)
    //    {
    //        horizMove = -moveSpeed * Time.deltaTime;
    //    }
    //    else horizMove = 0;

    //    if (joystick.Vertical >= .2)
    //    {
    //        vertMove = moveSpeed * Time.deltaTime;

    //    }
    //    else if (joystick.Vertical <= -.2)
    //    {
    //        vertMove = -moveSpeed * Time.deltaTime;
    //    }
    //    else horizMove = 0;

    //}



    void HealthCheck()
    {         //this is the health module. it takes the activebattery object and checks its HP count
        if (activeBattery.batteryHP <= 0)
        {     //if it hits 0 it checks the powerlevel to see if it can recharge the battery
            if (powerLevel > 0)
            { //if its greater than 0 then it activates the activebattery built in method to recharge it at the cost of one power level.
                activeBattery.RechargeBattery();
                powerLevel--;
                Instantiate(rechargeEffect, transform.position, transform.rotation);
            }
            else
            {// if it cannot recharge [the powerlevel is at zero] then the game is lost
                gameState   = StateGame.lose;
                playerState = StatePlayer.dead;
                Instantiate(deathExplosion, transform.position, transform.rotation);
            }
        }
        else
        {//if the health is not lower than 0 then the player state is alive adn the number of recharges is displayed
            playerState = StatePlayer.alive;
            activeBattery.numberOfRecharges.text = "X" + powerLevel.ToString();
        }
    }