コード例 #1
0
ファイル: MPClient.cs プロジェクト: DaniGTA/Gurkenplayer
        /// <summary>
        /// Method to process the received information.
        /// </summary>
        /// <param name="type">Type of the message. Indicates what the message's contents are.</param>
        /// <param name="msg">The message to process.</param>
        private void ProgressData(MPMessageType msgType, NetIncomingMessage msg)
        {
            Log.Message("Client received " + msgType);
            switch (msgType)
            {
            case MPMessageType.MoneyUpdate:     // Receiving money
                long t = msg.ReadInt64();
                EcoExtBase.MPInternalMoneyAmount = t;
                break;

            case MPMessageType.DemandUpdate:     // Receiving demand
                DemandExtBase.MPCommercialDemand = msg.ReadInt32();
                DemandExtBase.MPResidentalDemand = msg.ReadInt32();
                DemandExtBase.MPWorkplaceDemand  = msg.ReadInt32();
                break;

            case MPMessageType.TileUpdate:     // Receiving tile coordinates to unlock
                AreaExtBase.MPXCoordinate = msg.ReadInt32();
                AreaExtBase.MPZCoordinate = msg.ReadInt32();
                // INFO: The unlock process is activated simutaniously with the
                // EcoExtBase.OnUpdateMoneyAmount(long internalMoneyAmount).
                // Maybe I find a direct way to unlock a tile within AreaExtBase
                break;

            case MPMessageType.SimulationUpdate:     // Receiving update on simulation information
                SimulationManager.instance.SelectedSimulationSpeed = msg.ReadInt32();
                SimulationManager.instance.SimulationPaused        = msg.ReadBoolean();
                break;

            case MPMessageType.CitizenUpdate:
                CitizenManager.instance.m_citizenCount = msg.ReadInt32();
                break;

            default:     // Unhandled ID (MPMessageType)
                OnClientReceivedUnhandledMessage(new ReceivedUnhandledMessageEventArgs(msg, msgType.ToString()));
                break;
            }
        }
コード例 #2
0
ファイル: MPClient.cs プロジェクト: rockhowse/Gurkenplayer
 /// <summary>
 /// Method to process the received information.
 /// </summary>
 /// <param name="type">Type of the message. Indicates what the message's contents are.</param>
 /// <param name="msg">The message to process.</param>
 private void ProgressData(MPMessageType msgType, NetIncomingMessage msg)
 {
     Log.Message("Client received " + msgType);
     switch (msgType)
     {
         case MPMessageType.MoneyUpdate: // Receiving money
             long t = msg.ReadInt64();
             EcoExtBase.MPInternalMoneyAmount = t;
             break;
         case MPMessageType.DemandUpdate: // Receiving demand
             DemandExtBase.MPCommercialDemand = msg.ReadInt32();
             DemandExtBase.MPResidentalDemand = msg.ReadInt32();
             DemandExtBase.MPWorkplaceDemand = msg.ReadInt32();
             break;
         case MPMessageType.TileUpdate: // Receiving tile coordinates to unlock
             AreaExtBase.MPXCoordinate = msg.ReadInt32();
             AreaExtBase.MPZCoordinate = msg.ReadInt32();
             // INFO: The unlock process is activated simutaniously with the
             // EcoExtBase.OnUpdateMoneyAmount(long internalMoneyAmount).
             // Maybe I find a direct way to unlock a tile within AreaExtBase
             break;
         case MPMessageType.SimulationUpdate: // Receiving update on simulation information
             SimulationManager.instance.SelectedSimulationSpeed = msg.ReadInt32();
             SimulationManager.instance.SimulationPaused = msg.ReadBoolean();
             break;
         case MPMessageType.CitizenUpdate:
             CitizenManager.instance.m_citizenCount = msg.ReadInt32();
             break;
         default: // Unhandled ID (MPMessageType)
             OnClientReceivedUnhandledMessage(new ReceivedUnhandledMessageEventArgs(msg, msgType.ToString()));
             break;
     }
 }