Ejemplo n.º 1
0
        private WaveDetails genNextWave()
        {
            var nextWaveDetails = new WaveDetails(currentWaveDetails.buildTime, null, 0, Mathf.Max(currentWaveDetails.spawnDelay - 0.05f, 0.25f), currentWaveDetails.waveNr + 1, currentWaveDetails.waveScore + Mathf.Pow(4, (currentWaveDetails.waveNr + 1) / 5f));

            //Todo balancing
            nextWaveGenerated = true;
            return(nextWaveDetails);
        }
Ejemplo n.º 2
0
 void OnEnable()
 {
     currentWaveDetails = GameController.CurrentWaveDetails;
     if (currentWaveDetails.waveNr == 0)
     {
         UIController.Instance.tutorialInProgress = true;
         UIController.Instance.GetComponent <Tutorial>().tutorialObj.SetActive(true);
     }
     buildTime = currentWaveDetails.buildTime;
     buildAcc  = 0f;
 }
Ejemplo n.º 3
0
 public void startWave(WaveDetails waveDetails)
 {
     if (UIController.Instance.researchScreen.activeSelf)
     {
         UIController.Instance.researchScreen.SetActive(false);
     }
     started          = true;
     currentWaveScore = 0f;
     waveNr           = waveDetails.waveNr;
     maxScore         = waveDetails.waveScore;
     foreach (var spawn in spawns)
     {
         spawn.setUp(waveDetails);
     }
 }
Ejemplo n.º 4
0
        void Update()
        {
            waveOver = isWaveEnded();
            if (waveOver)
            {
                if (!nextWaveGenerated)
                {
                    currentWaveDetails = genNextWave();

                    float wavexp = 10 * currentWaveDetails.waveNr;
                    foreach (Trait trait in GameController.instance.getAllTraits())
                    {
                        if (trait.isToggled)
                        {
                            wavexp *= trait.xpmodifier;
                        }
                    }
                    GameController.instance.addXP(wavexp);

                    saveWave(wavexp);
                    GameController.instance.saveData();
                }

                if (buildAcc >= buildTime)
                {
                    spawnController.startWave(currentWaveDetails);
                    nextWaveGenerated = false;
                    waveCheck         = true;
                }
                else
                {
                    if (!UIController.Instance.tutorialInProgress)
                    {
                        buildAcc += Time.deltaTime;
                    }
                    UIController.Instance.showCountdown();
                    UIController.Instance.updateCountdown(buildTime - buildAcc);
                }
            }
            else
            {
                UIController.Instance.hideCountdown();
                buildTime = currentWaveDetails.buildTime;
                buildAcc  = 0f;
            }

            // Todo this doesn't belong to this class
            // TODO fix this, currently it adds 10-20xp at the beginning of the first wave.
            // Todo still doesn't belong here
            // Todo no good here
            // Todo need balancing
            if (waveOver && waveCheck)
            {
//                float wavexp = 100;
//                foreach (Trait trait in GameController.instance.getAllTraits()) {
//                    if (trait.isToggled)
//                        wavexp *= trait.xpmodifier;
//                }
//                GameController.instance.addXP(wavexp);
//                waveCheck = false;
            }
        }