Esempio n. 1
0
    //called from PlayerBase when one of the player died
    public virtual void GameOver(bool isWin)
    {
        // if player destroyed hostile base
        if (isWin && gameOverFlag == false)
        {
            // if incoming boss remains
            if (PublicLevel.GetIsBoss())
            {
                //spawn boss
                spawnControl.SummonBoss();
                PublicLevel.SetIsBoss(false);
            }
            else
            {
                PublicLevel.SetPlayerLevel(PublicLevel.GetStageLevel() + 1);
                spawnControl.DeadAllHostileCreature();
                aiplayer.AIplayerStop();
                winPanel.SetActive(true);
                winPanel.transform.GetChild(0).GetComponent <Text>().text = "Your level is " + PublicLevel.GetPlayerLevel().ToString();
                Debug.Log("player win!");
            }

            for (int i = 0; i < PublicLevel.usingLaneNum; ++i)
            {
                GameObject[] laneObjects = GameObject.FindGameObjectsWithTag("Lane" + i.ToString());
                foreach (GameObject laneObject in laneObjects)
                {
                    if (laneObject.name == "creature0_0Prefab(Clone)" && laneObject.GetComponent <DefaultCreature>().GetSide() == GameControl.Sides.Hostile)
                    {
                        laneObject.GetComponent <DefaultCreature>().Dead();
                    }
                }
            }
            return;
        }
        // if player's base was destroyed
        else if (!isWin && gameOverFlag)
        {
            losePanel.SetActive(true);
        }
        gameOverFlag = true;
        aiplayer.AIplayerStop();
    }