Exemplo n.º 1
0
        public override void OnConnectionReady(NetConnection client)
        {
            // Allocate the player to a team
            AddPlayerToTeam(client, NetPlayerComponent.GetPlayer(client));

            // Get client up to date
            NetChannel.FireEvent("Client_GamemodeInfo", client, (ushort)SCORE_CAP);
            NetChannel.FireEvent("Client_UpdateScores", client, RemoteFlag.None,
                                 NetDeliveryMethod.ReliableOrdered, (short)teamAScore, (short)teamBScore);

            // Spawn their player
            AddRespawn(client, 0);
        }
        private void ObjectComponent_OnCreatableDestroyed(object sender, NetCreatableInfo e)
        {
            ServerMPPlayer player = e.Creatable as ServerMPPlayer;

            if (player != null)
            {
                // Update network player
                NetworkPlayer netPlayer;
                if (NetPlayerComponent.TryGetPlayer(e.Owner, out netPlayer))
                {
                    netPlayer.CharacterId = null;
                }
            }
        }
        private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo e)
        {
            ServerMPPlayer player = e.Creatable as ServerMPPlayer;

            if (player != null)
            {
                // Update network player
                NetworkPlayer netPlayer = NetPlayerComponent.GetPlayer(e.Owner);
                netPlayer.CharacterId = player.StateInfo.Id;

                // Player is all set
                Players.Add(player.StateInfo.Owner, player);

                // Inform the rest of the gamemode
                OnPlayerAdded(player.StateInfo.Owner, player);
            }
        }
Exemplo n.º 4
0
        void CaptureIntel(ServerMPPlayer player, Intel intel)
        {
            intel.Return();

            string team = intel.Team == Team.A ? "Red" : "Blue";

            Screen.Chat(string.Format("The {0} intel has been captured!", team));

            if (player != null)
            {
                player.DropIntel();

                NetworkPlayer netPlayer;
                if (NetPlayerComponent.TryGetPlayer(player.StateInfo.Owner, out netPlayer))
                {
                    netPlayer.Score += SCORE_CAPTURE;

                    Screen.AddFeedItem(netPlayer.Name, "", World.GetTeamColor(player.Team),
                                       "Captured", "Intel", World.GetTeamColor(player.Team == Team.A ? Team.B : Team.A));
                }
            }
            else
            {
                Screen.AddFeedItem("?", null, World.GetTeamColor(intel.Team == Team.A ? Team.B : Team.A),
                                   "Captured", "Intel", World.GetTeamColor(intel.Team));
            }

            if (intel.Team == Team.B)
            {
                teamAScore++;
            }
            else
            {
                teamBScore++;
            }

            if (teamAScore < SCORE_CAP && teamBScore < SCORE_CAP)
            {
                NetChannel.FireEventForAllConnections("Client_IntelCaptured", (byte)intel.Team);
            }

            NetChannel.FireEventForAllConnections("Client_UpdateScores",
                                                  (short)teamAScore, (short)teamBScore);
        }
Exemplo n.º 5
0
        private void Intel_OnDropped(object sender, Player _player)
        {
            Intel          intel  = (Intel)sender;
            ServerMPPlayer player = (ServerMPPlayer)_player;

            string team = intel.Team == Team.A ? "Red" : "Blue";

            Screen.Chat(string.Format("The {0} intel has been dropped!", team));

            NetworkPlayer netPlayer;

            if (NetPlayerComponent.TryGetPlayer(player.StateInfo.Owner, out netPlayer))
            {
                Screen.AddFeedItem(netPlayer.Name, "", World.GetTeamColor(player.Team),
                                   "Dropped", "Intel", World.GetTeamColor(intel.Team));
            }

            NetChannel.FireEventForAllConnections("Client_IntelDropped", (byte)intel.Team);
        }
Exemplo n.º 6
0
        protected override void OnPlayerRespawn(NetConnection client)
        {
            // Find the connections networkplayer
            NetworkPlayer netPlayer = NetPlayerComponent.GetPlayer(client);
            Team          team      = netPlayer.Team;

            if (team == Team.None)
            {
                DashCMD.WriteError("[TDMGamemode] Failed to respawn player, they do not have a team!");
            }
            else
            {
                Vector3 spawnLocation = team == Team.A
                    ? redPost.Transform.Position
                    : bluePost.Transform.Position;

                // Create the character
                SpawnPlayer(client, spawnLocation, team);
            }
        }
Exemplo n.º 7
0
        public override void OnConnectionReady(NetConnection client)
        {
            // Allocate the player to a team
            AddPlayerToTeam(client, NetPlayerComponent.GetPlayer(client));

            // Get client up to date
            NetChannel.FireEvent("Client_GamemodeInfo", client, (ushort)SCORE_CAP);
            NetChannel.FireEvent("Client_UpdateScores", client, RemoteFlag.None,
                                 NetDeliveryMethod.ReliableOrdered, (short)teamAScore, (short)teamBScore);
            if (redIntel.Holder != null)
            {
                NetChannel.FireEvent("Client_IntelPickedUp", client,
                                     (byte)Team.A, ((ServerMPPlayer)redIntel.Holder).StateInfo.Id);
            }
            if (blueIntel.Holder != null)
            {
                NetChannel.FireEvent("Client_IntelPickedUp", client,
                                     (byte)Team.B, ((ServerMPPlayer)blueIntel.Holder).StateInfo.Id);
            }

            // Spawn their player
            AddRespawn(client, 0);
        }