예제 #1
0
 private void ResetPlayingState()
 {
     Utility.tdGameTimer        = TimeSpan.Zero;
     Utility.numberOfLives      = startingLives;
     Utility.totalNumberOfKills = 0;
     Utility.GameDifficulty     = 0;
     difficultyCooldown.Reset();
     previewTower  = null;
     selectedTower = null;
     Utility.board.ResetPaths();
     Utility.TowerList.Clear();
 }
예제 #2
0
        public Minion(float iX, float iY, Utility.MinionType iType)
        {
            Position           = new Vector2(iX, iY);
            inBetween          = 0;
            _distanceTraveled  = 0;
            waypoints          = new List <Waypoint>();
            stackFlamethrowers = new List <FireStack>();
            fireClock          = new CoolDownTimer(1);
            fireClock.Reset();
            type = iType;

            if (type == Utility.MinionType.fast)
            {
                hp     = Utility.fastMinionHP;
                maxHP  = Utility.fastMinionHP;
                speed  = 0.002f;
                radius = 0.2f;
            }
            else if (type == Utility.MinionType.slow)
            {
                hp     = Utility.slowMinionHP;
                maxHP  = Utility.slowMinionHP;
                speed  = 0.0005f;
                radius = 0.4f;
            }
            else if (type == Utility.MinionType.boss)
            {
                hp     = Utility.bossMinionHp;
                maxHP  = Utility.bossMinionHp;
                speed  = 0.0001f;
                radius = 0.6f;
            }
            healthBar = new HealthBar(this);
        }
예제 #3
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();
     }
 }
예제 #4
0
        public Spawner()
        {
            timer1 = new CoolDownTimer(1);
            timer1.Reset();

            timer2 = new CoolDownTimer(5);
            timer2.Reset();
            IsActive = true;
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
        public Board(int iWidth, int iHeight)
        {
            Width  = iWidth;
            Height = iHeight;

            Paths    = new List <Path>();
            OldPaths = new List <Path>();
            tiles    = new Tile[FullWidth, FullHeight];

            bossTimer = new CoolDownTimer(60);
            bossTimer.Reset();

            for (int i = 0; i < FullWidth; i++)
            {
                for (int j = 0; j < FullHeight; j++)
                {
                    tiles[i, j] = new Tile(i, j);
                }
            }
            CacheGridSize();
        }
예제 #7
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();
            }
        }