示例#1
0
 private bool HandleClientEventDuelRequest(NetworkCommunicator peer, DuelRequest message)
 {
     if (peer == null || peer.GetComponent <MissionPeer>() == null || (peer.GetComponent <MissionPeer>().ControlledAgent == null || message.RequestedAgent == null))
     {
         return(false);
     }
     this.DuelRequestReceived(peer.GetComponent <DuelMissionRepresentative>().ControlledAgent, message.RequestedAgent);
     return(true);
 }
        private bool HandleClientEventLobbyEquipmentUpdated(
            NetworkCommunicator peer,
            RequestTroopIndexChange message)
        {
            MissionPeer component = peer.GetComponent <MissionPeer>();

            if (component == null)
            {
                return(false);
            }
            SpawnComponent missionBehaviour = this.Mission.GetMissionBehaviour <SpawnComponent>();

            if (missionBehaviour == null)
            {
                return(false);
            }
            if (missionBehaviour.AreAgentsSpawning() && component.SelectedTroopIndex != message.SelectedTroopIndex)
            {
                component.SelectedTroopIndex = message.SelectedTroopIndex;
                GameNetwork.BeginBroadcastModuleEvent();
                GameNetwork.WriteMessage((GameNetworkMessage) new UpdateSelectedTroopIndex(peer, message.SelectedTroopIndex));
                GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, peer);
                if (this.OnEquipmentRefreshed != null)
                {
                    this.OnEquipmentRefreshed(component);
                }
            }
            return(true);
        }
示例#3
0
        private void HandleServerEventKillDeathCountChangeEvent(KillDeathCountChange message)
        {
            if (message.VictimPeer == null)
            {
                return;
            }
            MissionPeer         component    = message.VictimPeer.GetComponent <MissionPeer>();
            NetworkCommunicator attackerPeer = message.AttackerPeer;
            MissionPeer         killedPeer   = attackerPeer != null?attackerPeer.GetComponent <MissionPeer>() : (MissionPeer)null;

            if (component != null)
            {
                component.KillCount   = message.KillCount;
                component.AssistCount = message.AssistCount;
                component.DeathCount  = message.DeathCount;
                component.Score       = message.Score;
                component.OnKillAnotherPeer(killedPeer);
                if (message.KillCount == 0 && message.AssistCount == 0 && (message.DeathCount == 0 && message.Score == 0))
                {
                    component.ResetKillRegistry();
                }
            }
            if (this._missionScoreboardComponent == null)
            {
                return;
            }
            this._missionScoreboardComponent.PlayerPropertiesChanged(message.VictimPeer);
        }
        public void HandleAgentVisualSpawning(
            NetworkCommunicator spawningNetworkPeer,
            AgentBuildData spawningAgentBuildData,
            int troopCountInFormation = 0)
        {
            MissionPeer component = spawningNetworkPeer.GetComponent <MissionPeer>();

            component.HasSpawnedAgentVisuals   = true;
            component.EquipmentUpdatingExpired = false;
            if (!this.IsGameModeHidingAllAgentVisuals)
            {
                GameNetwork.BeginBroadcastModuleEvent();
                GameNetwork.WriteMessage((GameNetworkMessage) new CreateAgentVisuals(spawningNetworkPeer, spawningAgentBuildData, component.SelectedTroopIndex, troopCountInFormation));
                GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, spawningNetworkPeer);
            }
            else
            {
                if (spawningNetworkPeer.IsServerPeer)
                {
                    return;
                }
                GameNetwork.BeginModuleEventAsServer(spawningNetworkPeer);
                GameNetwork.WriteMessage((GameNetworkMessage) new CreateAgentVisuals(spawningNetworkPeer, spawningAgentBuildData, component.SelectedTroopIndex, troopCountInFormation));
                GameNetwork.EndModuleEventAsServer();
            }
        }
        private void TeamChange(NetworkCommunicator player, Team oldTeam, Team nextTeam)
        {
            MissionPeer component = player.GetComponent <MissionPeer>();

            if (oldTeam != null)
            {
                if (oldTeam == this.Mission.SpectatorTeam)
                {
                    this._spectators.Remove(component);
                }
                else
                {
                    this._sides[(int)oldTeam.Side].RemovePlayer(component);
                }
            }
            if (nextTeam != null)
            {
                if (nextTeam == this.Mission.SpectatorTeam)
                {
                    this._spectators.Add(component);
                }
                else
                {
                    this._sides[(int)nextTeam.Side].AddPlayer(component);
                }
            }
            if (this.OnPlayerSideChanged == null)
            {
                return;
            }
            this.OnPlayerSideChanged(oldTeam, nextTeam, component);
        }
示例#6
0
 public override void OnPeerChangedTeam(NetworkCommunicator peer, Team oldTeam, Team newTeam)
 {
     if (oldTeam == null || oldTeam == newTeam || !this.UseGold())
     {
         return;
     }
     this.ChangeCurrentGoldForPeer(peer.GetComponent <MissionPeer>(), 0);
 }
示例#7
0
 private void OnPreTeamChanged(NetworkCommunicator peer, Team currentTeam, Team newTeam)
 {
     if (!peer.IsSynchronized || peer.GetComponent <MissionPeer>().ControlledAgent == null)
     {
         return;
     }
     this.MakePlayerFormationCharge(peer);
 }
示例#8
0
 public override void OnPeerChangedTeam(NetworkCommunicator peer, Team oldTeam, Team newTeam)
 {
     if (oldTeam == null || oldTeam == newTeam || oldTeam.Side == BattleSideEnum.None)
     {
         return;
     }
     this.ChangeCurrentGoldForPeer(peer.GetComponent <MissionPeer>(), 100);
 }
示例#9
0
        protected override void HandleNewClientAfterSynchronized(NetworkCommunicator networkPeer)
        {
            MissionPeer component = networkPeer.GetComponent <MissionPeer>();

            component.Team = this.Mission.AttackerTeam;
            if (networkPeer.IsServerPeer)
            {
                return;
            }
            this._missionNetworkComponent?.OnPeerSelectedTeam(component);
        }
示例#10
0
        private void HandleServerEventAddPeerComponent(AddPeerComponent message)
        {
            NetworkCommunicator peer = message.Peer;
            uint componentId         = message.ComponentId;

            if (peer.GetComponent(componentId) != null)
            {
                return;
            }
            peer.AddComponent(componentId);
        }
示例#11
0
        public void ForfeitSpawning(NetworkCommunicator peer)
        {
            MissionPeer component = peer.GetComponent <MissionPeer>();

            if (component == null || !component.HasSpawnedAgentVisuals || (!this.UseGold() || !this.RoundController.IsRoundInProgress))
            {
                return;
            }
            Mission.Current.GetMissionBehaviour <MultiplayerMissionAgentVisualSpawnComponent>().RemoveAgentVisuals(component, true);
            this.ChangeCurrentGoldForPeer(component, -1);
        }
示例#12
0
 private bool ServerPrepareAndSendMessage(
     NetworkCommunicator fromPeer,
     bool toTeamOnly,
     string message)
 {
     if (fromPeer.IsMuted)
     {
         GameNetwork.BeginModuleEventAsServer(fromPeer);
         GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.ServerMessage("str_multiplayer_muted_message", true));
         GameNetwork.EndModuleEventAsServer();
         return(true);
     }
     if (!GameNetwork.IsDedicatedServer && fromPeer != GameNetwork.MyPeer && !this._mutedPlayers.Contains(fromPeer.VirtualPlayer.Id))
     {
         MissionPeer component1 = GameNetwork.MyPeer.GetComponent <MissionPeer>();
         if (component1 == null)
         {
             return(false);
         }
         bool flag;
         if (toTeamOnly)
         {
             if (component1 == null)
             {
                 return(false);
             }
             MissionPeer component2 = fromPeer.GetComponent <MissionPeer>();
             if (component2 == null)
             {
                 return(false);
             }
             flag = component1.Team == component2.Team;
         }
         else
         {
             flag = true;
         }
         if (flag)
         {
             this.OnPlayerMessageReceived(fromPeer, message, toTeamOnly);
         }
     }
     if (toTeamOnly)
     {
         ChatBox.ServerSendMessageToTeam(fromPeer, message);
     }
     else
     {
         ChatBox.ServerSendMessageToEveryone(fromPeer, message);
     }
     return(true);
 }
示例#13
0
        private void MakePlayerFormationCharge(NetworkCommunicator peer)
        {
            if (!peer.IsSynchronized)
            {
                return;
            }
            MissionPeer component = peer.GetComponent <MissionPeer>();

            if (component.ControlledFormation == null || component.ControlledAgent == null)
            {
                return;
            }
            component.Team.GetOrderControllerOf(component.ControlledAgent).SetOrder(OrderType.Charge);
        }
        public void PlayerPropertiesChanged(NetworkCommunicator player)
        {
            if (GameNetwork.IsDedicatedServer)
            {
                return;
            }
            MissionPeer component = player.GetComponent <MissionPeer>();

            if (component == null)
            {
                return;
            }
            this.PlayerPropertiesChanged(component);
        }
示例#15
0
        private static void ServerSendMessageToTeam(NetworkCommunicator networkPeer, string message)
        {
            MissionPeer missionPeer = networkPeer.GetComponent <MissionPeer>();

            if (missionPeer.Team == null)
            {
                return;
            }
            foreach (NetworkCommunicator communicator in GameNetwork.NetworkPeers.Where <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => !x.IsServerPeer && x.IsSynchronized && x != networkPeer && x.GetComponent <MissionPeer>().Team == missionPeer.Team)))
            {
                GameNetwork.BeginModuleEventAsServer(communicator);
                GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.PlayerMessageTeam(networkPeer, message));
                GameNetwork.EndModuleEventAsServer();
            }
        }
        private void ChangeTeamServer(NetworkCommunicator networkPeer, Team team)
        {
            MissionPeer component1 = networkPeer.GetComponent <MissionPeer>();
            MissionPeer component2 = networkPeer.GetComponent <MissionPeer>();
            Team        team1      = component1.Team;

            if (team1 != null && team1 != this.Mission.SpectatorTeam && (team1 != team && component1.ControlledAgent != null))
            {
                component1.ControlledAgent.Die(new Blow(component1.ControlledAgent.Index)
                {
                    DamageType    = DamageTypes.Invalid,
                    BaseMagnitude = 10000f,
                    Position      = component1.ControlledAgent.Position
                }, Agent.KillInfo.Stone);
            }
            component1.Team = team;
            if (team != team1)
            {
                if (component2.HasSpawnedAgentVisuals)
                {
                    component2.HasSpawnedAgentVisuals = false;
                    MBDebug.Print("HasSpawnedAgentVisuals = false for peer: " + component2.Name + " because he just changed his team");
                    component2.SpawnCountThisRound = 0;
                    Mission.Current.GetMissionBehaviour <MultiplayerMissionAgentVisualSpawnComponent>().RemoveAgentVisuals(component2, true);
                }
                if (!this._gameModeServer.IsGameModeHidingAllAgentVisuals && !networkPeer.IsServerPeer)
                {
                    this._missionNetworkComponent?.OnPeerSelectedTeam(component1);
                }
                this._gameModeServer.OnPeerChangedTeam(networkPeer, team1, team);
                component2.SpawnTimer.Reset(MBCommon.GetTime(MBCommon.TimeType.Mission), 0.1f);
                component2.WantsToSpawnAsBot    = false;
                component2.HasSpawnTimerExpired = false;
            }
            this.UpdateTeams(networkPeer, team1, team);
        }
        public bool ShouldSpawnVisualsForServer(NetworkCommunicator spawningNetworkPeer)
        {
            if (GameNetwork.IsDedicatedServer)
            {
                return(false);
            }
            NetworkCommunicator myPeer      = GameNetwork.MyPeer;
            MissionPeer         missionPeer = myPeer != null?myPeer.GetComponent <MissionPeer>() : (MissionPeer)null;

            if (missionPeer == null)
            {
                return(false);
            }
            MissionPeer component = spawningNetworkPeer.GetComponent <MissionPeer>();

            return(!this.IsGameModeHidingAllAgentVisuals && component.Team == missionPeer.Team || spawningNetworkPeer.IsServerPeer);
        }
示例#18
0
 protected override void HandleNewClientAfterSynchronized(NetworkCommunicator networkPeer)
 {
     networkPeer.AddComponent <FlagDominationMissionRepresentative>();
     if (this.UseGold() && !this.RoundController.IsRoundInProgress)
     {
         this.ChangeCurrentGoldForPeer(networkPeer.GetComponent <MissionPeer>(), 300);
         this._gameModeFlagDominationClient?.OnGoldAmountChangedForRepresentative((MissionRepresentativeBase)networkPeer.GetComponent <FlagDominationMissionRepresentative>(), 300);
     }
     if (this.AllCapturePoints == null || networkPeer.IsServerPeer)
     {
         return;
     }
     foreach (FlagCapturePoint flagCapturePoint in this.AllCapturePoints.Where <FlagCapturePoint>((Func <FlagCapturePoint, bool>)(cp => !cp.IsDeactivated)))
     {
         GameNetwork.BeginModuleEventAsServer(networkPeer);
         GameNetwork.WriteMessage((GameNetworkMessage) new FlagDominationCapturePointMessage(flagCapturePoint.FlagIndex, this._capturePointOwners[flagCapturePoint.FlagIndex]));
         GameNetwork.EndModuleEventAsServer();
     }
 }
示例#19
0
        private bool HandleClientEventCreateBannerForPeer(
            NetworkCommunicator peer,
            NetworkMessages.FromClient.CreateBanner message)
        {
            MissionMultiplayerGameModeBase missionBehaviour = Mission.Current.GetMissionBehaviour <MissionMultiplayerGameModeBase>();

            if (missionBehaviour == null || !missionBehaviour.AllowCustomPlayerBanners())
            {
                return(false);
            }
            MissionPeer component = peer.GetComponent <MissionPeer>();

            if (component == null)
            {
                return(false);
            }
            component.Peer.BannerCode = message.BannerCode;
            MissionLobbyComponent.SyncBannersToAllClients(message.BannerCode, component.GetNetworkPeer());
            return(true);
        }
示例#20
0
 protected virtual void OnBotDies(Agent botAgent, MissionPeer assistorPeer)
 {
     if (assistorPeer != null)
     {
         GameNetwork.BeginBroadcastModuleEvent();
         GameNetwork.WriteMessage((GameNetworkMessage) new KillDeathCountChange(assistorPeer.GetNetworkPeer(), (NetworkCommunicator)null, assistorPeer.KillCount, assistorPeer.AssistCount, assistorPeer.DeathCount, assistorPeer.Score));
         GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
     }
     if (botAgent == null)
     {
         return;
     }
     if (botAgent.Formation?.PlayerOwner != null)
     {
         NetworkCommunicator networkCommunicator = GameNetwork.NetworkPeers.SingleOrDefault <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => x.GetComponent <MissionPeer>() != null && x.GetComponent <MissionPeer>().ControlledFormation == botAgent.Formation));
         if (networkCommunicator != null)
         {
             MissionPeer component = networkCommunicator.GetComponent <MissionPeer>();
             ++component.DeathCount;
             --component.BotsUnderControlAlive;
             this._missionScoreboardComponent.PlayerPropertiesChanged(networkCommunicator);
             GameNetwork.BeginBroadcastModuleEvent();
             GameNetwork.WriteMessage((GameNetworkMessage) new KillDeathCountChange(networkCommunicator, (NetworkCommunicator)null, component.KillCount, component.AssistCount, component.DeathCount, component.Score));
             GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
             GameNetwork.BeginBroadcastModuleEvent();
             GameNetwork.WriteMessage((GameNetworkMessage) new BotsControlledChange(networkCommunicator, component.BotsUnderControlAlive, component.BotsUnderControlTotal));
             GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
         }
     }
     else
     {
         MissionScoreboardComponent.MissionScoreboardSide sideSafe = this._missionScoreboardComponent.GetSideSafe(botAgent.Team.Side);
         BotData botScores = sideSafe.BotScores;
         ++botScores.DeathCount;
         --botScores.AliveCount;
         GameNetwork.BeginBroadcastModuleEvent();
         GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.BotData(sideSafe.Side, botScores.KillCount, botScores.AssistCount, botScores.DeathCount, botScores.AliveCount));
         GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
     }
     this._missionScoreboardComponent.BotPropertiesChanged(botAgent.Team.Side);
 }
示例#21
0
 public void KickPlayer(NetworkCommunicator peerToKick, bool banPlayer)
 {
     if (GameNetwork.IsServer || GameNetwork.IsDedicatedServer)
     {
         if (peerToKick.IsMine)
         {
             return;
         }
         MissionPeer component = peerToKick.GetComponent <MissionPeer>();
         if (component == null)
         {
             return;
         }
         if (banPlayer)
         {
             if (GameNetwork.IsClient)
             {
                 BannedPlayerManagerCustomGameClient.AddBannedPlayer(component.Peer.Id, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000);
             }
             else if (GameNetwork.IsDedicatedServer)
             {
                 BannedPlayerManagerCustomGameServer.AddBannedPlayer(component.Peer.Id, component.GetNetworkPeer().UserName, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000);
             }
         }
         if (GameNetwork.IsDedicatedServer)
         {
             throw new NotImplementedException();
         }
         NetworkMain.GameClient.KickPlayer(component.Peer.Id, banPlayer);
     }
     else
     {
         if (!GameNetwork.IsClient)
         {
             return;
         }
         GameNetwork.BeginModuleEventAsClient();
         GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromClient.KickPlayer(peerToKick, banPlayer));
         GameNetwork.EndModuleEventAsClient();
     }
 }
        private bool HandleClientEventRequestPerkChange(
            NetworkCommunicator peer,
            RequestPerkChange message)
        {
            MissionPeer component = peer.GetComponent <MissionPeer>();

            if (component == null)
            {
                return(false);
            }
            SpawnComponent missionBehaviour = this.Mission.GetMissionBehaviour <SpawnComponent>();

            if (missionBehaviour == null)
            {
                return(false);
            }
            if (component.SelectPerk(message.PerkListIndex, message.PerkIndex) && missionBehaviour.AreAgentsSpawning() && this.OnEquipmentRefreshed != null)
            {
                this.OnEquipmentRefreshed(component);
            }
            return(true);
        }
示例#23
0
        private static void CreateFixedBannerForPeer(
            NetworkCommunicator peer,
            Team currTeam,
            Team nextTeam)
        {
            if (!GameNetwork.IsServerOrRecorder)
            {
                return;
            }
            Mission.Current.GetMissionBehaviour <MissionMultiplayerGameModeBase>();
            MissionPeer component = peer.GetComponent <MissionPeer>();

            if (nextTeam.Side != BattleSideEnum.Attacker && nextTeam.Side != BattleSideEnum.Defender)
            {
                return;
            }
            List <string> stringList = new List <string>();

            stringList.Add("11.8.1.4345.4345.770.774.1.0.0.133.7.5.512.512.784.769.1.0.0");
            stringList.Add("11.8.1.4345.4345.770.774.1.0.0.156.7.5.512.512.784.769.1.0.0");
            stringList.Add("11.8.1.4345.4345.770.774.1.0.0.155.7.5.512.512.784.769.1.0.0");
            stringList.Add("11.8.1.4345.4345.770.774.1.0.0.158.7.5.512.512.784.769.1.0.0");
            stringList.Add("11.8.1.4345.4345.770.774.1.0.0.118.7.5.512.512.784.769.1.0.0");
            stringList.Add("11.8.1.4345.4345.770.774.1.0.0.149.7.5.512.512.784.769.1.0.0");
            List <string> list = GameNetwork.NetworkPeers.Where <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => x.GetComponent <MissionPeer>()?.Team == nextTeam)).Select <NetworkCommunicator, string>((Func <NetworkCommunicator, string>)(x => x.GetComponent <MissionPeer>().Peer.BannerCode)).ToList <string>();

            foreach (string str in stringList)
            {
                if (!list.Contains(str))
                {
                    component.Peer.BannerCode = str;
                    break;
                }
            }
            GameNetwork.BeginBroadcastModuleEvent();
            GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.CreateBanner(peer, component.Peer.BannerCode));
            GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
        }
        private void SendNotificationToTeam(
            Team team,
            MultiplayerGameNotificationsComponent.MultiplayerNotificationEnum message,
            int param1 = -1,
            int param2 = -1)
        {
            NetworkCommunicator myPeer      = GameNetwork.MyPeer;
            MissionPeer         missionPeer = myPeer != null?myPeer.GetComponent <MissionPeer>() : (MissionPeer)null;

            if (!GameNetwork.IsDedicatedServer && (missionPeer?.Team != null && missionPeer.Team.IsEnemyOf(team)))
            {
                this.ShowNotification(message, param1, param2);
            }
            foreach (MissionPeer peer in VirtualPlayer.Peers <MissionPeer>())
            {
                if (peer.Team != null && !peer.IsMine && !peer.Team.IsEnemyOf(team))
                {
                    GameNetwork.BeginModuleEventAsServer(peer.Peer);
                    GameNetwork.WriteMessage((GameNetworkMessage) new NotificationMessage((int)message, param1, param2));
                    GameNetwork.EndModuleEventAsServer();
                }
            }
        }
 protected override void HandleLateNewClientAfterSynchronized(NetworkCommunicator networkPeer)
 {
     networkPeer.GetComponent <MissionPeer>();
     foreach (MissionScoreboardComponent.MissionScoreboardSide side in this._sides)
     {
         if (side != null && !networkPeer.IsServerPeer)
         {
             if (side.BotScores.IsAnyValid)
             {
                 GameNetwork.BeginModuleEventAsServer(networkPeer);
                 GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.BotData(side.Side, side.BotScores.KillCount, side.BotScores.AssistCount, side.BotScores.DeathCount, side.BotScores.AliveCount));
                 GameNetwork.EndModuleEventAsServer();
             }
             if (this._mpGameModeBase != null)
             {
                 int defenderTeamScore = this._scoreboardSides != MissionScoreboardComponent.ScoreboardSides.OneSide ? this._sides[0].SideScore : 0;
                 GameNetwork.BeginModuleEventAsServer(networkPeer);
                 GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.UpdateRoundScores(this._sides[1].SideScore, defenderTeamScore));
                 GameNetwork.EndModuleEventAsServer();
             }
         }
     }
 }
示例#26
0
        protected virtual void OnPlayerKills(
            MissionPeer killerPeer,
            Agent killedAgent,
            MissionPeer assistorPeer)
        {
            NetworkCommunicator killedPeer = (NetworkCommunicator)null;

            if (killedAgent.MissionPeer == null)
            {
                NetworkCommunicator networkPeer = GameNetwork.NetworkPeers.SingleOrDefault <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => x.GetComponent <MissionPeer>() != null && x.GetComponent <MissionPeer>().ControlledFormation != null && x.GetComponent <MissionPeer>().ControlledFormation == killedAgent.Formation));
                if (networkPeer != null)
                {
                    MissionPeer component = networkPeer.GetComponent <MissionPeer>();
                    killedPeer = networkPeer;
                    killerPeer.OnKillAnotherPeer(component);
                }
            }
            else
            {
                killerPeer.OnKillAnotherPeer(killedAgent.MissionPeer);
                killedPeer = killedAgent.MissionPeer.GetNetworkPeer();
            }
            if (killerPeer.ControlledAgent.Team.IsEnemyOf(killedAgent.Team))
            {
                killerPeer.Score += this._gameMode.GetScoreForKill(killedAgent);
                ++killerPeer.KillCount;
            }
            else
            {
                killerPeer.Score -= this._gameMode.GetScoreForKill(killedAgent);
                --killerPeer.KillCount;
            }
            this._missionScoreboardComponent.PlayerPropertiesChanged(killerPeer.GetNetworkPeer());
            GameNetwork.BeginBroadcastModuleEvent();
            GameNetwork.WriteMessage((GameNetworkMessage) new KillDeathCountChange(killerPeer.GetNetworkPeer(), killedPeer, killerPeer.KillCount, killerPeer.AssistCount, killerPeer.DeathCount, killerPeer.Score));
            GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
        }
示例#27
0
        private void HandleServerEventRemovePeerComponent(RemovePeerComponent message)
        {
            NetworkCommunicator peer = message.Peer;

            peer.RemoveComponent(peer.GetComponent(message.ComponentId));
        }
示例#28
0
 protected override void HandleNewClientAfterSynchronized(NetworkCommunicator networkPeer)
 {
     networkPeer.AddComponent <TeamDeathmatchMissionRepresentative>();
     this.ChangeCurrentGoldForPeer(networkPeer.GetComponent <MissionPeer>(), 120);
     this.GameModeBaseClient.OnGoldAmountChangedForRepresentative((MissionRepresentativeBase)networkPeer.GetComponent <TeamDeathmatchMissionRepresentative>(), 120);
 }
 protected override void HandleNewClientAfterSynchronized(NetworkCommunicator networkPeer)
 {
     networkPeer.AddComponent <FFAMissionRepresentative>();
     networkPeer.GetComponent <MissionPeer>().Team = this.Mission.AttackerTeam;
 }
示例#30
0
        protected virtual void OnBotKills(Agent botAgent, Agent killedAgent)
        {
            if (botAgent?.Team == null)
            {
                return;
            }
            if (botAgent.Formation?.PlayerOwner != null)
            {
                NetworkCommunicator networkCommunicator1 = GameNetwork.NetworkPeers.SingleOrDefault <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => x.GetComponent <MissionPeer>() != null && x.GetComponent <MissionPeer>().ControlledFormation == botAgent.Formation));
                if (networkCommunicator1 != null)
                {
                    MissionPeer         component            = networkCommunicator1.GetComponent <MissionPeer>();
                    MissionPeer         missionPeer          = killedAgent.MissionPeer;
                    NetworkCommunicator networkCommunicator2 = missionPeer != null?missionPeer.GetNetworkPeer() : (NetworkCommunicator)null;

                    if (killedAgent.MissionPeer == null)
                    {
                        NetworkCommunicator networkCommunicator3 = GameNetwork.NetworkPeers.SingleOrDefault <NetworkCommunicator>((Func <NetworkCommunicator, bool>)(x => x.GetComponent <MissionPeer>() != null && x.GetComponent <MissionPeer>().ControlledFormation == killedAgent.Formation));
                        if (networkCommunicator3 != null)
                        {
                            networkCommunicator2 = networkCommunicator3;
                            component.OnKillAnotherPeer(networkCommunicator2.GetComponent <MissionPeer>());
                        }
                    }
                    else
                    {
                        component.OnKillAnotherPeer(killedAgent.MissionPeer);
                    }
                    if (botAgent.Team.IsEnemyOf(killedAgent.Team))
                    {
                        ++component.KillCount;
                        component.Score += this._gameMode.GetScoreForKill(killedAgent);
                    }
                    else
                    {
                        --component.KillCount;
                        component.Score -= this._gameMode.GetScoreForKill(killedAgent);
                    }
                    this._missionScoreboardComponent.PlayerPropertiesChanged(networkCommunicator1);
                    GameNetwork.BeginBroadcastModuleEvent();
                    GameNetwork.WriteMessage((GameNetworkMessage) new KillDeathCountChange(networkCommunicator1, networkCommunicator2, component.KillCount, component.AssistCount, component.DeathCount, component.Score));
                    GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
                }
            }
            else
            {
                MissionScoreboardComponent.MissionScoreboardSide sideSafe = this._missionScoreboardComponent.GetSideSafe(botAgent.Team.Side);
                BotData botScores = sideSafe.BotScores;
                if (botAgent.Team.IsEnemyOf(killedAgent.Team))
                {
                    ++botScores.KillCount;
                }
                else
                {
                    --botScores.KillCount;
                }
                this._missionScoreboardComponent.BotPropertiesChanged(sideSafe.Side);
                GameNetwork.BeginBroadcastModuleEvent();
                GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.BotData(sideSafe.Side, botScores.KillCount, botScores.AssistCount, botScores.DeathCount, botScores.AliveCount));
                GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None);
            }
            this._missionScoreboardComponent.BotPropertiesChanged(botAgent.Team.Side);
        }