Exemplo n.º 1
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);
 }
Exemplo n.º 2
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);
        }