示例#1
0
 private void Awake()
 {
     if (itLevelCheker)
     {
         DataBaseLevel data = DataWork.LoadLevel();
         levelProgress = data.levelProgress;
     }
 }
    private void FixedUpdate()
    {
        if (timer < 100)
        {
            if (timer < 0)
            {
                if (enemyCounter == 0)
                {
                    if (waveNumber == generator.Length - 1)
                    {
                        waveOver = true;
                    }
                    else
                    {
                        buttonStartWave.SetActive(true);
                        timer = 150;
                    }
                }
                else
                {
                    enemyCounter -= 1;
                    timer         = generator[waveNumber].creepSpownTime;
                    switch (generator[waveNumber].witchEnemy)
                    {
                    case EnemyBase.enemy.Frigate:
                        GameObject creep = Instantiate(frigate, location.transform.position, Quaternion.LookRotation(firstChekpoint.position - location.transform.position));
                        Enemy      enemy = creep.GetComponent <Enemy>();
                        enemy._chekpoint = firstChekpoint;
                        enemy.heatPoint += generator[waveNumber].bonusHeatPoints;
                        break;

                    case EnemyBase.enemy.Fighter:
                        creep            = Instantiate(fighter, location.transform.position, Quaternion.LookRotation(firstChekpoint.position - location.transform.position));
                        enemy            = creep.GetComponent <Enemy>();
                        enemy._chekpoint = firstChekpoint;
                        enemy.heatPoint += generator[waveNumber].bonusHeatPoints;
                        break;

                    case EnemyBase.enemy.Bomber:
                        creep            = Instantiate(bomber, location.transform.position, Quaternion.LookRotation(firstChekpoint.position - location.transform.position));
                        enemy            = creep.GetComponent <Enemy>();
                        enemy._chekpoint = firstChekpoint;
                        enemy.heatPoint += generator[waveNumber].bonusHeatPoints;
                        break;

                    case EnemyBase.enemy.Mothership:
                        creep            = Instantiate(mothership, location.transform.position, Quaternion.LookRotation(firstChekpoint.position - location.transform.position));
                        enemy            = creep.GetComponent <Enemy>();
                        enemy._chekpoint = firstChekpoint;
                        enemy.heatPoint += generator[waveNumber].bonusHeatPoints;
                        break;
                    }
                }
            }
            else
            {
                timer -= Time.deltaTime;
            }
        }

        if (waveOver)
        {
            if (GameObject.FindGameObjectsWithTag("Enemy").Length == 0 && !over)
            {
                over = true;
                overScreen.SetActive(true);
                GameObject.Find("OverText").GetComponent <Text>().text = "Level complete!";
                GameObject.Find("Next").GetComponent <UiEndScreenButton>().NextLevel = true;
                GameObject.Find("NextText").GetComponent <Text>().text = "Next Level";


                DataBaseLevel data = DataWork.LoadLevel();
                if (GameEngine.Engine.Level > data.levelProgress)
                {
                    DataWork.SaveLevel(GameEngine.Engine.Level);
                }
            }
        }
    }