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