public void AddEnemy(Vector2 enemyPosition) { if (!Enemies.Contains(enemyPosition)) { Enemies.Add(enemyPosition); } }
public void AddPartyEnemy(CreatureObject PartyEnemy) { if (PartyEnemy == null) { throw new ApplicationException("Trying to add party enemy, but that creature does not exist."); } if (!Enemies.Contains(PartyEnemy)) { Enemies.Add(PartyEnemy); } if (CanPartySee(PartyEnemy)) { int EnemyArmorRank = PartyEnemy.Script.GetArmorRank(PartyEnemy.Script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CARMOUR, PartyEnemy.ObjectId)); if ((EnemyArmorRank == CLRScriptBase.ARMOR_RANK_HEAVY || EnemyArmorRank == CLRScriptBase.ARMOR_RANK_MEDIUM) && !EnemyHardTargets.Contains(PartyEnemy)) { EnemyHardTargets.Add(PartyEnemy); } if (EnemyArmorRank == CLRScriptBase.ARMOR_RANK_LIGHT || EnemyArmorRank == CLRScriptBase.ARMOR_RANK_NONE) { EnemySoftTargets.Add(PartyEnemy); } if (_LooksLikeSpellcaster(PartyEnemy)) { EnemySpellcasters.Add(PartyEnemy); } } else { EnemiesLost.Add(PartyEnemy); } }
public void RemovePartyEnemy(CreatureObject PartyEnemy) { if (Enemies.Contains(PartyEnemy)) { Enemies.Remove(PartyEnemy); } if (EnemyHardTargets.Contains(PartyEnemy)) { EnemyHardTargets.Remove(PartyEnemy); } if (EnemySoftTargets.Contains(PartyEnemy)) { EnemySoftTargets.Remove(PartyEnemy); } if (EnemySpellcasters.Contains(PartyEnemy)) { EnemySpellcasters.Remove(PartyEnemy); } if (EnemyHealers.Contains(PartyEnemy)) { EnemyHealers.Remove(PartyEnemy); } }
/// <summary> /// Add a new enemy to the active enemies.</summary> /// <param name="enemy">The Enemy</param> /// <param name="index">The targeted index in the list.</param> public void AddEnemy(IFighter enemy, int index = 0) { if (!Enemies.Contains(enemy)) { Enemies.Insert(index, enemy); EmitOnEnemyEnteredAltertnessRange(); } }
public void AddEnemy(Guild g) { if (!Enemies.Contains(g)) { Enemies.Add(g); g.AddEnemy(this); } }
public void RemoveEnemy(Guild g) { if (Enemies != null && Enemies.Contains(g)) { Enemies.Remove(g); g.RemoveEnemy(this); } }
/// <summary> /// Remove the Enemy from the active enemies of this Character.</summary> /// <param name="enemy"></param> public void RemoveEnemy(IFighter enemy) { if (Enemies.Contains(enemy)) { Enemies.Remove(enemy); EmitOnEnemyLeftAltertnessRange(); } if (EnemiesInAttackRange.Contains(enemy)) { EnemiesInAttackRange.Remove(enemy); } }
public void RemoveEnemy(PoliticalGroup other) { if (!Enemies.Contains(other)) { return; } Enemies.Remove(other); EnemiesRev.Remove(other); other.RemoveEnemy(this); }
public void AddEnemy(PoliticalGroup other) { if (Enemies.Contains(other)) { return; } Enemies.Add(other); EnemiesRev.Add(other); other.AddEnemy(this); }
protected override void RunIteration(long elapsed, bool isLast) { if (DURATION > PAUSE && !HasRemoved) { foreach (Enemy enemy in Enemies) { int index = Battle.EnemyList.IndexOf(enemy); Battle.EnemyList.RemoveAt(index); Battle.DeadEnemies.Add(enemy); Battle.EventQueue.PruneEvents(x => Enemies.Contains(x.Source), "source removed from battle"); } HasRemoved = true; } }
public bool IsWar(Guild g) { if (g == null) { return(false); } Guild guild = GetAllianceLeader(this); Guild otherGuild = GetAllianceLeader(g); if (guild.FindActiveWar(otherGuild) != null) { return(true); } return(Enemies.Contains(g)); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Enemy") { EnemyUnit enemy = other.GetComponent <EnemyUnit>( ); if (enemy == null) { return; } if (!Enemies.Contains(enemy)) { Enemies.Add(enemy); } StartCoroutine("AttackWithDelay"); } }
private void OnTriggerExit2D(Collider2D other) { if (other.tag == "Enemy") { EnemyUnit enemy = other.GetComponent <EnemyUnit>( ); if (enemy == null) { return; } if (Enemies.Contains(enemy)) { Enemies.Remove(enemy); } if (Enemies.Count <= 0) { StopCoroutine("AttackWithDelay"); StopAttackAnim( ); } } }
// Display the current map public override string ToString() { string s = ""; for (int y = 0; y < Rows; y++) { for (int x = 0; x < Cols; x++) { Coordinates pos = new Coordinates(x, y); char c = '_'; if (MyAnts.ContainsKey(pos)) { c = 'a'; } else if (Walls.Contains(pos)) { c = '#'; } else if (Enemies.Contains(pos)) { c = 'e'; } else if (Food.Contains(pos)) { c = '.'; } else if (Hills.Contains(pos)) { c = '*'; } s += c; } s += "\n"; } return(s); }
public void Update(GameTime gameTime) { foreach (Bullet b in Bullets.ToArray()) { b.Update(gameTime); if (b.Bounds.Intersects(Parent.Player.Bounds)) { Parent.Health.Value--; AssetManager.PlaySound("Hit", 1f); Parent.GFM.SpawnMiniExplosion(b); Bullets.Remove(b); } else if (b.ShouldRemove) { Parent.GFM.SpawnMiniExplosion(b); Bullets.Remove(b); } } CurrentTime += gameTime.ElapsedGameTime.TotalSeconds; if (CurrentTime >= SpawnInterval) { CurrentTime = 0; for (int i = 0; i < Rand.Next(5); i++) { //Spawn at top of screen, choose random enemy int R = Rand.Next(4); if (R == 1) { Enemies.Add(new ShooterEnemy(new Rectangle(Rand.Next(64, 64 + 192 - 9), Rand.Next(-32, 0), 7, 14), this)); } else if (R == 2) { Enemies.Add(new FighterEnemy(new Rectangle(Rand.Next(64, 64 + 192 - 9), Rand.Next(-32, 0), 9, 13), this)); } else if (R == 3) { Enemies.Add(new FollowEnemy(new Rectangle(Rand.Next(64, 64 + 192 - 9), Rand.Next(-32, 0), 9, 9), this)); } else { Enemies.Add(new SpikeEnemy(new Rectangle(Rand.Next(64, 64 + 192 - 9), Rand.Next(-32, 0), 13, 13), this)); } } } ToRemove.Clear(); foreach (IEnemy E in Enemies) { E.Update(gameTime); if (E.Bounds.Intersects(Parent.Player.Bounds)) { ToRemove.Add(E); Parent.Health.Value--; } foreach (Bullet B in Parent.Player.Bullets.ToArray()) { if (B.Bounds.Intersects(E.Bounds)) { E.Health--; Parent.GFM.SpawnMiniExplosion(E); if (E.Health <= 0) { Parent.Score.Value++; ToRemove.Add(E); } else { AssetManager.PlaySound("Hit"); } Parent.Player.Bullets.Remove(B); } } } foreach (IEnemy E in ToRemove) { if (Enemies.Contains(E)) { Parent.GFM.SpawnExplosion(E); Parent.Camera.ScreenShake(20, 0.075f); Enemies.Remove(E); } } }
public ImmutableArray <Character> GetTeammates(ItemResolver <Character> c) { return(Enemies.Contains(c.Item) ? Enemies : Party); }
public ImmutableArray <Character> GetOpponents(ItemResolver <Character> c) { return(Enemies.Contains(c.Item) ? Party : Enemies); }
public ImmutableArray <Character> GetTeammates(Character c) { return(Enemies.Contains(c) ? Enemies : Party); }
public ImmutableArray <Character> GetOpponents(Character c) { return(Enemies.Contains(c) ? Party : Enemies); }
public virtual void Damage(double dmg, Character attacker = null, int sound = 0, DamageType damageType = DamageType.RawDamage, DamageFlags flags = DamageFlags.None) { if (LifeStatus != LifeStatus.Alive) { return; } RemoveStatus("Morph"); var realDamage = dmg; if ((flags & DamageFlags.CanBeAbsorbed) == DamageFlags.CanBeAbsorbed) { if (AbsorbingAbsoluteDamage) { CurrentAbsoluteDamageAbsorbed += dmg; if (MaximumAbsoluteDamageAbsorbed <= CurrentAbsoluteDamageAbsorbed) { RemoveStatus("AbsoluteAbsorb"); } realDamage = 0; SpellAnimation(AbsoluteAbsorbAnimation, 100); } else if (AbsorbingPhysicalDamage && damageType == DamageType.Physical) { CurrentPhysicalDamageAbsorbed += dmg; if (MaximumPhysicalDamageAbsorbed <= CurrentPhysicalDamageAbsorbed) { RemoveStatus("PhysicalAbsorb"); } realDamage = 0; SpellAnimation(PhysicalAbsorbAnimation, 100); } else if (AbsorbingMagicalDamage && damageType == DamageType.Magical) { CurrentMagicalDamageAbsorbed += dmg; if (MaximumMagicalDamageAbsorbed <= CurrentMagicalDamageAbsorbed) { RemoveStatus("MagicalAbsorb"); } realDamage = 0; SpellAnimation(MagicalAbsorbAnimation, 100); } } if (damageType == DamageType.Physical) { realDamage *= ArmorProtection * (1d - PhysicalProtection); } else if (damageType == DamageType.Magical) { realDamage -= (realDamage * (MagicResistance / 100d)); realDamage *= (1d - MagicalProtection); } if (Map.Flags.HasFlag(MapFlags.PlayerKill)) { dmg *= 0.75; } if (attacker != null) { if (!Enemies.Contains(attacker)) { Enemies.Add(attacker); } if (!attacker.Enemies.Contains(this)) { attacker.Enemies.Add(this); } LastAttacker = attacker; } if ((flags & DamageFlags.CanBeRedirected) == DamageFlags.CanBeRedirected) { if (RedirectingPhysicalDamage && damageType == DamageType.Physical) { if (PhysicalRedirectTarget != null && PhysicalRedirectTarget != this && WithinRange(PhysicalRedirectTarget, 12)) { var yourDamage = realDamage * PhysicalRedirectPercent; realDamage -= yourDamage; PhysicalRedirectTarget.Damage(yourDamage, null, 0, DamageType.RawDamage, DamageFlags.None); } if (--PhysicalRedirectCount == 0) { RemoveStatus("PhysicalRedirect"); } } if (RedirectingMagicalDamage && damageType == DamageType.Magical) { if (MagicalRedirectTarget != null && MagicalRedirectTarget != this && WithinRange(MagicalRedirectTarget, 12)) { var yourDamage = realDamage * MagicalRedirectPercent; realDamage -= yourDamage; MagicalRedirectTarget.Damage(yourDamage, null, 0, DamageType.RawDamage, DamageFlags.None); } if (--MagicalRedirectCount == 0) { RemoveStatus("MagicalRedirect"); } } } if ((flags & DamageFlags.CanBeConvertedToManaDamage) == DamageFlags.CanBeConvertedToManaDamage) { if (ConvertingPhysicalDamageToManaDamage && damageType == DamageType.Physical) { CurrentMP -= (long)realDamage; if (CurrentMP < 0) { CurrentMP = 0; } CurrentPhysicalDamageConvertedToManaDamage += dmg; if (MaximumPhysicalDamageConvertedToManaDamage <= CurrentPhysicalDamageConvertedToManaDamage) { RemoveStatus("PhysicalConvertToMana"); } realDamage = 0; SpellAnimation(PhysicalConvertToManaAnimation, 100); } if (ConvertingMagicalDamageToManaDamage && damageType == DamageType.Magical) { CurrentMP -= (long)realDamage; if (CurrentMP < 0) { CurrentMP = 0; } CurrentMagicalDamageConvertedToManaDamage += dmg; if (MaximumMagicalDamageConvertedToManaDamage <= CurrentPhysicalDamageConvertedToManaDamage) { RemoveStatus("MagicalConvertToMana"); } realDamage = 0; SpellAnimation(MagicalConvertToManaAnimation, 100); } } CurrentHP -= (long)realDamage; if (CurrentHP < 0) { CurrentHP = 0; } if (attacker != null) { if (Attackers.ContainsKey(attacker)) { Attackers[attacker] += realDamage; } else { Attackers.Add(attacker, realDamage); } } double percent = Math.Floor((double)CurrentHP / (double)MaximumHP * 100.0); if (percent < 0) { percent = 0; } if (percent > 100) { percent = 100; } var dot = (flags & DamageFlags.DamageOverTime) == DamageFlags.DamageOverTime; var id = (attacker != null) ? attacker.ID : ID; foreach (Character c in Map.Objects) { if (WithinRange(c, 12) && (c is Player)) { var packet = new ServerPacket(0x13); packet.WriteUInt32(id); packet.WriteUInt32(ID); packet.WriteByte(dot); packet.WriteByte((byte)percent); packet.WriteUInt32((uint)realDamage); packet.WriteByte((byte)sound); (c as Player).Client.Enqueue(packet); } } }
public void ComputeMoves(GameActionsMessage msg) { // Next ants positions Dictionary <Coordinates, Ant> updated = new Dictionary <Coordinates, Ant>(); Random rand = new Random(); foreach (KeyValuePair <Coordinates, Ant> pair in MyAnts) { Ant ant = pair.Value; Coordinates pos = pair.Key; AntDirection move; Coordinates next; if (ant.HasFood) { if (ant.History.Count > 0 && !Hills.Contains(pos)) { // Walk back move = ant.History.Pop().Reverse(); next = pos.ApplyDirection(move).Normalize(this); // If the path is blocked, don't move (and put the move back on the history for next round) if (!Enemies.Contains(next) && !updated.ContainsKey(next)) { msg.AddMove(pos.Col, pos.Row, move.ToString()); updated.Add(next, ant); } else { ant.History.Push(move.Reverse()); } continue; } else { ant.HasFood = false; } } move = GetNearbyFood(pos); // If there is accessible food, go there if (move == AntDirection.U) { List <AntDirection> remaining = new List <AntDirection>() { AntDirection.N, AntDirection.S, AntDirection.E, AntDirection.W }; int index; // First move to try : continue the same way or not ? 50% chance if (ant.History.Count > 0 && rand.NextDouble() < 0.5) { move = ant.History.Peek(); remaining.Remove(move); } else { index = rand.Next(4); move = remaining[index]; remaining.RemoveAt(index); } int size = remaining.Count; do { Coordinates result = pos.ApplyDirection(move).Normalize(this); if (!Walls.Contains(result) && !MyAnts.ContainsKey(result) && !updated.ContainsKey(result)) { break; } if (size > 0) { index = rand.Next(size); move = remaining[index]; remaining.RemoveAt(index); } else { move = AntDirection.U; } size--; } while (size >= 0); } else { ant.HasFood = true; } next = pos.ApplyDirection(move).Normalize(this); if (move != AntDirection.U && !updated.ContainsKey(next)) { ant.History.Push(move); msg.AddMove(pos.Col, pos.Row, move.ToString()); updated.Add(next, ant); } } MyAnts = updated; }