Example #1
0
 public void Update(GameTime gameTime)
 {
     bossTimer.Update(gameTime);
     CacheGridSize();
     for (int i = Paths.Count - 1; i >= 0; i--)
     {
         Paths[i].Update(gameTime);
         if (Paths[i].Sequence == Path.Animation.despawn)
         {
             OldPaths.Add(Paths[i]);
             Paths.RemoveAt(i);
         }
     }
     for (int i = OldPaths.Count - 1; i >= 0; i--)
     {
         OldPaths[i].Update(gameTime);
         if (OldPaths[i].Done)
         {
             OldPaths.RemoveAt(i);
         }
     }
     if (Paths.Count < Utility.GameDifficulty / 4 + 1)
     {
         GeneratePath();
     }
     if (bossTimer.IsExpired)
     {
         Paths[0].AddMinion(new Minion(0, 0, Utility.MinionType.boss));
         bossTimer.Reset();
     }
 }
        private void UpdatePlayingState(GameTime gameTime)
        {
            Utility.tdGameTimer += gameTime.ElapsedGameTime;

            difficultyCooldown.Update(gameTime);
            if (difficultyCooldown.IsExpired)
            {
                difficultyCooldown.Reset();
                Utility.GameDifficulty++;
            }

            Utility.board.Update(gameTime);
            HoveringOverTowerChecker();
            TowerMovementChecker();
            TowerHotkeyHandler();
            TowerSwitchInput();
            sidebarUI.Update(gameTime);
            input.Update();
            if (input.MouseRightButtonPressed && IsWithinDimensions())
            {
                if (Utility.MaxTowers > Utility.TowerList.Count)
                {
                    AddTower(input.MouseToGameGrid().X, input.MouseToGameGrid().Y, Utility.TowerType.FlameThrower, Utility.TowerList.Count + 1);
                }
            }
            for (int i = Utility.TowerList.Count - 1; i >= 0; i--)
            {
                Tile currenttile = Utility.board.GetTile(new Point(Utility.TowerList[i].X, Utility.TowerList[i].Y));
                if (Utility.board.IsTileOnPath(currenttile))
                {
                    Utility.TowerList[i].IsDisabled = true;
                }
                else
                {
                    Utility.TowerList[i].IsDisabled = false;
                }
                Utility.TowerList[i].Update(gameTime);
            }

            /*
             * if (input.MouseLeftButtonPressed)
             * {
             *  if (Utility.board.Paths.Count > 0)
             *  {
             *      Minion m = new Minion(0, 0, Utility.MinionType.fast);
             *      Utility.board.Paths[0].AddMinion(m);
             *  }
             * }
             */
        }
        public void Update(GameTime gameTime, Path p)
        {
            timer1.Update(gameTime);
            timer2.Update(gameTime);

            if (timer1.IsExpired && IsActive)
            {
                p.AddMinion(new Minion(0, 0, Utility.MinionType.fast));
                timer1.Reset();
            }
            if (timer2.IsExpired && IsActive)
            {
                p.AddMinion(new Minion(0, 0, Utility.MinionType.slow));
                timer2.Reset();
            }
        }
Example #4
0
        public void Update(GameTime gameTime)
        {
            _distanceTraveled += speed + (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            inBetween         += speed * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            while (waypoints.Count() > 0 && inBetween >= waypoints.First().distance)
            {
                inBetween -= waypoints[0].distance;
                waypoints.RemoveAt(0);
            }
            if (waypoints.Count > 0)
            {
                inBetween = Math.Min(waypoints[0].distance, inBetween);
                Position  = Vector2.Lerp(waypoints[0].start, waypoints[0].target, inBetween / waypoints[0].distance);
            }
            else
            {
                inBetween = 0;
            }
            fireClock.Update(gameTime);

            for (int i = stackFlamethrowers.Count - 1; i >= 0; i--)
            {
                stackFlamethrowers[i].fireTimer.Update(gameTime);
                if (stackFlamethrowers[i].fireTimer.IsExpired)
                {
                    stackFlamethrowers.RemoveAt(i);
                }
            }

            if (fireClock.IsExpired)
            {
                foreach (FireStack fs in stackFlamethrowers)
                {
                    TakeDamage(fs.flameThrower.Damage);
                }
                fireClock.Reset();
            }
        }