Beispiel #1
0
        public override void OnTick()
        {
            this.CheckForDisqualification();

            // check for anyone carrying flags
            if (this.HomeBases != null)
            {
                ArrayList dlist = null;

                foreach (CTFBase b in this.HomeBases)
                {
                    if (b == null || b.Deleted)
                    {
                        if (dlist == null)
                        {
                            dlist = new ArrayList();
                        }
                        dlist.Add(b);
                        continue;
                    }

                    if (!b.Deleted && b.Flag != null && !b.Flag.Deleted)
                    {
                        if (b.Flag.RootParent is Mobile)
                        {
                            Mobile m = b.Flag.RootParent as Mobile;

                            // make sure a participant has it
                            IChallengeEntry entry = this.GetParticipant(m);

                            if (entry != null)
                            {
                                // display the flag
                                //m.PublicOverheadMessage( MessageType.Regular, BaseChallengeGame.TeamColor(b.Team), false, b.Team.ToString());
                                Effects.SendTargetParticles(m, 0x375A, 35, 10, BaseChallengeGame.TeamColor(b.Team), 0x00, 9502,
                                                            (EffectLayer)255, 0x100);
                            }
                            else
                            {
                                b.ReturnFlag();
                            }
                        }
                        else if (!b.HasFlag)
                        {
                            b.ReturnFlag();
                        }
                    }
                }

                if (dlist != null)
                {
                    foreach (CTFBase b in dlist)
                    {
                        this.HomeBases.Remove(b);
                    }
                }
            }
        }
Beispiel #2
0
        public void CheckForDeathBall()
        {
            Mobile owner = null;

            if (this.m_DeathBall != null && this.m_DeathBall.RootParent is Mobile)
            {
                owner = this.m_DeathBall.RootParent as Mobile;
            }

            // only score if one player is carrying the ball
            if (owner != null)
            {
                IChallengeEntry entry = this.GetParticipant(owner);

                // dont let players who are in a caution state such as hidden or out of bounds to score
                if (entry != null && entry.Participant != null && entry.Caution == ChallengeStatus.None)
                {
                    // 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
                    TeamDeathballGump.RefreshAllGumps(this, false);

                    // check for win conditions
                    this.CheckForGameEnd();
                }
            }
            else
            {
                // check to see if someone is carrying it
                if (this.Participants != null)
                {
                    foreach (IChallengeEntry entry in this.Participants)
                    {
                        if (entry.Status == ChallengeStatus.Active && entry.Participant != null && entry.Participant.Holding == this.m_DeathBall)
                        {
                            // 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
                            TeamDeathballGump.RefreshAllGumps(this, false);

                            // check for win conditions
                            this.CheckForGameEnd();

                            break;
                        }
                    }
                }
            }
        }
Beispiel #3
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();
                }
            }
        }
        public override void CheckForGameEnd()
        {
            if (this.Participants == null || !this.GameInProgress)
            {
                return;
            }

            ArrayList winner = new ArrayList();

            int             leftstanding = 0;
            IChallengeEntry lastentry    = null;
            int             maxscore     = -99999;

            // has anyone reached the target score
            foreach (IChallengeEntry entry in this.Participants)
            {
                if (entry.Status == ChallengeStatus.Active)
                {
                    if (this.TargetScore > 0 && entry.Score >= this.TargetScore)
                    {
                        winner.Add(entry);
                        entry.Winner = true;
                    }

                    if (entry.Score >= maxscore)
                    {
                        maxscore = entry.Score;
                    }
                    leftstanding++;
                    lastentry = entry;
                }
            }

            // if only one is left then they are the winner
            if (leftstanding == 1 && winner.Count == 0)
            {
                winner.Add(lastentry);
                lastentry.Winner = true;
            }

            if (winner.Count == 0 && this.MatchLength > TimeSpan.Zero && (DateTime.UtcNow >= this.MatchStart + this.MatchLength))
            {
                // find the highest score
                // has anyone reached the target score
                foreach (IChallengeEntry entry in this.Participants)
                {
                    if (entry.Status == ChallengeStatus.Active)
                    {
                        if (entry.Score >= maxscore)
                        {
                            winner.Add(entry);
                            entry.Winner = true;
                        }
                    }
                }
            }

            // and then check to see if this is the Deathmatch
            if (winner.Count > 0)
            {
                // declare the winner(s) and end the game
                foreach (IChallengeEntry entry in winner)
                {
                    if (entry.Participant != null)
                    {
                        XmlPoints.SendText(entry.Participant, 100311, this.ChallengeName); // "You have won {0}"
                        this.GameBroadcast(100312, entry.Participant.Name);                // "The winner is {0}"
                        this.AwardWinnings(entry.Participant, this.TotalPurse / winner.Count);
                    }
                }

                this.EndGame();
                DeathmatchGump.RefreshAllGumps(this, true);
            }
        }