Exemplo n.º 1
0
    void CheckLife()
    {
        if (lostHeathToChangeSprite != 0)
        {
            ChangeSpriteFollowHealth();
        }
        //Handle when health is <= 0
        if (health <= 0)
        {
            //if this health is of base
            if (GetComponent <Vehicle> ())
            {
                WinLoseCondition wlCondition = GameObject.FindGameObjectWithTag("Win Lose Condition").GetComponent <WinLoseCondition> ();
                wlCondition.Lose();
            }
            //if this health is of block
            if (GetComponent <BlockOfStage> ())
            {
                Instantiate(DieEffectPrefab, transform.position, Quaternion.identity);
                GetComponent <BlockOfStage> ().BlockDestroy();

                return;
            }
            //if this health is of enemy
            if (GetComponent <Enemy> ())
            {
                Instantiate(DieEffectPrefab, transform.position, Quaternion.identity);
                GetComponent <Enemy> ().EnemyDestroy();
                return;
            }
        }
        //if this health is of prisoner
        if (GetComponent <Prisoner> () && !isDead)
        {
            SetHealthBar();
            StartCoroutine("PlayHitSpriteAndHitSound");
        }
    }
Exemplo n.º 2
0
    //---------------------------------------------------------------
    public void CheckAlivePrisonerLeft()
    {
        int alivePrisonerNum = prisonerArray.Length;

        foreach (Prisoner thisPrisoner in prisonerArray)
        {
            Health thisPrisonerHealth = thisPrisoner.GetComponent <Health>();
            bool   isDead             = (thisPrisonerHealth.GetHealth() <= 0);
            if (isDead)
            {
                alivePrisonerNum--;
                print("alivePrisonerNum " + alivePrisonerNum);
            }
        }

        if ((alivePrisonerNum <= 0))
        {
            allPrisonerDead = true;
            //as all the prisoners are down, set the game is lost
            WinLoseCondition wlCondition = GameObject.FindGameObjectWithTag("Win Lose Condition").GetComponent <WinLoseCondition>();
            wlCondition.Lose();
        }
    }