public Projectile(Game game, Vector2 position, Creep target, int damage = Settings.DEFAULT_DAMAGE) { mGame = game; Width = 5; Height = 5; // The position passed in is the center of the tower, we need to recalc the projectiles position so the center is aligned with the center of the tower Position = new Vector2(position.X - Width / 2, position.Y - Height / 2); Target = target; Velocity = 200; Damage = damage; Type = "Basic"; Ready = false; }
public SlowProjectile(Game game, Vector2 position, Creep target) : base(game, position, target, 0) { Type = "Slow"; }
public SniperProjectile(Game game, Vector2 position, Creep target, int damage) : base(game, position, target, damage) { Type = "Sniper"; }
public virtual Boolean fire() { // Fire the tower int leastPathLength = 999; Creep targetCreep = null; if (StaticTarget != null) { if (StaticTarget.Alive) targetCreep = StaticTarget; else StaticTarget = null; } if (targetCreep == null) { lock (mOpponent.Creeps) { foreach (Creep creep in mOpponent.Creeps) { if (!creep.Active) continue; float d = creep.getDistance(this); if (d < EffectedRange) { if (creep.CurrentPath.Count < leastPathLength && !creep.isDeathWaiting()) { leastPathLength = creep.CurrentPath.Count; targetCreep = creep; } } } } } if (targetCreep != null) { lock (mGame.Projectiles) { if(this is RapidFireTower) mGame.Projectiles.Add(new RapidFireProjectile(mGame, new Vector2(Center), targetCreep, EffectedDamage)); else if (this is SniperTower) mGame.Projectiles.Add(new SniperProjectile(mGame, new Vector2(Center), targetCreep, EffectedDamage)); else if (this is SpellTower) mGame.Projectiles.Add(new SpellProjectile(mGame, new Vector2(Center), targetCreep, EffectedDamage)); else mGame.Projectiles.Add(new Projectile(mGame, new Vector2(Center), targetCreep, EffectedDamage)); } return true; } return false; }
public void debugCreep(Creep cr) { Console.WriteLine("--- CREEP --- (" + Number + ")"); Console.WriteLine("Type: " + cr.Type); Console.WriteLine("Life: " + cr.Life); Console.WriteLine("Armor: " + cr.Armor); Console.WriteLine("Worth: " + cr.Worth); }
public void addCreep(Creep creep) { switch (creep.Type) { case "Armor": if (Points >= ArmorCreep.DEFAULT_POINTS) { Points -= ArmorCreep.DEFAULT_POINTS; SpawnQueue.Enqueue(creep); if (!CreepTypes.Contains(creep.Type)) CreepTypes.Add(creep.Type); } break; case "Chigen": if (Points >= ChigenCreep.DEFAULT_POINTS) { Points -= ChigenCreep.DEFAULT_POINTS; SpawnQueue.Enqueue(creep); if (!CreepTypes.Contains(creep.Type)) CreepTypes.Add(creep.Type); } break; case "Magic": if (Points >= MagicCreep.DEFAULT_POINTS) { Points -= MagicCreep.DEFAULT_POINTS; SpawnQueue.Enqueue(creep); if (!CreepTypes.Contains(creep.Type)) CreepTypes.Add(creep.Type); } break; case "Quick": if (Points >= QuickCreep.DEFAULT_POINTS) { Points -= QuickCreep.DEFAULT_POINTS; SpawnQueue.Enqueue(creep); if (!CreepTypes.Contains(creep.Type)) CreepTypes.Add(creep.Type); } break; case "Regen": if (Points >= RegenCreep.DEFAULT_POINTS) { Points -= RegenCreep.DEFAULT_POINTS; SpawnQueue.Enqueue(creep); if (!CreepTypes.Contains(creep.Type)) CreepTypes.Add(creep.Type); } break; case "Swarm": if (Points >= SwarmCreep.DEFAULT_POINTS) { Points -= SwarmCreep.DEFAULT_POINTS; // Queue three for each point SpawnQueue.Enqueue(creep); SpawnQueue.Enqueue(new SwarmCreep(mPlayer, mOpponent, StartingPosition, getCurrentPath())); SpawnQueue.Enqueue(new SwarmCreep(mPlayer, mOpponent, StartingPosition, getCurrentPath())); if (!CreepTypes.Contains(creep.Type)) CreepTypes.Add(creep.Type); } break; } }
public RapidFireProjectile(Game game, Vector2 position, Creep target, int damage) : base(game, position, target, damage) { Type = "RapidFire"; }