Пример #1
0
    public void TakeDamage(float damage)
    {
        if (!invulnerableAfterDamage)
        {
            float halfDamage_1 = damage / 2.0f;
            float halfDamage_2 = damage / 2.0f;
            healthPoints -= halfDamage_1;

            float minusOfShield = halfDamage_2 / 2.0f;
            if (minusOfShield < shieldPoints)
            {
                shieldPoints -= minusOfShield;
            }
            else if (minusOfShield == shieldPoints)
            {
                shieldPoints = 0.0f;
            }
            else if (minusOfShield > shieldPoints && shieldPoints == 0)
            {
                healthPoints -= minusOfShield * 2.0f;
            }
            else if (minusOfShield > shieldPoints && shieldPoints > 0)
            {
                minusOfShield -= shieldPoints;
                shieldPoints   = 0.0f;
                healthPoints  -= minusOfShield; // was ... * 2.0f
            }

            //Debug.Log("My Current health points are: " + healthPoints.ToString());
            if (healthPoints <= 0.0f)
            {
                invulnerableAfterDamage = true;
                // Запускаем процедуру гибели объекта
                deathDel();
            }

            if (myObject.tag == "Player")
            {
                playerUpDel(healthPoints, shieldPoints);
                ControlPanelCanvasScript CPCS = FindObjectOfType <ControlPanelCanvasScript>();
                CPCS.UpdateHealth(healthPoints);
                CPCS.UpdateShield(shieldPoints);
            }

            if (myObject.tag == "Planet" || myObject.tag == "Comet")
            {
                planetChHlth(healthPoints);
            }

            if (myObject.tag == "Enemy")
            {
                enemyChHlth(healthPoints / maxHealthPoints);
            }

            if (myObject.tag == "PlasmaArea")
            {
                plasmaNearFlight();
            }
        }
    }
Пример #2
0
    public void TakeUltimateDamage()
    {
        healthPoints = 0;
        shieldPoints = 0;

        ControlPanelCanvasScript CPCS = FindObjectOfType <ControlPanelCanvasScript>();

        CPCS.UpdateHealth(healthPoints);
        CPCS.UpdateShield(shieldPoints);

        invulnerableAfterDamage = true;
        deathDel();
    }
Пример #3
0
    void Start()
    {
        playerInitHealth = ConstGameCtrl.instance.GetMaxPlayerParam(ConstGameCtrl.PlayerShipUpgrades.health);
        playerInitShield = ConstGameCtrl.instance.GetMaxPlayerParam(ConstGameCtrl.PlayerShipUpgrades.shield);
        playerFuelVolume = ConstGameCtrl.instance.GetMaxPlayerParam(ConstGameCtrl.PlayerShipUpgrades.fuel);

        lastFuelVolume = playerFuelVolume;

        Random.InitState(42);
        CPCS = FindObjectOfType <ControlPanelCanvasScript>();

        CPCS.UpdateHealth(playerInitHealth);
        CPCS.UpdateShield(0);

        canFly = true;
    }
Пример #4
0
 public void OnPlasmaWound(float v1, float v2)
 {
     CPCS.UpdateHealth(v1);
     CPCS.UpdateShield(v2);
 }