private void InputOnOnReceiveGamerInfo(GamersPacket gamersPacket)
 {
     //auto rebrith
     for (int i = 0; i < gamersPacket.Gamers.Length; i++)
     {
         if (gamersPacket.Gamers[i].PlayerSlot == slotId &&
             gamersPacket.Gamers[i].State == EGamerState.Die)
         {
             bot.output.Rebirth(0);
         }
     }
 }
示例#2
0
 public void fireReceiveGamerInfo(GamersPacket r)
 {
     onReceiveGamerInfo?.Invoke(r);
 }
示例#3
0
        public static void FReceiveGamePacket(IGamerEntity gamer, Dictionary <byte, object> packet, out SimWorld world)
        {
            foreach (byte key in packet.Keys)
            {
                if (!Enum.TryParse(key.ToString(), out EServerGameCode code))
                {
                    //LogProxy.WriteError($"Parse EServerGameCode fail, Value:{key}");
                    continue;
                }

                switch (code)
                {
                //遊戲正式開始
                case EServerGameCode.GameStart:
                    if (!gamer.input.IsStartGame)
                    {
                        gamer.input.IsStartGame = true;
                        gamer.input.SetLevel(GamerInput.Level.Gaming);
                        //LogProxy.WriteLine($"EServerGameCode.GameStart({gamer.account.Info.Name})");
                    }
                    break;

                //遊戲訊息
                case EServerGameCode.GamerInfo:
                    break;

                //遊戲結果
                case EServerGameCode.GameResult:
                    Console.WriteLine("Receive game result.");
                    //LogProxy.WriteLine($"EServerGameCode.GameResult({gamer.account.Info.Name})");
                    gamer.input.IsOverGame = true;
                    break;
                }
            }

            EnvironmentPacket?PacketEnv = null;

            GameEvent[]               PacketGameEvent  = null;
            DropItemPacket            PacketDropItem   = null;
            int?                      PacketBonuspot   = null;
            GameResultPacket          PacketGameResult = null;
            GamersPacket              PacketGamersInfo = null;
            object                    PacketBroadcast  = null;
            string                    PacketPureData   = null;
            object                    PacketGameStart  = null;
            Dictionary <string, byte> PacketGamerSlots = null;

            byte[] PacketGMGamer   = null;
            int?   PacketCountDown = null;
            float? PacketGameTime  = null;

            foreach (var key in packet.Keys)
            {
                if (!Enum.TryParse(key.ToString(), out EServerGameCode code))
                {
                    continue;
                }
                switch (code)
                {
                case EServerGameCode.Environment:
                    PacketEnv = (EnvironmentPacket)packet[key];
                    break;

                case EServerGameCode.GameEvent:
                    PacketGameEvent = (GameEvent[])packet[key];
                    break;

                case EServerGameCode.DropItem:
                    PacketDropItem = (DropItemPacket)packet[key];
                    break;

                case EServerGameCode.Bonuspot:
                    PacketBonuspot = (int)packet[key];
                    break;

                case EServerGameCode.GameResult:
                    PacketGameResult = (GameResultPacket)packet[key];
                    break;

                case EServerGameCode.GamerInfo:
                    PacketGamersInfo = (GamersPacket)packet[key];
                    break;

                case EServerGameCode.Broadcast:
                    PacketBroadcast = packet[key];
                    break;

                case EServerGameCode.PureData:
                    PacketPureData = (string)packet[key];
                    break;

                case EServerGameCode.GameStart:
                    PacketGameStart = packet[key];
                    break;

                case EServerGameCode.GamerSlots:
                    PacketGamerSlots = (Dictionary <string, byte>)packet[key];
                    break;

                case EServerGameCode.RMGamer:
                    PacketGMGamer = (byte[])packet[key];
                    break;

                case EServerGameCode.CountDown:
                    PacketCountDown = (int)packet[key];
                    break;

                case EServerGameCode.GameTime:
                    PacketGameTime = (float)packet[key];
                    break;
                }
            }

            if (PacketEnv != null)
            {
                gamer.fireReceiver.fireReceiveEnvironment(PacketEnv.Value);
            }
            if (PacketGameEvent != null)
            {
                gamer.fireReceiver.fireReceiveGameEvent(PacketGameEvent);
            }
            if (PacketDropItem != null)
            {
                gamer.fireReceiver.fireReceiveDropItem(PacketDropItem);
            }
            if (PacketBonuspot != null)
            {
                gamer.fireReceiver.fireReceiveBonuspot(PacketBonuspot.Value);
            }
            if (PacketGameResult != null)
            {
                gamer.fireReceiver.fireReceiveGameResult(PacketGameResult);
            }
            if (PacketGamersInfo != null)
            {
                gamer.fireReceiver.fireReceiveGamerInfo(PacketGamersInfo);
            }
            if (PacketBroadcast != null)
            {
                gamer.fireReceiver.fireReceiveBroadcast(PacketBroadcast);
            }
            if (PacketPureData != null)
            {
                gamer.fireReceiver.fireReceivePureData(PacketPureData);
            }
            if (PacketGameStart != null)
            {
                gamer.fireReceiver.fireReceiveGameStart(PacketGameStart);
            }
            if (PacketGamerSlots != null)
            {
                gamer.fireReceiver.fireReceiveGamerSlots(PacketGamerSlots);
            }
            if (PacketGMGamer != null)
            {
                gamer.fireReceiver.fireReceiveGMGamer(PacketGMGamer);
            }
            if (PacketCountDown != null)
            {
                gamer.fireReceiver.fireReceiveCountDown(PacketCountDown.Value);
            }
            if (PacketGameTime != null)
            {
                gamer.fireReceiver.fireReceiveGameTime(PacketGameTime.Value);
            }

            world = new SimWorld();
            if (PacketEnv != null)
            {
                world.Environment = PacketEnv.Value;
            }
            if (PacketGameEvent != null)
            {
                world.GameEvent = PacketGameEvent;
            }
            if (PacketDropItem != null)
            {
                world.DropItem = PacketDropItem;
            }
            if (PacketBonuspot != null)
            {
                world.Bonuspot = PacketBonuspot.Value;
            }
            if (PacketGameResult != null)
            {
                world.GameResult = PacketGameResult;
            }
            if (PacketGamersInfo != null)
            {
                world.GamerInfo = PacketGamersInfo;
            }
            if (PacketBroadcast != null)
            {
                world.Broadcast = PacketBroadcast;
            }
            if (PacketPureData != null)
            {
                world.PureData = PacketPureData;
            }
            if (PacketGameStart != null)
            {
                world.GameStart = PacketGameStart;
            }
            if (PacketGamerSlots != null)
            {
                world.GamerSlots = PacketGamerSlots;
            }
            if (PacketGMGamer != null)
            {
                world.RMGamer = PacketGMGamer;
            }
            if (PacketCountDown != null)
            {
                world.CountDown = PacketCountDown.Value;
            }
            if (PacketGameTime != null)
            {
                world.GameTime = PacketGameTime.Value;
            }
        }