コード例 #1
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (!m_Flag.Game.Running)
                {
                    from.SendMessage("You cannot pass or capture after the game end.");
                    return;
                }

                CTFTeam fteam = m_Flag.Game.GetTeam(from);

                if (target is Mobile)
                {
                    Mobile  targ  = (Mobile)target;
                    CTFTeam tteam = m_Flag.Game.GetTeam(targ);
                    if (targ.Alive && tteam == fteam && from != targ)
                    {
                        if (targ.Backpack != null)
                        {
                            m_Flag.RandomizeItemID();
                            targ.Backpack.DropItem(m_Flag);
                            targ.SendMessage("{0} gave you the {1} flag!", from.Name, m_Flag.Team.Name);
                            m_Flag.Game.PlayerMessage("{0} passed the {1} flag to {2}!", from.Name, m_Flag.Team.Name, targ.Name);
                        }
                    }
                    else
                    {
                        from.SendMessage("You cannot give the flag to them!");
                    }
                }
                else if (target is CTFFlag)
                {
                    CTFFlag flag = target as CTFFlag;
                    if (flag.Team == fteam)
                    {
                        if (flag.Home)
                        {
                            CTFScoreBoard.Captured(from);
                            if (m_Flag.Game != null && m_Flag.Game.IsLeagueGame)
                            {
                                CTFLScoreBoard.Captured(from);
                            }
                            from.SendMessage("You captured the {0} flag!", m_Flag.Team.Name);
                            flag.Game.PlayerMessage("{0} ({1}) captured the {2} flag!", from.Name, fteam.Name, m_Flag.Team.Name);
                            m_Flag.ReturnToHome();
                            fteam.Points += 15;
                        }
                        else
                        {
                            from.SendMessage("Your flag must be at home to capture!");
                        }
                    }
                    else
                    {
                        from.SendMessage("You can only capture for your own team!");
                    }
                }
            }
コード例 #2
0
        public override void OnDoubleClick(Mobile from)
        {
            UpdateTeam();
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                if (m_Game == null || m_Team == null)
                {
                    from.SendGump(new PropertiesGump(from, this));
                }
                else
                {
                    from.SendGump(new PropertiesGump(from, m_Team));
                }
            }
            else if (m_Team != null && m_Game != null)
            {
                if (!m_Game.Running)
                {
                    from.SendMessage("The game is currently closed.");
                    return;
                }

                CTFTeam team = m_Game.GetTeam(from);
                if (team != null)
                {
                    if (!from.InLOS(this.GetWorldLocation()))
                    {
                        from.SendLocalizedMessage(502800);                           // You can't see that.
                        return;
                    }
                    else if (from.GetDistanceToSqrt(this.GetWorldLocation()) > 2)
                    {
                        from.SendLocalizedMessage(500446);                           // That is too far away.
                        return;
                    }

                    if (RootParent is Mobile)
                    {
                        if (RootParent == from)
                        {
                            from.Target = new CaptureTarget(this);
                            from.SendMessage("Target your flag to capture, or target a team-mate to pass the flag.");                              //"What do you wish to do with the flag?" );
                        }
                    }
                    else
                    {
                        if (team != m_Team)
                        {
                            if (from.Backpack != null)
                            {
                                from.RevealingAction();
                                from.Backpack.DropItem(this);
                                from.SendMessage("You got the enemy flag!");
                                BeginCapture();
                                m_Game.PlayerMessage("{0} ({1}) got the {2} flag!", from.Name, team.Name, m_Team.Name);
                            }
                            else
                            {
                                from.SendMessage("You have no backpack to carry that flag!");
                            }
                        }
                        else
                        {
                            if (!m_Home)
                            {
                                CTFScoreBoard.Returned(from);
                                if (m_Game.IsLeagueGame)
                                {
                                    CTFLScoreBoard.Returned(from);
                                }
                                m_Game.PlayerMessage("{0} has returned the {1} flag!", from.Name, m_Team.Name);
                                ReturnToHome();
                            }
                        }
                    }
                }
                else
                {
                    from.SendMessage("You are not part of the game.");
                }
            }
        }