Ejemplo n.º 1
0
    // 쿼리 - 이사를 마쳐도 되는가?.
    public QueryHouseMoveEnd        queryHouseMoveEnd(bool local = true)
    {
        QueryHouseMoveEnd query = null;

        do
        {
            query = new QueryHouseMoveEnd();

            this.queries.Add(query);
        } while(false);

        // 이사 종료 요청을 보냅니다.
        GameObject netObj = GameObject.Find("Network");

        if (netObj && local)
        {
            // Network 클래스의 컴포넌트를 획득합니다.
            Network network = netObj.GetComponent <Network>();
            // 이사 종료 요청을 보냅니다.
            MovingData moving = new MovingData();
            moving.characterId = GameRoot.getInstance().account_name_local;
            moving.houseId     = "";
            moving.moving      = false;
            MovingPacket packet = new MovingPacket(moving);
            network.SendReliable <MovingData>(packet);
        }

        return(query);
    }
Ejemplo n.º 2
0
 void OnMoving()
 {
     if (!m_MovingData.OnMoving())
     {
         CancelInvoke("OnMoving");
         onMoveComplete.Invoke(m_MovingData.curCell);
         m_MovingData = null;
     }
 }
Ejemplo n.º 3
0
    // 이동 정보 패킷 획득 함수
    public void OnReceiveMovingPacket(PacketId id, byte[] data)
    {
        MovingPacket packet = new MovingPacket(data);
        MovingData   moving = packet.GetPacket();

        Debug.Log(moving + " 수신완료(마우스).");

        // 수신 후 사용 예
        // navAgent(moving.index).destinaion(new Vector3(moving.destX, moving.destY, moving.dextZ);
    }
Ejemplo n.º 4
0
        //
        public bool Serialize(MovingData packet)
        {
            bool ret = true;

            ret &= Serialize(packet.characterId, MovingData.characterNameLength);
            ret &= Serialize(packet.houseId, MovingData.houseIdLength);
            ret &= Serialize(packet.moving);

            return(ret);
        }
Ejemplo n.º 5
0
        public bool Serialize(MovingData packet)
        {
            bool ret = true;

            ret &= Serialize(packet.index);
            ret &= Serialize(packet.destX);
            ret &= Serialize(packet.destY);
            ret &= Serialize(packet.destZ);

            return(ret);
        }
Ejemplo n.º 6
0
        private void CheckSteps(Dictionary <Point, MovingData> checkedSteps,
                                Point nextStep, int levelNextStep, Point undoStep)
        {
            if (checkedSteps.TryGetValue(nextStep, out var alsoCheckedStep))
            {
                if (alsoCheckedStep.LevelDown <= levelNextStep)
                {
                    return;
                }
            }

            checkedSteps[nextStep] = new MovingData(undoStep, levelNextStep);
        }
Ejemplo n.º 7
0
        private void UpdateMarkedPoints(Dictionary <Point, MovingData> markedPoints,
                                        Point nextPoint, int energyForNextPoint, Point previousPoint)
        {
            if (markedPoints.TryGetValue(nextPoint, out var alreadyMarkedInfo))
            {
                if (alreadyMarkedInfo.WastedEnergy <= energyForNextPoint)
                {
                    return;
                }
            }

            markedPoints[nextPoint] = new MovingData(previousPoint, energyForNextPoint);
        }
Ejemplo n.º 8
0
    // 이동 정보 패킷 획득 함수
    public void OnReceiveMovingPacket(PacketId id, byte[] data)
    {
        MovingPacket packet = new MovingPacket(data);   //바이트 데이터 역직렬
        MovingData   moving = packet.GetPacket();
        // Debug.Log(moving + " 수신완료(이동)");

        Vector3 destination = new Vector3(moving.destX, moving.destY, moving.destZ);

        // 2020 02 01 상대 단말에서 상대의 로컬 캐릭터가 이동했을 때 송신한 정보를 수신한 것이므로 내 단말에서 리모트 캐릭터를 이동시킨다.
        //GameManager.instance.MoveEnemyCharacter(moving.index, destination);
        //// 2020 02 07 상대의 캐릭터의 이동속도 보정값을 저장.
        //remoteAgentSpeed[moving.index] = GameManager.instance.SetInterpolatedSpeed(moving.index, destination);
    }
Ejemplo n.º 9
0
    public bool MoveTo(HexCell destination, int distance = 0)
    {
        if (isMoving)
        {
            Debug.LogError("当前正在移动,不可以发出新的移动指令");
            return(false);
        }

        List <HexCell> path = null;

        if (distance == 0)
        {
            HexRoom.HexCellPaths allPath = LevelManager.room.hexRoom.GetAvailableDestinations(entity.centerCell, m_PropertyComponent.movePoint);
            path = LevelManager.room.hexRoom.FindPath(allPath, entity.centerCell, destination);
            HexRoom.SortPathByDistance(path, destination);
        }
        else
        {
            //和目标保持一定的距离
            int targetDistance = entity.centerCell.GetDistance(destination);
            int moveDistance   = targetDistance - distance;
            moveDistance = moveDistance < 0 ? 0 : moveDistance;
            if (m_PropertyComponent.movePoint < moveDistance)
            {
                Debug.LogError("移动力不足 " + moveDistance);
                return(false);
            }

            HexRoom.HexCellPaths allPath = LevelManager.room.hexRoom.GetAvailableDestinations(entity.centerCell, targetDistance);
            path = LevelManager.room.hexRoom.FindPath(allPath, entity.centerCell, destination);
            HexRoom.SortPathByDistance(path, destination);
            for (int i = 0; i < distance; i++)
            {
                path.RemoveAt(path.Count - 1);
            }
        }

        m_MovingData = new MovingData(path, path[path.Count - 1], entity, m_PropertyComponent);
        if (m_MovingData.BeginMove())
        {
            onBeginMove.Invoke(destination);
            InvokeRepeating("OnMoving", 0f, Config.system.baseTimeDelta);
            return(true);
        }
        else
        {
            m_MovingData = null;
            return(false);
        }
    }
Ejemplo n.º 10
0
        //
        public bool Deserialize(ref MovingData element)
        {
            if (GetDataSize() == 0)
            {
                // 데이터가 설정되어 있지 않습니다.
                return(false);
            }

            bool ret = true;

            ret &= Deserialize(ref element.characterId, MovingData.characterNameLength);
            ret &= Deserialize(ref element.houseId, MovingData.houseIdLength);
            ret &= Deserialize(ref element.moving);

            return(ret);
        }
Ejemplo n.º 11
0
    // 이동정보를 상대에게 전송하는 함수
    // 매개변수는 수정해도 상관 없음.
    // 결과적으로 함수 내 MovingData의 멤버변수를 채워주기만 하면 됨.
    public void SendLocalMovingInfo(int index, Vector3 dest)
    {
        // 이동정보 데이터 생성 후 정보 입력
        MovingData movingData = new MovingData();

        movingData.index = index;
        movingData.destX = dest.x;
        movingData.destY = dest.y;
        movingData.destZ = dest.z;
        Debug.Log("전송 " + movingData);
        // 생성자로 데이터에 패킷을 연결
        MovingPacket packet = new MovingPacket(movingData);

        // UDP 전송
        networkManager.SendUnreliable <MovingData>(packet);
    }
Ejemplo n.º 12
0
        private async Task DoWork(CancellationToken stoppingToken)
        {
            _logger.LogInformation(
                "Consume Scoped Service Hosted Service is working.");

            using (var scope = _provider.CreateScope())
            {
                var context            = scope.ServiceProvider.GetRequiredService <BustronicContext>();
                var movingData         = MovingData.Create(context);
                var movingVehicleInfos = MovingVehicleInfo.Create(movingData);
                var computation        = new Computation(movingData);
                var publisher          = connection.GetSubscriber();

                publisher.Subscribe("message", (channel, message) =>
                {
                    _logger.LogWarning($"channel: {channel}, message: {message}");
                });

                while (!stoppingToken.IsCancellationRequested)
                {
                    _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                    var sw     = Stopwatch.StartNew();
                    var result = computation.compute(movingVehicleInfos);
                    sw.Stop();
                    _logger.LogInformation($"count = {movingVehicleInfos.Count}, elapsed = {sw.ElapsedMilliseconds}");

                    movingVehicleInfos = result.Where(e => e.Error.Equals(String.Empty)).ToList();
                    //movingData.Update(movingVehicleInfos);
                    var toClient = JsonSerializer.Serialize(new
                    {
                        @event = "message",
                        data   = movingVehicleInfos.Select(e => e.ToClient())
                    });
                    publisher.Publish("channels", toClient);

                    var invalid = result.Where(e => !e.Error.Equals(String.Empty)).ToList();
                    if (invalid.Count > 0)
                    {
                        movingData.Remove(invalid);
                        movingData.Insert(invalid);
                        movingVehicleInfos = MovingVehicleInfo.Create(movingData);
                    }

                    await Task.Delay(1000, stoppingToken);
                }
            }
        }
Ejemplo n.º 13
0
        public bool Deserialize(ref MovingData element)
        {
            // 데이터가 정의되어있지 않다면
            if (GetDataSize() == 0)
            {
                return(false);
            }

            bool ret = true;

            ret &= Deserialize(ref element.index);
            ret &= Deserialize(ref element.destX);
            ret &= Deserialize(ref element.destY);
            ret &= Deserialize(ref element.destZ);

            return(ret);
        }
Ejemplo n.º 14
0
    public void     OnReceiveMovingPacket(PacketId id, byte[] data)
    {
        Debug.Log("OnReceiveMovingPacket");

        MovingPacket packet = new MovingPacket(data);
        MovingData   moving = packet.GetPacket();

        Debug.Log("[CharId]" + moving.characterId);
        Debug.Log("[HouseName]" + moving.houseId);
        Debug.Log("[Moving]" + moving.moving);

        chrController remote =
            CharacterRoot.get().findCharacter(moving.characterId);

        // 이사 쿼리 발행.
        if (remote != null)
        {
            if (moving.moving)
            {
                Debug.Log("cmdQueryHouseMoveStart");
                QueryHouseMoveStart query = remote.cmdQueryHouseMoveStart(moving.houseId, false);
                if (query != null)
                {
                    query.set_done(true);
                    query.set_success(true);
                }
            }
            else
            {
                Debug.Log("cmdQueryHouseMoveEnd");
                QueryHouseMoveEnd query = remote.cmdQueryHouseMoveEnd(false);
                if (query != null)
                {
                    query.set_done(true);
                    query.set_success(true);
                }
            }
        }

        // 이사 정보 보존.
        GlobalParam.get().remote_moving = moving;
    }
Ejemplo n.º 15
0
    // 쿼리-이사 시작해도 되는가?.
    public QueryHouseMoveStart      queryHouseMoveStart(string house_name, bool local = true)
    {
        QueryHouseMoveStart query = null;

        do
        {
            chrBehaviorNPC_House house = CharacterRoot.getInstance().findCharacter <chrBehaviorNPC_House>(house_name);

            if (house == null)
            {
                break;
            }

            query = new QueryHouseMoveStart(house_name);

            this.queries.Add(query);
        } while(false);

        // 이사 시작 요청을 보냅니다.
        GameObject netObj = GameObject.Find("Network");

        if (netObj && local)
        {
            // Network 클래스의 컴포넌트 획득합니다.
            Network network = netObj.GetComponent <Network>();
            // 이사 시작 요청을 보냅니다.
            MovingData moving = new MovingData();
            moving.characterId = GameRoot.getInstance().account_name_local;
            moving.houseId     = house_name;
            moving.moving      = true;
            MovingPacket packet = new MovingPacket(moving);
            network.SendReliable <MovingData>(packet);

            // 이사 정보 보존.
            GlobalParam.get().local_moving = moving;
        }

        return(query);
    }
Ejemplo n.º 16
0
 public Computation(MovingData movingData)
 {
     _movingData = movingData;
 }
Ejemplo n.º 17
0
    public override void    execute()
    {
        CameraControl camera = CameraControl.get();

        // ---------------------------------------------------------------- //
        // 다음 상태로 이동할지 체크합니다.

        switch (this.step.do_transition())
        {
        // 이벤트 시작.
        case STEP.START:
        {
            this.step.set_next(STEP.OPEN_DOOR);
            //camera.module.parallelMoveTo(this.get_locator_position("cam_loc_0"));

            Debug.Log("Name:" + this.player.controll.account_name);

            foreach (ItemManager.ItemState istate in GlobalParam.get().item_table.Values)
            {
                Debug.Log("Item:" + istate.item_id + " Own:" + istate.owner + " State:" + istate.state);

                if (istate.owner == this.player.controll.account_name &&
                    istate.state == ItemController.State.Picked)
                {
                    // 이미 아이템을 획득했다면 가지고 갈 수 있게 합니다.
                    ItemManager.get().activeItme(istate.item_id, true);
                    ItemManager.get().finishGrowingItem(istate.item_id);
                    QueryItemPick query = this.player.controll.cmdItemQueryPick(istate.item_id, false, true);
                    if (query != null)
                    {
                        query.is_anon = true;
                        query.set_done(true);
                        query.set_success(true);
                    }
                    ItemManager.get().setVisible(istate.item_id, true);
                }
            }

            // 리모트에서 이사 중은 로컬도 이사합니다.
            do
            {
                MovingData moving = GlobalParam.get().remote_moving;
                if (!moving.moving)
                {
                    break;
                }

                chrController remote = CharacterRoot.get().findCharacter(moving.characterId);
                if (remote == null)
                {
                    break;
                }

                chrBehaviorNet remote_player = remote.behavior as chrBehaviorNet;
                if (remote_player == null)
                {
                    break;
                }

                chrBehaviorNPC_House house = CharacterRoot.getInstance().findCharacter <chrBehaviorNPC_House>(moving.houseId);
                if (house == null)
                {
                    break;
                }

                Debug.Log("House move event call:" + moving.characterId + ":" + moving.houseId);

                remote_player.beginHouseMove(house);

                // '이사중~' 말풍선 표시.
                house.startHouseMove();
            } while(false);
        }
        break;

        // 배추가 옆으로 움직이고 & 대야를 타고 플레이어가 등장.
        case STEP.OPEN_DOOR:
        {
            if (this.hakusai_fcurve.isDone() && this.tarai_fcurve.isDone())
            {
                this.step.set_next(STEP.GET_OFF_TARAI_0);
            }
        }
        break;

        // 대야에서 내립니다(기슭으로 점프).
        case STEP.GET_OFF_TARAI_0:
        {
            if (!this.player_jump.isMoving())
            {
                this.step.set_next(STEP.GET_OFF_TARAI_1);
            }
        }
        break;

        // 대야에서 내립니다(조금 걷기).
        case STEP.GET_OFF_TARAI_1:
        {
            if (!this.player_move.isMoving())
            {
                this.step.set_next(STEP.CLOSE_DOOR);
            }
        }
        break;


        // 배추가 돌아오고 & 대야가 밖으로 이동.
        case STEP.CLOSE_DOOR:
        {
            if (this.hakusai_fcurve.isDone() && this.tarai_fcurve.isDone())
            {
                this.step.set_next(STEP.END);
            }
        }
        break;

        case STEP.END:
        {
            camera.module.popPosture();

            this.step.set_next(STEP.IDLE);
        }
        break;
        }

        // ---------------------------------------------------------------- //
        // 상태가 전환됐을 때의 초기화.

        while (this.step.get_next() != STEP.NONE)
        {
            dbwin.console().print(this.step.ToString());

            switch (this.step.do_initialize())
            {
            // 이벤트 시작.
            case STEP.START:
            {
                camera.module.pushPosture();

                this.player.beginOuterControll();
                this.player.controll.cmdSetPosition(this.tarai_leave_spline.curve.cvs.back().position);

                this.tarai_fune.transform.position = this.tarai_leave_spline.curve.cvs.back().position;

                if (!this.is_local_player)
                {
                    SoundManager.get().playSE(Sound.ID.SMN_JINGLE01);
                }
            }
            break;

            // 배추가 옆으로 이동하고 & 대야를 타고 플레이어가 등장.
            case STEP.OPEN_DOOR:
            {
                this.hakusai_set.setControl(true);
                this.hakusai_fcurve.setSlopeAngle(10.0f, 10.0f);
                this.hakusai_fcurve.setDuration(4.0f);
                this.hakusai_fcurve.start();
                this.hakusai_tracer.restart();

                this.tarai_fcurve.setSlopeAngle(60.0f, 5.0f);
                this.tarai_fcurve.setDuration(3.5f);
                this.tarai_fcurve.setDelay(0.5f);
                this.tarai_fcurve.start();
            }
            break;

            // 대야에서 내립니다(기슭으로 점프).
            case STEP.GET_OFF_TARAI_0:
            {
                Vector3 start = this.player.controll.getPosition();
                Vector3 goal  = this.get_locator_position("chr_loc_0");

                this.player_jump.start(start, goal, 1.0f);
            }
            break;

            // 대야에서 내립니다(조금 걷기).
            case STEP.GET_OFF_TARAI_1:
            {
                this.player_move.position.start = this.player.controll.getPosition();
                this.player_move.position.goal  = this.get_locator_position("chr_loc_1");
                this.player_move.startConstantVelocity(chrBehaviorLocal.MOVE_SPEED);
            }
            break;

            // 배추가 돌아오고 & 대야가 밖으로 이동.
            case STEP.CLOSE_DOOR:
            {
                this.hakusai_fcurve.setSlopeAngle(10.0f, 10.0f);
                this.hakusai_fcurve.setDuration(4.0f);
                this.hakusai_fcurve.setDelay(1.0f);
                this.hakusai_fcurve.start();
                this.hakusai_tracer.restart();
                this.hakusai_tracer.setCurrentByDistance(this.hakusai_tracer.curve.calcTotalDistance());

                this.tarai_tracer.attach(this.tarai_enter_spline.curve);
                this.tarai_tracer.restart();
                this.tarai_fcurve.reset();
                this.tarai_fcurve.setSlopeAngle(10.0f, 60.0f);
                this.tarai_fcurve.setDuration(2.5f);
                this.tarai_fcurve.start();

                this.ripple_effect.is_created = false;
            }
            break;

            case STEP.END:
            {
                // 이벤트 종료.
                this.hakusai_set.reset();
                this.hakusai_set.setControl(false);

                this.player.endOuterControll();

                this.player = null;
            }
            break;
            }
        }

        // ---------------------------------------------------------------- //
        // 각 상태에서의 실행 처리.

        switch (this.step.do_execution(Time.deltaTime))
        {
        // 배추가 옆으로 움직인다 & 대야를 타고 플레이어가 등장..
        case STEP.OPEN_DOOR:
        {
            this.hakusai_fcurve.execute(Time.deltaTime);
            this.hakusai_tracer.proceedToDistance(this.hakusai_tracer.curve.calcTotalDistance() * this.hakusai_fcurve.getValue());
            this.hakusai_set.setPosition(this.hakusai_tracer.cv.position);

            this.tarai_fcurve.execute(Time.deltaTime);
            this.tarai_tracer.proceedToDistance(this.tarai_tracer.curve.calcTotalDistance() * (1.0f - this.tarai_fcurve.getValue()));

            SimpleSpline.ControlVertex cv = this.tarai_tracer.getCurrent();

            this.tarai_fune.setPosition(cv.position);
            this.player.controll.cmdSetPosition(cv.position);
            this.player.controll.cmdSmoothHeadingTo(cv.position - cv.tangent.Y(0.0f));

            if (this.tarai_fcurve.isTriggerDone())
            {
                this.ripple_effect.is_created = false;
            }
        }
        break;

        // 대야에서 내립니다(기슭을 향해 점프).
        case STEP.GET_OFF_TARAI_0:
        {
            this.player_jump.execute(Time.deltaTime);
            this.player.controll.cmdSetPosition(this.player_jump.position);
            this.player.controll.cmdSmoothHeadingTo(this.player_jump.goal);
        }
        break;

        // 대야에서 내립니다(조금 걷는다).
        case STEP.GET_OFF_TARAI_1:
        {
            this.player_move.execute(Time.deltaTime);
            this.player.controll.cmdSetPosition(this.player_move.position.current);
            this.player.controll.cmdSmoothHeadingTo(this.player_move.position.goal);
            this.player.playWalkMotion();
        }
        break;

        // 배추가 돌아옵니다 & 대야가 밖으로 이동.
        case STEP.CLOSE_DOOR:
        {
            this.hakusai_fcurve.execute(Time.deltaTime);
            this.hakusai_tracer.proceedToDistance(this.hakusai_tracer.curve.calcTotalDistance() * (1.0f - this.hakusai_fcurve.getValue()));
            this.hakusai_set.setPosition(this.hakusai_tracer.getCurrent().position);

            this.tarai_fcurve.execute(Time.deltaTime);
            this.tarai_tracer.proceedToDistance(this.tarai_tracer.curve.calcTotalDistance() * (1.0f - this.tarai_fcurve.getValue()));
            this.tarai_fune.transform.position = this.tarai_tracer.getCurrent().position;
            this.player.stopWalkMotion();
        }
        break;
        }

        // 대야 뒤에 나오는 물결.
        if (!this.ripple_effect.is_created || Vector3.Distance(this.ripple_effect.last_position, this.tarai_fune.getPosition()) > 2.0f)
        {
            this.ripple_effect.is_created    = true;
            this.ripple_effect.last_position = this.tarai_fune.transform.position;

            EffectRoot.get().createRipple(this.ripple_effect.last_position);
        }

        // ---------------------------------------------------------------- //
    }