コード例 #1
0
        void Winner(Team team)
        {
            gameEnding = true;
            foreach (var member in CTFPlayers)
            {
                if (member.hasFlag)
                {
                    CTFFlag flag = member.team == Team.A ? FlagB : FlagA;

                    flag.DropFlag(member.transform.position);
                    member.player.SendNetworkUpdate();
                    member.hasFlag = false;
                }
                if (member.team == team)
                {
                    EventManager.AddTokens(member.player.userID, configData.EventSettings.TokensOnWin, true);
                }
            }
            if (team == Team.NONE)
            {
                EventManager.BroadcastToChat(msg("draw"));
            }
            else
            {
                EventManager.BroadcastToChat(string.Format(msg("winner"), GetTeamName(team)));
            }
            timer.In(2, () =>
            {
                EventManager.CloseEvent();
                EventManager.EndEvent();
            });
        }
コード例 #2
0
        void AddFlag(Team team)
        {
            string spawnFile = team == Team.A ? TeamASpawns : TeamBSpawns;

            var spawnPoint = Spawns.Call("GetSpawn", spawnFile, 0);

            if (spawnPoint is string)
            {
                PrintError((string)spawnPoint);
                return;
            }
            else
            {
                CTFFlag ctfFlag = new GameObject().gameObject.AddComponent <CTFFlag>();
                ctfFlag.InitializeFlag(team, (Vector3)spawnPoint);
                if (team == Team.A)
                {
                    FlagA = ctfFlag;
                }
                else
                {
                    FlagB = ctfFlag;
                }
            }
        }
コード例 #3
0
    public override void Draw()
    {
        base.Draw();

        CTFFlag flag = Map.flags[Team.id];

        if ((!flag.IsInBase || flag.holder != null) && IsLocalPlayer)
        {
            Vector2 flagPosition = flag.holder == null ? flag.Position : flag.holder.Position;
            float   dis          = (flagPosition - Position).Length;
            Color   c            = Team.Color;
            c.A = MathHelper.Clamp((dis - 7f) / 2f, 0, 1);

            arrowMesh.Color = c;

            arrowMesh.Reset();

            arrowMesh.Translate(position);
            arrowMesh.Rotate(TKMath.GetAngle(flagPosition - position));
            arrowMesh.Translate(Math.Min(7f, (flagPosition - position).Length), 0f);
            arrowMesh.Scale(0.7f);

            arrowMesh.Draw();
        }
    }
コード例 #4
0
    public void GrabFlag(CTFFlag flag)
    {
        holdingFlag = flag;
        flag.holder = this;

        Map.FlagStolen(flag);
    }
コード例 #5
0
    public void GrabFlag(CTFFlag flag)
    {
        holdingFlag = flag;
        flag.holder = this;

        SendFlagGrabToPlayer(Map.playerList);
    }
コード例 #6
0
        public override bool OnSingleClick(Mobile from, object o)
        {
            if (!(o is Mobile))
            {
                return(base.OnSingleClick(from, o));
            }

            Mobile  m    = (Mobile)o;
            CTFTeam team = CTFGame.FindTeamFor(m);

            if (team != null)
            {
                string msg;
                Item[] items = null;

                if (m.Backpack != null)
                {
                    items = m.Backpack.FindItemsByType(typeof(CTFFlag));
                }

                if (items == null || items.Length == 0)
                {
                    msg = String.Format("(Team: {0})", team.Name);
                }
                else
                {
                    StringBuilder sb = new StringBuilder("(Team: ");
                    sb.Append(team.Name);
                    sb.Append(" -- Flag");
                    if (items.Length > 1)
                    {
                        sb.Append("s");
                    }
                    sb.Append(": ");

                    for (int j = 0; j < items.Length; j++)
                    {
                        CTFFlag flag = (CTFFlag)items[j];

                        if (flag != null && flag.Team != null)
                        {
                            if (j > 0)
                            {
                                sb.Append(", ");
                            }

                            sb.Append(flag.Team.Name);
                        }
                    }

                    sb.Append(")");
                    msg = sb.ToString();
                }
                m.PrivateOverheadMessage(Network.MessageType.Label, team.Hue, true, msg, from.NetState);
            }

            return(true);
        }
コード例 #7
0
    public void FlagStolen(CTFFlag f)
    {
        string teamName = f.ownerID == 0 ? "Blue teams" : "Orange teams";

        mesh.Color = Player.colorList[f.ownerID];

        text.Clear();
        text.Write(teamName, 0.5f, 0.4f, 1f);
        text.Write("flag has been stolen!", 0.5f, 0.55f, 1f);

        messageTimer.Reset();
    }
コード例 #8
0
        void RemovePlayer(CTFPlayer player)
        {
            if (player.hasFlag)
            {
                CTFFlag flag = player.team == Team.A ? FlagB : FlagA;

                flag.DropFlag(player.transform.position);
                player.player.SendNetworkUpdate();
                player.hasFlag = false;
                SendMessage($"{ctf.configData.Messaging.MainColor}{player.player.displayName}</color>{ctf.configData.Messaging.MSGColor} {msg("has dropped")} </color>{ctf.configData.Messaging.MainColor}{ctf.GetTeamName(flag.team)}'s</color>{ctf.configData.Messaging.MSGColor} {msg("flag")}!</color>");
            }
        }
コード例 #9
0
    public void FlagCaptured(CTFFlag f)
    {
        string teamName = f.ownerID == 0 ? "Blue teams" : "Orange teams";

        Color c = Player.colorList[(f.ownerID + 1) % 2];

        mesh.Color = c;

        text.Clear();
        text.Write(teamName, 0.5f, 0.4f, 1f);
        text.Write("flag has been captured!", 0.5f, 0.55f, 1f);

        messageTimer.Reset();

        score[(f.ownerID + 1) % 2]++;

        UpdateScoreText();
    }
コード例 #10
0
ファイル: CTFFlag.cs プロジェクト: DuckMonster/Time-Dash-Re
    public override void Logic()
    {
        if (holder == null)
        {
            foreach (CTFPlayer p in Map.playerList)
            {
                if (p != null)
                {
                    if (p.CollidesWith(Position, 0.5f))
                    {
                        if (p.Team == OwnerTeam && !IsInBase)
                        {
                            Return();
                        }
                        if (p.Team != OwnerTeam)
                        {
                            p.GrabFlag(this);
                        }
                    }
                }
            }
        }
        else
        {
            CTFFlag otherFlag = Map.flags[(ownerID + 1) % 2];
            if (otherFlag.IsInBase && holder.CollidesWith(otherFlag.Position, 0.5f))
            {
                Capture();
            }
        }

        if (holder == null && !IsInBase)
        {
            DoPhysics();
        }

        base.Logic();
    }
コード例 #11
0
ファイル: CTF.cs プロジェクト: greeduomacro/divinity
        public CTFTeamInfo( int teamID, GenericReader ip )
        {
            m_TeamID = teamID;
            m_Players = new Dictionary<Mobile, CTFPlayerInfo>();

            int version = ip.ReadEncodedInt();

            switch ( version )
            {
                case 2:
                {
                    m_Board = ip.ReadItem() as CTFBoard;

                    goto case 1;
                }
                case 1:
                {
                    m_Name = ip.ReadString();

                    goto case 0;
                }
                case 0:
                {
                    m_Color = ip.ReadEncodedInt();

                    m_Flag = ip.ReadItem() as CTFFlag;
                    m_Origin = ip.ReadPoint3D();
                    break;
                }
            }
        }
コード例 #12
0
ファイル: CTFGame.cs プロジェクト: FreeReign/imaginenation
		public void ResetGame()
		{
			AnnounceToPlayers("The game has started.");
            AnnounceToPlayers("Game will end when one of the teams reaches {0} Score.", MaxScore);
            AnnounceToPlayers("Team gets 15 Score for each flag captured and 1 point for each kill.");

			for (int i=0;i<Teams.Count;i++)
			{
				CTFTeam team = (CTFTeam)Teams[i];

				team.Score = 0;
                if (team.Flag != null)
                {
                    team.Flag.ReturnToHome();

                    Item flagItem = (Item)team.Flag;
                    flagItem.EventItem = true;
                }
                else
                {
                    CTFFlag flag = new CTFFlag(this, team);
                    flag.EventItem = true;
                }
			}
		}
コード例 #13
0
ファイル: CTFGame.cs プロジェクト: FreeReign/imaginenation
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
                case 1:
                {
                    m_DeathDelay = reader.ReadTimeSpan();
                    goto case 0;
                }
				case 0:
				{
					m_DeathPoint = reader.ReadBool();
					break;
				}
			}

            if (Running)
            {
                foreach (CTFTeam team in Teams)
                {
                    CTFFlag flag = new CTFFlag(this, team);
                    flag.EventItem = true;
                }
            }
		}
コード例 #14
0
 public ReturnTimer( CTFFlag flag )
     : base(TimeSpan.Zero, TimeSpan.FromSeconds( 1.0 ))
 {
     m_Flag = flag;
     m_End = DateTime.Now + TimeSpan.FromMinutes( 3.0 );
 }
コード例 #15
0
 public CaptureTarget( CTFFlag flag )
     : base(3, false, TargetFlags.None)
 {
     m_Flag = flag;
 }
コード例 #16
0
ファイル: CTFMap.cs プロジェクト: DuckMonster/Time-Dash-Re
 public void FlagCaptured(CTFFlag f)
 {
     score[(f.ownerID + 1) % 2]++;
 }