Esempio n. 1
0
 /// <summary>
 /// Projectile ctor, sets the damage, speed, target, and colour
 /// </summary>
 /// <param name="damage">Damage projectile will do</param>
 /// <param name="speed">Speed it travels</param>
 /// <param name="enemy">Target it's aiming at</param>
 /// <param name="color">colour of the projectile</param>
 public Projectile(double damage, double speed, Enemy enemy, string color)
 {
     this.damage = damage;
     this.speed = speed;
     target = enemy;
     Color = color;
 }
Esempio n. 2
0
        /// <summary>
        /// Updates this instance of EnemyWave class
        /// </summary>
        /// <param name="gameTime">current gametime</param>
        public void update(GameTime gameTime)
        {
            // doesn't update if a certian time hasn't passed
            if (gameTime.TotalGameTime - previousUpdateTime > spawnRate)
            {
                Random random = new Random();
                if (waveSize <= 0 && Enemy.enemyList.Count == 0)
                {
                    complete = true;
                    return;
                }

                if (waveSize-- > 0)
                {
                    Enemy e = new Enemy(Map.currentMap);
                    int movementspeed = random.Next(20, 100);
                    e.movetime = TimeSpan.FromMilliseconds(movementspeed);

                    double newhealth = (70 * TDPlayerStats.currentWave) + movementspeed * (Math.Pow(TDPlayerStats.currentWave, 2));
                    e.SetHealth((int)newhealth);

                }

                spawnRate = TimeSpan.FromMilliseconds(random.Next(500, 4000));
                previousUpdateTime = gameTime.TotalGameTime;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// BasicBolt Constructor
 /// Sets the damage, speed, target, and current x/y positions, and colour
 /// </summary>
 /// <param name="damage">Damage the projectile does</param>
 /// <param name="speed">Speed the projectile travels at</param>
 /// <param name="enemy">Target of the projectile</param>
 /// <param name="xpos">Starting X position in pixels</param>
 /// <param name="ypos">starting Y position in pixels</param>
 /// <param name="color">Colour of the projectile</param>
 public BasicBolt(double damage, double speed, Enemy enemy, int xpos, int ypos, string color)
     : base(damage, speed, enemy, color)
 {
     centerX = xpos;
     centerY = ypos;
     projectileSprite = new TDProjectileSprite();
     TowerDefenseManager.TDLayers[2].AddEntity(projectileSprite);
     projectileSprite.Position.Y = centerY ;
     projectileSprite.Position.X = centerX ;
     id = count++;
     alive = true;
 }
Esempio n. 4
0
 /// <summary>
 /// Checks if the target is within range of the tower.
 /// </summary>
 /// <returns>If an enemy is within range it returns the distance
 /// other wise it returns -1</returns>
 public double isWithinRange(Enemy enemy)
 {
     double xdist = xposCenter - (enemy.xpos * 5);
     double ydist = yposCenter - (enemy.ypos * 5);
     double distance = Math.Sqrt(Math.Pow(xdist, 2) + Math.Pow(ydist, 2));
     if (distance <= range)
         return distance;
     return -1;
 }