private void BattleEnded(bool writeReport) { if (writeReport) { BattleReport.CompleteBattle(); } AboutToExitBattle(this, Attackers, Defenders); ExitBattle(this, Attackers, Defenders); foreach (var combatObj in Defenders.AllCombatObjects().Where(combatObj => !combatObj.IsDead)) { combatObj.ExitBattle(); } foreach (var combatObj in Attackers.AllCombatObjects().Where(combatObj => !combatObj.IsDead)) { combatObj.ExitBattle(); } foreach (var group in Attackers) { WithdrawAttacker(this, group); } foreach (var group in Defenders) { WithdrawDefender(this, group); } // Delete all groups Attackers.Clear(); Defenders.Clear(); }
public override void Reset() { base.Reset(); if (Flag != null) { Flag.Delete(); Flag = null; } if (Attackers != null) { Attackers.Clear(); } else { Attackers = new Dictionary <PlayerMobile, int>(); } if (Defenders != null) { Defenders.Clear(); } else { Defenders = new Dictionary <PlayerMobile, int>(); } Caps = 0; }
public void Respawn() { LastCombatTime = DateTime.Now.AddSeconds(-999); CurrentHitPoints = MaxHitPoints; CurrentShieldPoints = MaxShieldPoints; SetPosition(Position.Random(Spacemap, 0, 20800, 0, 12800)); Spacemap.AddCharacter(this); Attackers.Clear(); MainAttacker = null; Destroyed = false; }
private void SetAttackAndDefense() { Attackers.Clear(); Defenders.Clear(); List <Actor> units_within_range = FindObjectsOfType <Actor>(). Where(actor => Vector3.Distance(actor.transform.position, transform.position) < influence_zone_radius). ToList(); if (NodeFaction != null) { // attack and defense is determined by who currently claims the node for (int i = 0; i < units_within_range.Count; i++) { Actor actor = units_within_range[i]; if (actor != null) { if (actor.CurrentFaction.IsHostileTo(NodeFaction)) { if (!Attackers.Contains(actor) && actor != null) { Attackers.Add(actor); } } else { if (!Defenders.Contains(actor) && actor != null) { Defenders.Add(actor); } } } } } else { // the attackers are the faction with the most units; everybody else can try to kill them // NOTE: the faction that has the most units for the last boost gains the node (of course, then they have to keep it) var faction_units = units_within_range .GroupBy(unit => unit.CurrentFaction, (faction, factions) => new { Key = faction, Count = factions.Count() }) .OrderByDescending(faction => faction.Count); Attackers.AddRange(units_within_range.Where(unit => unit.CurrentFaction == faction_units.First().Key)); } }