コード例 #1
0
        private void Handler_C_MOVE_START(IPacket packet)
        {
            if (status != UserStatus.InGame)
            {
                return;
            }

            if (MachingRoom.CurrentUser != this)
            {
                return;
            }

            C_MOVE_START moveStart = (C_MOVE_START)packet;

            if (moveStart.GameId != SessionId)
            {
                return;
            }

            S_MOVE moveEnd = new S_MOVE();

            moveEnd.GameId   = SessionId;
            moveEnd.Position = moveStart.Position;

            MachingRoom.Broadcast(moveEnd);

            SendEndAction();
        }
コード例 #2
0
        private void Handler_C_REQUEST_PLAYER_STATUS(IPacket packet)
        {
            C_REQUEST_PLAYER_STATUS receivePacket = (C_REQUEST_PLAYER_STATUS)packet;

            int  requestGameId = receivePacket.GameId;
            User user          = MachingRoom.GetUser(requestGameId);

            if (user == null)
            {
                return;
            }

            S_PLAYER_STATUS sendPacket = new S_PLAYER_STATUS();

            sendPacket.GameId      = user.SessionId;
            sendPacket.CharacterId = user.Character.Index;
            sendPacket.ShipId      = 0;
            sendPacket.Hp          = (int)CommonDatasheet.GetValue(CommonType.Hp) + user.Character.HpBouns;
            sendPacket.Battle      = (int)CommonDatasheet.GetValue(CommonType.Battle) + user.Character.BattleBouns;
            sendPacket.Hit         = (int)CommonDatasheet.GetValue(CommonType.Hit) + user.Character.HitBouns;
            sendPacket.Move        = (int)CommonDatasheet.GetValue(CommonType.Move) + user.Character.MoveBouns;
            sendPacket.Range       = (int)CommonDatasheet.GetValue(CommonType.Range) + user.Character.RangeBouns;

            if (Ship != null)
            {
                sendPacket.ShipId  = user.Ship.Index;
                sendPacket.Hp     += user.Ship.HpBouns;
                sendPacket.Battle += user.Ship.BattleBouns;
                sendPacket.Hit    += user.Ship.HitBouns;
                sendPacket.Move   += user.Ship.MoveBouns;
                sendPacket.Range  += user.Ship.RangeBouns;
            }

            MachingRoom.Broadcast(sendPacket);
        }
コード例 #3
0
        private static void ActionPhase(MachingRoom room, User user)
        {
            S_START_USER_TURN packet = new S_START_USER_TURN();

            packet.GameId    = room.CurrentUser.SessionId;
            room.ActionCount = (int)CommonDatasheet.GetValue(CommonType.PlyearAction);

            room.Broadcast(packet);
        }
コード例 #4
0
        private void Handler_C_START_DICE(IPacket packet)
        {
            if (status != UserStatus.InGame)
            {
                return;
            }

            C_START_DICE dice = (C_START_DICE)packet;

            if (dice.GameId != MachingRoom.AttackerId || dice.GameId != MachingRoom.DefenderId)
            {
                return;
            }

            Random random         = new Random();
            double value          = random.Next(100);
            double successPersent = MachingRoom.IsRangedAttack ? CommonDatasheet.GetValue(CommonType.HitCheck) : CommonDatasheet.GetValue(CommonType.BattleCheck);
            bool   successed      = value < successPersent;

            if (MachingRoom.AttackerId == dice.GameId)
            {
                MachingRoom.AttackerValue += (successed ? 1 : 0);
                --MachingRoom.AttackCount;
            }
            else if (MachingRoom.DefenderId == dice.GameId)
            {
                MachingRoom.DefenderValue += (successed ? 1 : 0);
                --MachingRoom.DefenceCount;
            }

            S_DICE_RESULT result = new S_DICE_RESULT();

            result.GameId    = dice.GameId;
            result.Successed = value < successPersent;

            MachingRoom.Broadcast(result);

            DoAsync(() =>
            {
                S_END_FIGHT endFight   = new S_END_FIGHT();
                endFight.AttackerId    = MachingRoom.AttackerId;
                endFight.AttackerValue = MachingRoom.AttackerValue;
                endFight.DefenderId    = MachingRoom.DefenderId;
                endFight.DefenderValue = MachingRoom.DefenderValue;

                MachingRoom.Broadcast(endFight);

                SendEndAction();
            });
        }
コード例 #5
0
        private void SendEndAction()
        {
            DoAsync(() =>
            {
                S_END_ACTION endAction = new S_END_ACTION();
                endAction.GameId       = SessionId;

                Send(endAction);

                DoAsync(() =>
                {
                    --MachingRoom.ActionCount;
                    if (MachingRoom.ActionCount == 0)
                    {
                        MachingRoom.NextUser();

                        S_END_USER_TURN endTurn = new S_END_USER_TURN();
                        endTurn.GameId          = SessionId;
                        endTurn.NextUserGameId  = MachingRoom.CurrentUser.SessionId;

                        MachingRoom.Broadcast(endTurn);

                        DoAsync(() =>
                        {
                            if (MachingRoom.AllUserEndTurn.All(isEnd => isEnd == true))
                            {
                                MachingRoom.DoAsyncAll((user) =>
                                {
                                    S_END_PHASE endPhase = new S_END_PHASE();
                                    endPhase.GameId      = user.SessionId;
                                    endPhase.NextPhase   = (int)PhaseType.Weather;

                                    user.Send(endPhase);
                                });
                            }
                        });
                    }
                });
            });
        }
コード例 #6
0
        private void Handler_C_SELECT_SHIP(IPacket packet)
        {
            if (status != UserStatus.InGame)
            {
                return;
            }

            C_SELECT_SHIP receive = (C_SELECT_SHIP)packet;

            if (receive.GameId == SessionId)
            {
                Ship = CharacterDatasheet.FindTemplate(receive.ShipId);
            }

            S_PLAYER_SHIP send = new S_PLAYER_SHIP();

            send.GameId        = receive.GameId;
            send.ShipId        = receive.ShipId;
            send.StartPosition = CharacterDatasheet.FindTemplate(receive.ShipId).Start;

            MachingRoom.Broadcast(send);
        }
コード例 #7
0
        private void Handler_C_START_ATTACK(IPacket packet)
        {
            if (status != UserStatus.InGame)
            {
                return;
            }

            if (MachingRoom.CurrentUser != null)
            {
                return;
            }

            C_START_ATTACK attackInfo = (C_START_ATTACK)packet;

            if (attackInfo.AttackterId != SessionId)
            {
                return;
            }

            User attacker = MachingRoom.GetUser(attackInfo.AttackterId);

            MachingRoom.AttackerId    = attackInfo.AttackterId;
            MachingRoom.AttackerValue = 0;
            MachingRoom.AttackCount   = (int)CommonDatasheet.GetValue(CommonType.Battle) + attacker.Character.BattleBouns + attacker.Ship.BattleBouns;

            User defender = MachingRoom.GetUser(attackInfo.DefenderId);

            MachingRoom.DefenderId    = attackInfo.DefenderId;
            MachingRoom.DefenderValue = attackInfo.DefenderId;
            MachingRoom.DefenceCount  = (int)CommonDatasheet.GetValue(CommonType.Battle) + defender.Character.BattleBouns + defender.Ship.BattleBouns;

            S_START_FIGHT fight = new S_START_FIGHT();

            fight.AttackerId = attackInfo.AttackterId;
            fight.DefenderId = attackInfo.DefenderId;

            MachingRoom.Broadcast(fight);
        }