コード例 #1
0
        public override void CheckForGameEnd()
        {
            if (this.Participants == null || !this.GameInProgress)
            {
                return;
            }

            int    leftstanding = 0;
            Mobile winner       = null;

            foreach (ChallengeEntry entry in this.Participants)
            {
                if (entry.Status == ChallengeStatus.Active)
                {
                    leftstanding++;
                    winner = entry.Participant;
                }
            }

            // and then check to see if this is the last man standing
            if (leftstanding == 1 && winner != null)
            {
                // declare the winner and end the game
                XmlPoints.SendText(winner, 100311, this.ChallengeName);  // "You have won {0}"
                this.Winner = winner;
                this.RefreshSymmetricNoto(winner);
                this.GameBroadcast(100312, winner.Name); // "The winner is {0}"
                this.AwardWinnings(winner, this.TotalPurse);

                this.EndGame();
                LastManStandingGump.RefreshAllGumps(this, true);
            }
            if (leftstanding < 1)
            {
                // declare a tie and keep the fees
                this.GameBroadcast(100313);  // "The match is a draw"

                this.EndGame();
                LastManStandingGump.RefreshAllGumps(this, true);
            }
        }
コード例 #2
0
        public override void OnPlayerKilled(Mobile killer, Mobile killed)
        {
            if (killed == null)
            {
                return;
            }

            /*
             * // move the killed player and their corpse to a location
             * // you have to replace x,y,z with some valid coordinates
             * int x = this.Location.X + 30;
             * int y = this.Location.Y + 30;
             * int z = this.Location.Z;
             * Point3D killedloc = new Point3D(x, y, z);
             *
             * ArrayList petlist = new ArrayList();
             *
             * foreach (Mobile m in killed.GetMobilesInRange(16))
             * {
             * if (m is BaseCreature && ((BaseCreature)m).ControlMaster == killed)
             * {
             * petlist.Add(m);
             * }
             * }
             *
             * // port the pets
             * foreach (Mobile m in petlist)
             * {
             * m.MoveToWorld(killedloc, killed.Map);
             * }
             *
             * // do the actual moving
             * killed.MoveToWorld(killedloc, killed.Map);
             * if (killed.Corpse != null)
             * killed.Corpse.MoveToWorld(killedloc, killed.Map);
             */

            if (this.AutoRes)
            {
                // prepare the autores callback
                Timer.DelayCall(RespawnTime, new TimerStateCallback(XmlPoints.AutoRes_Callback),
                                new object[] { killed, false });
            }

            // find the player in the participants list and set their status to Dead
            if (this.m_Participants != null)
            {
                foreach (ChallengeEntry entry in this.m_Participants)
                {
                    if (entry.Participant == killed && entry.Status != ChallengeStatus.Forfeit)
                    {
                        entry.Status = ChallengeStatus.Dead;
                        // clear up their noto
                        this.RefreshSymmetricNoto(killed);

                        this.GameBroadcast(100314, killed.Name); // "{0} has been killed"
                    }
                }
            }

            LastManStandingGump.RefreshAllGumps(this, true);

            // see if the game is over
            this.CheckForGameEnd();
        }
コード例 #3
0
        public void CheckForDisqualification()
        {
            if (this.Participants == null || !this.GameInProgress)
            {
                return;
            }

            bool statuschange = false;

            foreach (ChallengeEntry entry in this.Participants)
            {
                if (entry.Participant == null || entry.Status == ChallengeStatus.Forfeit || entry.Status == ChallengeStatus.Disqualified)
                {
                    continue;
                }

                bool hadcaution = (entry.Caution != ChallengeStatus.None);

                // and a map check
                if (entry.Participant.Map != this.Map)
                {
                    // check to see if they are offline
                    if (entry.Participant.Map == Map.Internal)
                    {
                        // then give them a little time to return before disqualification
                        if (entry.Caution == ChallengeStatus.Offline)
                        {
                            // were previously out of bounds so check for disqualification
                            // check to see how long they have been out of bounds
                            if (DateTime.UtcNow - entry.LastCaution > MaximumOfflineDuration)
                            {
                                entry.Status = ChallengeStatus.Disqualified;
                                this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                                this.RefreshSymmetricNoto(entry.Participant);
                                statuschange = true;
                            }
                        }
                        else
                        {
                            entry.LastCaution = DateTime.UtcNow;
                            statuschange      = true;
                        }

                        entry.Caution = ChallengeStatus.Offline;
                    }
                    else
                    {
                        // changing to any other map is instant disqualification
                        entry.Status = ChallengeStatus.Disqualified;
                        this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                        this.RefreshSymmetricNoto(entry.Participant);
                        statuschange = true;
                    }
                }
                else if (this.m_ArenaSize > 0 && !Utility.InRange(entry.Participant.Location, this.Location, this.m_ArenaSize) ||
                         (this.IsInChallengeGameRegion && !(Region.Find(entry.Participant.Location, entry.Participant.Map) is ChallengeGameRegion)))
                {
                    if (entry.Caution == ChallengeStatus.OutOfBounds)
                    {
                        // were previously out of bounds so check for disqualification
                        // check to see how long they have been out of bounds
                        if (DateTime.UtcNow - entry.LastCaution > MaximumOutOfBoundsDuration)
                        {
                            entry.Status = ChallengeStatus.Disqualified;
                            this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                            this.RefreshSymmetricNoto(entry.Participant);
                            statuschange = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.UtcNow;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100309, MaximumOutOfBoundsDuration.TotalSeconds);  // "You are out of bounds!  You have {0} seconds to return"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.OutOfBounds;
                }
                else if (entry.Participant.Hidden)
                {
                    if (entry.Caution == ChallengeStatus.Hidden)
                    {
                        // were previously hidden so check for disqualification
                        // check to see how long they have hidden
                        if (DateTime.UtcNow - entry.LastCaution > MaximumHiddenDuration)
                        {
                            entry.Status = ChallengeStatus.Disqualified;
                            this.GameBroadcast(100308, entry.Participant.Name);  // "{0} has been disqualified"
                            this.RefreshSymmetricNoto(entry.Participant);
                            statuschange = true;
                        }
                    }
                    else
                    {
                        entry.LastCaution = DateTime.UtcNow;
                        // inform the player
                        XmlPoints.SendText(entry.Participant, 100310, MaximumHiddenDuration.TotalSeconds); // "You have {0} seconds become unhidden"
                        statuschange = true;
                    }

                    entry.Caution = ChallengeStatus.Hidden;
                }
                else
                {
                    entry.Caution = ChallengeStatus.None;
                }

                if (hadcaution && entry.Caution == ChallengeStatus.None)
                {
                    statuschange = true;
                }
            }

            if (statuschange)
            {
                // update gumps with the new status
                LastManStandingGump.RefreshAllGumps(this, false);
            }

            // it is possible that the game could end like this so check
            this.CheckForGameEnd();
        }