示例#1
0
        public void ClearArena()
        {
            if (ArenaSize <= 0)
            {
                return;
            }

            ArrayList mlist = new ArrayList();

            IPooledEnumerable eable = this.GetMobilesInRange(ArenaSize);

            // who is currently within the arena
            foreach (Mobile p in eable)
            {
                if (p == null)
                {
                    continue;
                }

                IChallengeEntry entry = GetParticipant(p);

                // if this is not a current participant then move them
                if (entry == null)
                {
                    // prepare to move them off
                    mlist.Add(p);
                }
            }

            eable.Free();

            // move non-participants
            foreach (Mobile p in mlist)
            {
                for (int i = 0; i < 10; i++)
                {
                    int     x      = Location.X + (ArenaSize + i) * (Utility.RandomBool() ? 1 : -1);
                    int     y      = Location.Y + (ArenaSize + i) * (Utility.RandomBool() ? 1 : -1);
                    int     z      = Map.GetAverageZ(x, y);
                    Point3D newloc = new Point3D(x, y, z);

                    if (XmlSpawner.IsValidMapLocation(newloc, p.Map))
                    {
                        p.MoveToWorld(newloc, p.Map);
                    }
                }
            }
        }
        public void CheckForKingOfTheHill()
        {
            ArrayList mlist = new ArrayList();
            ArrayList elist = new ArrayList();

            // who is currently on the hill
            foreach (Mobile p in this.GetMobilesInRange(0))
            {
                if (p == null)
                {
                    continue;
                }

                IChallengeEntry entry = GetParticipant(p);

                // if this is not a current participant then move them
                if (entry == null)
                {
                    // prepare to move them off
                    mlist.Add(p);
                }
                else
                // dont let players who are in a caution state such as hidden to score
                if (entry.Caution == ChallengeStatus.None)
                {
                    // prepare to bump their score
                    elist.Add(entry);
                }
            }

            // move non-participants
            foreach (Mobile p in mlist)
            {
                for (int i = 10; i < 20; i++)
                {
                    int     x      = p.Location.X + i * (Utility.RandomBool() ? 1 : -1);
                    int     y      = p.Location.Y + i * (Utility.RandomBool() ? 1 : -1);
                    int     z      = Map.GetAverageZ(x, y);
                    Point3D newloc = new Point3D(x, y, z);

                    if (XmlSpawner.IsValidMapLocation(newloc, p.Map))
                    {
                        p.MoveToWorld(newloc, p.Map);
                    }
                }
            }

            // only score if one player is alone on the hill
            if (elist.Count == 1)
            {
                IChallengeEntry entry = (IChallengeEntry)elist[0];

                if (entry != null && entry.Participant != null)
                {
                    // bump their score
                    entry.Score++;

                    // display the score
                    entry.Participant.PublicOverheadMessage(MessageType.Regular, 0, true, entry.Score.ToString());

                    // update all the gumps if you like
                    TeamKotHGump.RefreshAllGumps(this, false);

                    // check for win conditions
                    CheckForGameEnd();
                }
            }
        }