• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    해결됨

Arrow 함수 에서의 Push 사용

20.10.01 11:55 작성 조회수 139

0

안녕하세요 Arrow의 Update에서 궁금한점이 있어서 문의드립니다.

Arrow.cs에서 LeaveGame을 처리할 때 Push함수를 사용하도록 변경을 했는데 Arrow의 부모클래스인 Projectile의 Update 실행을 GameRoom의 Update 함수내에서  projectile.Update(); 의 호출로 실행해주고 있기 때문에 이미 Push가 Job으로 관리되고 있을것 같습니다.

그렇다면 혹시 Room.Push(Room.LeaveGame, Id); 부분도 Room.LeaveGame(Id); 로 사용해도 되는건지 궁금합니다~!

public override void Update()

        {

            if (Data == null || Data.projectile == null || Owner == null || Room == 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);

                }

                //소멸

                Room.Push(Room.LeaveGame, Id);

            }

답변 1

답변을 작성해보세요.

0

둘다 가능합니다.
이전 질문과 동일한 내용이므로 링크로 대체합니다.

https://www.inflearn.com/questions/71106