Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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();
            });
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            SessionManager.CreateSessionImpl = (sessionId) => new User(sessionId);

            // Datasheet Load
            CommonDatasheet.Load();
            CharacterDatasheet.Load();

            ServerService service = new ServerService();

            service.Start(ServerPort);

            Console.WriteLine("Press any key to terminate the server process....");
            Console.ReadKey();
        }
Exemplo n.º 5
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);
        }