Ejemplo n.º 1
0
        public void Update(GameTime time)
        {
            List <int> towersDone = new List <int>();

            for (int i = 0; i < chunks.Count; i++)
            {
                chunks[i].Update(time);
                if (chunks[i].TowerDone)
                {
                    towersDone.Add(i);
                }
            }
            for (int j = towersDone.Count - 1; j >= 0; j--)
            {
                chunks.RemoveAt(towersDone[j]);
            }
            for (int k = 0; k < towersDone.Count; k++)
            {
                int newHeight = lastHeight + (Rand.Next(-1, 2));
                if (newHeight > maxHeight)
                {
                    newHeight = maxHeight;
                }
                if (newHeight <= minHeight)
                {
                    newHeight = minHeight;
                }
                int        x    = (int)CurrentTerrain.Last().CurrentX + groundWidth;
                BlockChunk next = CurrentTerrain.Construct(x);
                next.Generate();
                chunks.Add(next);
                lastHeight = newHeight;
                TowersCreated++;
            }
        }