示例#1
0
文件: Team.cs 项目: LordEnigma/UO
        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;
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="win"></param>
        public override void EndFight(bool win = false)
        {
            base.EndFight(win);

            if (win)
            {
                Guild.AddMessage(() =>
                {
                    if (Guild.IsDeleted)
                    {
                        return;
                    }
                    StartAction(GameActionTypeEnum.MAP);
                    Guild.Dispatch(WorldMessage.GUILD_TAXCOLLECTOR_SURVIVED(Name, Map.X, Map.Y));
                });
            }
            else
            {
                Guild.AddMessage(() =>
                {
                    if (Guild.IsDeleted)
                    {
                        return;
                    }
                    Guild.RemoveTaxCollector(this);
                    Guild.Dispatch(WorldMessage.GUILD_TAXCOLLECTOR_DIED(Name, Map.X, Map.Y));
                });
            }

            Defenders.Clear();
        }
示例#3
0
        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();
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        public override void Dispose()
        {
            Guild = null;

            Defenders.Clear();
            Defenders = null;

            base.Dispose();
        }
示例#5
0
    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));
        }
    }