public static void C_MoveHandler(PacketSession session, IMessage packet)
    {
        C_Move        movePacket    = packet as C_Move;
        ClientSession clientSession = session as ClientSession;

        //Console.WriteLine($"C_Move({movePacket.PosInfo.PosX}, {movePacket.PosInfo.PosY})");

        if (clientSession.MyPlayer == null)
        {
            return;
        }
        if (clientSession.MyPlayer.Room == null)
        {
            return;
        }

        //TODO : 검증
        //서버에서 좌표 이동
        PlayerInfo info = clientSession.MyPlayer.Info;

        info.PosInfo = movePacket.PosInfo;

        //다른 플레이어한테도 알려준다
        S_Move resMovePacket = new S_Move();

        resMovePacket.PlayerId = clientSession.MyPlayer.Info.PlayerId;
        resMovePacket.PosInfo  = movePacket.PosInfo;

        clientSession.MyPlayer.Room.Broadcast(resMovePacket);
    }
Esempio n. 2
0
        public void HandleMove(Player player, C_Move movePacket)
        {
            if (player == null)
            {
                return;
            }

            // 일단 서버에서 좌표 이동
            PositionInfo MovePosinfo = movePacket.PosInfo;
            ObjectInfo   info        = player.Info;

            // 다른 좌표로 이동할 경우, 갈 수 있는지 체크
            if (MovePosinfo.PosX != info.PosInfo.PosX || MovePosinfo.PosY != info.PosInfo.PosY)
            {
                if (_Map.CanGo(new Vector2int(MovePosinfo.PosX, MovePosinfo.PosY)) == false)
                {
                    return;
                }
            }

            info.PosInfo.State   = MovePosinfo.State;
            info.PosInfo.Movedir = MovePosinfo.Movedir;
            _Map.ApplyMove(player, new Vector2int(MovePosinfo.PosX, MovePosinfo.PosY));

            // 다른 플레이어한테도 알려준다.
            S_Move resMovePacket = new S_Move();

            resMovePacket.ObjectId = player.Info.ObjectId;
            resMovePacket.PosInfo  = movePacket.PosInfo;

            BroadCast(resMovePacket);
        }
Esempio n. 3
0
        public override void Update()
        {
            if (Data == null || Data.projectile == null || Owner == null || Room == null)
            {
                return;
            }

            int tick = (int)(1000 / Data.projectile.speed);

            Room.PushAfter(tick, Update);

            Vector2Int destPos = GetFrontCellPos();

            if (Room.Map.ApplyMove(this, destPos, collision: false))
            {
                S_Move movePacket = new S_Move();
                movePacket.ObjectId = Id;
                movePacket.PosInfo  = PosInfo;
                Room.Broadcast(CellPos, movePacket);

                //Console.WriteLine("Move Arrow");
            }
            else
            {
                GameObject target = Room.Map.Find(destPos);
                if (target != null)
                {
                    target.OnDamaged(this, Data.damage + Owner.TotalAttack);
                }

                // 소멸
                Room.Push(Room.LeaveGame, Id);
            }
        }
Esempio n. 4
0
    // 이동패킷
    public static void S_MoveHandler(PacketSession session, IMessage packet)
    {
        S_Move movePacket = packet as S_Move;

        GameObject go = Managers.Object.FindById(movePacket.ObjectId);

        if (go == null)
        {
            return;
        }

        // 내 이동은 이미 클라에서 처리했는데, 굳이 서버에서 콜백을 받아다가 덮어쓸 이유는 없지않을까?
        // 난 이미 이동했지만 서버는 직전 좌표를 던져줘서 나를 강제로 이전 좌표에 이동시킬수가 있다.
        // 조작중인 플레이어의 이동은 전적으로 클라이언트에 의지한다 서버는 통보만 받음
        if (Managers.Object.MyPlayer.Id == movePacket.ObjectId)
        {
            return;
        }

        // 정보를 고치기 위해 CreatureController에 접근
        BaseController bc = go.GetComponent <BaseController>();

        if (bc == null)
        {
            return;             // or crash
        }
        bc.PosInfo = movePacket.PosInfo;
    }
Esempio n. 5
0
    public static void S_MoveHandler(PacketSession session, IMessage packet)// 무언가 이동
    {
        S_Move movePacket = packet as S_Move;

        GameObject go = Managers.Object.Find(movePacket.ObjectId);

        if (go == null)
        {
            return;
        }


        if (movePacket.ObjectId == Managers.Object.MyPlayer.Id)
        {
            return;
        }

        BaseController bc = go.GetComponent <BaseController>();

        if (bc == null)
        {
            return;
        }

        //Debug.Log($"S_MoveHandler ::\n\t{cc.gameObject.name} :: CellPos ({cc.PosInfo.PosX},{cc.PosInfo.PosY}) | Dir : {cc.PosInfo.MoveDir}");
        bc.PosInfo = movePacket.PosInfo;
    }
Esempio n. 6
0
    public static void S_MoveHandler(PacketSession session, IMessage packet)
    {
        S_Move movePacket = packet as S_Move;

        GameObject go = Managers.Object.FindById(movePacket.ObjectId);

        if (go == null)
        {
            return;
        }

        if (Managers.Object.MyPlayer.Id == movePacket.ObjectId)
        {
            return;
        }

        BaseController bc = go.GetComponent <BaseController>();

        if (bc == null)
        {
            return;
        }

        bc.PosInfo = movePacket.PosInfo;
    }
        public void HandleMove(Player player, C_Move movePacket)
        {
            if (player == null)
            {
                return;
            }

            // TODO : 검증
            PositionInfo movePosInfo = movePacket.PosInfo;
            ObjectInfo   info        = player.Info;

            // 다른 좌표로 이동할 경우, 갈 수 있는지 체크
            if (movePosInfo.PosX != info.PosInfo.PosX || movePosInfo.PosY != info.PosInfo.PosY)
            {
                if (Map.CanGo(new Vector2Int(movePosInfo.PosX, movePosInfo.PosY)) == false)
                {
                    return;
                }
            }

            info.PosInfo.State   = movePosInfo.State;
            info.PosInfo.MoveDir = movePosInfo.MoveDir;
            Map.ApplyMove(player, new Vector2Int(movePosInfo.PosX, movePosInfo.PosY));

            // 다른 플레이어한테도 알려준다
            S_Move resMovePacket = new S_Move();

            resMovePacket.ObjectId = player.Info.ObjectId;
            resMovePacket.PosInfo  = movePacket.PosInfo;

            Broadcast(resMovePacket);
        }
    public static void S_MoveHandler(PacketSession session, IMessage packet)
    {
        S_Move        MovePacket    = packet as S_Move;
        ServerSession serverSession = session as ServerSession;


        GameObject go = Managers.Object.FindById(MovePacket.ObjectId);

        if (go == null)
        {
            return;
        }

        // 다른 플레이어의 좌표만 갱신해줍니다.
        // 서버의 프레임으로 인해 좌표 밀려나는 현상을 방지
        if (Managers.Object.MyPlayer.Id == MovePacket.ObjectId)
        {
            return;
        }

        BaseController bc = go.GetComponent <BaseController>();

        if (bc == null)
        {
            return;
        }

        bc.PosInfo = MovePacket.PosInfo;
    }
        void BroadcastMove()
        {
            // 다른 플레이어한테도 알려준다
            S_Move movePacket = new S_Move();

            movePacket.ObjectId = Id;
            movePacket.PosInfo  = PosInfo;
            Room.Broadcast(movePacket);
        }
 // Start is called before the first frame update
 void Start()
 {
     enemy_Generator        = this.gameObject.GetComponent <EnemyGenerator>();
     object_Generator       = this.gameObject.GetComponent <ObjectCreater>();
     s_move                 = GameObject.FindGameObjectWithTag("Player").GetComponent <S_Move>();
     is_dead_gameManager    = false;
     this.next_step         = STEP.PLAY;
     this.guistyle.fontSize = 30;
 }
Esempio n. 11
0
        void BroadCastMove()
        {
            // 다른 플레이어에게 알려주기
            S_Move movePacket = new S_Move();

            movePacket.ObjectId = Id;
            movePacket.PosInfo  = PosInfo;
            Room.Broadcast(CellPos, movePacket);
        }
Esempio n. 12
0
        void BroadCastMove()
        {
            // 다른 플레이어에게 알려줍니다.
            S_Move movePacket = new S_Move();

            movePacket.ObjectId = Id;
            movePacket.PosInfo  = PosInfo;

            Room.BroadCast(movePacket);
        }
Esempio n. 13
0
        void BroadcastMove()
        {
            S_Move movePacket = new S_Move
            {
                ObjectId = Id,
                PosInfo  = PosInfo
            };

            Room.Broadcast(movePacket);
        }
Esempio n. 14
0
        // 무조건 게임 전체 틱을 따라갈 이유가 없다
        public override void Update()
        {
            if (Data == null || Data.projectile == null || Owner == null || Room == null)
            {
                return;
            }

            if (_nextMoveTick >= Environment.TickCount64)
            {
                return;
            }

            // 틱돌아옴
            // speed 는 1초에 움직일수 있는 칸의 개수
            // 1초는 1000ms니까 이걸 speed 값으로 나눠서
            // 다음 1칸 이동까지 내가 얼마나 기다려야 하는지(ms) 구함
            long tick = (long)(1000 / Data.projectile.speed);

            _nextMoveTick = Environment.TickCount64 + tick;

            // 1칸 이동 처리
            Vector2Int destPos = GetFrontCellPos(); // 내가 진행하는 방향의 바로 앞 좌표

            if (Room.Map.CanGo(destPos))
            {
                CellPos = destPos;

                S_Move movePacket = new S_Move();
                movePacket.ObjectId = Id;
                movePacket.PosInfo  = PosInfo;
                Room.Broadcast(movePacket);

                Console.WriteLine("Move Arrow");
            }
            else
            {
                // 화살이 가다 막힘
                GameObject target = Room.Map.Find(destPos);
                // 벽이 아니고 게임 캐릭터였으면?
                if (target != null)
                {
                    // 아야 -> 피를 어디서 깎을거냐? -> 맞은쪽이 처리 (맞은쪽의 스펙(버프) 계산때문에 얻어맞은쪽이 직접 처리하는게 편함)
                    // 공격자 자체를 넣을지 나를 때린 오브젝트를 넣을지?
                    // 여기서는 공격자 자체를 넣었는데, owner변수로 누가 공격했는지도 알 수 있다
                    target.OnDamaged(this, Data.damage + Owner.Stat.Attack);
                    Console.WriteLine($"Damage : {Data.damage + Owner.Stat.Attack}");
                }

                // 벽쾅 -> 소멸
                Room.Push(Room.LeaveGame, Id);
            }
        }
Esempio n. 15
0
        public override void Update()
        {
            if (Data == null || Owner == null || Room == null)
            {
                return;
            }

            if (Data.projectile == null)
            {
                return;
            }

            if (_nextMoveTick >= Environment.TickCount64)
            {
                return;
            }

            long tick = (long)(1000 / Data.projectile.speed);

            _nextMoveTick = Environment.TickCount64 + tick;

            Vector2int destPos = GetFrontCellPos();

            if (Room._Map.CanGo(destPos))
            {
                CellPos = destPos;

                S_Move movePacket = new S_Move();
                movePacket.ObjectId = Id;
                movePacket.PosInfo  = PosInfo;
                Room.BroadCast(movePacket);

                Console.WriteLine("Move Arrow");
            }
            else
            {
                GameObject target = Room._Map.Find(destPos);
                if (target != null)
                {
                    // 피격 판정
                    target.OnDamaged(this, Data.damage + Owner.Stat.Attack);
                    //Console.WriteLine($"damage : {Data.damage}");
                }

                // 소멸
                Room.Push(Room.LeaveGame, Id);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Finds the best move in the moveList looping from the parameter index
        /// to the end of the MoveList. It then swaps the best move with the
        /// move at the index moveNum.
        /// </summary>
        /// <param name="moveNum"></param>
        /// <param name="list"></param>
        public void PickNextMove(int moveNum, MoveList list)
        {
            int bestScore = 0;
            int bestIndex = moveNum;

            // Find the best move.
            for (int i = moveNum; i < list.Count; ++i)
            {
                int tempScore = list.Moves[i].Score;
                if (tempScore > bestScore)
                {
                    bestIndex = i;
                    bestScore = tempScore;
                }
            }

            // Swaps the values in the list.
            S_Move tempMove = list.Moves[moveNum];

            list.Moves[moveNum].Move = list.Moves[bestIndex].Move;
            list.Moves[bestIndex]    = tempMove;
        }
Esempio n. 17
0
        public override void Update()
        {
            // 유효성 검사
            if (Data == null || Data.projectile == null || Owner == null || Room == null)
            {
                return;
            }

            int tick = (int)(1000 / Data.projectile.speed); // 1초에 speed칸만큼 움직임

            Room.PushAfter(tick, Update);                   // 자기 자신을 예약

            // TODO 앞으로 나가기 / 뿌려주기
            Vector2Int destPos = GetFrontCellPos();

            if (Room.Map.ApplyMove(this, destPos, collision: false) == true)
            {
                S_Move movePacket = new S_Move();
                movePacket.ObjectId = Id;
                movePacket.PosInfo  = PosInfo;
                Room.Broadcast(CellPos, movePacket);

                //Console.WriteLine("Move Arrow");
            }
            else
            {
                GameObject target = Room.Map.Find(destPos);
                if (target != null)
                {
                    // 피격판정
                    //Console.WriteLine($"{target.Info.Name}  Damaged : {Data.damage}");
                    target.OnDamaged(this, Data.damage + Owner.TotalAttack);
                }
                // 소멸
                //Room.LeaveGame(Id);
                Room.Push(Room.LeaveGame, Id);
            }
        }
Esempio n. 18
0
        public void HandleMove(Player player, C_Move movePacket)
        {
            if (player == null)
            {
                return;
            }

            // 검증
            PositionInfo movePosInfo = movePacket.PosInfo; // 이동하려는 목적지 좌표
            ObjectInfo   info        = player.Info;        // 이동하기 전의 플레이어 좌표

            // 다른 좌표로 이동할 경우, 갈 수 있는지 체크
            if (movePosInfo.PosX != info.PosInfo.PosX || movePosInfo.PosY != info.PosInfo.PosY)
            {
                if (Map.CanGo(new Vector2Int(movePosInfo.PosX, movePosInfo.PosY)) == false)
                {
                    return; // 플레이어가 가려고 요청한 곳에 갈 수 있는지를 실제 맵 데이터와 대조
                }
            }

            // 좌표가 바뀌지 않고 상태만 바뀌었을 경우 아래만 실행
            info.PosInfo.State   = movePosInfo.State;
            info.PosInfo.MoveDir = movePosInfo.MoveDir;
            // 이동하는 부분을 GameRoom에서 하지않고 map 클래스에서 처리
            // 왜냐면 map이 들고있는 플레이어 좌표 배열에 가서 기존 위치를 null 처리하고
            // 이동시켜야 하기 떄문에 map클래스 안에서 하는게 편하다
            Map.ApplyMove(player, new Vector2Int(movePosInfo.PosX, movePosInfo.PosY)); // 맵에다가 나를 이동시켜달라 요청

            // 다른 플레이어에게도 알려준다
            S_Move resMovePacket = new S_Move();

            resMovePacket.ObjectId = player.Info.ObjectId; // 움직이는 사람의 id
            resMovePacket.PosInfo  = movePacket.PosInfo;

            Broadcast(resMovePacket); // 들어와있는 모든 유저에게 알림
        }
Esempio n. 19
0
 public static void S_MoveHandler(PacketSession session, IMessage packet)// 무언가 이동
 {
     S_Move movePacket = packet as S_Move;
 }