Example #1
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);
    }
Example #2
0
 // 집을 설정합니다..
 public void             setHouse(chrBehaviorNPC_House house)
 {
     this.house = house;
 }
Example #3
0
	// 이사 시작.
	public override void		beginHouseMove(chrBehaviorNPC_House house)
	{
		base.beginHouseMove(house);

		this.step.set_next(STEP.HOUSE_MOVE);
	}
Example #4
0
	// 집을 설정합니다..
	public void		setHouse(chrBehaviorNPC_House house)
	{
		this.house = house;
	}
Example #5
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);
        }

        // ---------------------------------------------------------------- //
    }
Example #6
0
    // 이사 시작.
    public override void            beginHouseMove(chrBehaviorNPC_House house)
    {
        base.beginHouseMove(house);

        this.step.set_next(STEP.HOUSE_MOVE);
    }
Example #7
0
    // ================================================================ //

    // 조정을 마친 쿼리 실행.
    protected void          execute_queries()
    {
        foreach (QueryBase query in this.controll.queries)
        {
            if (!query.isDone())
            {
                continue;
            }

            switch (query.getType())
            {
            case "item.pick":
            {
                QueryItemPick query_pick = query as QueryItemPick;

                if (query.isSuccess())
                {
                    // 아이템을 가지고 있으면 버린다.
                    if (this.controll.item_carrier.isCarrying())
                    {
                        Debug.Log("Pick:" + query_pick.target + " Carry:" + this.controll.item_carrier.item.id);
                        if (query_pick.target != this.controll.item_carrier.item.id)
                        {
                            // 상대방 플레이어에게 드롭한 사실을 알려줘야만 하므로 쿼리를 만든다.
                            // 동기화할 필요는 없으므로 드롭은 바로 실행한다.
                            Debug.Log("behavior:cmdItemQueryDrop");

                            QueryItemDrop query_drop = this.controll.cmdItemQueryDrop();

                            query_drop.is_drop_done = true;

                            this.controll.cmdItemDrop(this.controll.account_name);
                        }
                    }

                    this.controll.cmdItemPick(query_pick,this.controll.account_name,query_pick.target);

                    if (!query_pick.is_anon)
                    {
                        SoundManager.get().playSE(Sound.ID.TFT_SE01);
                    }
                }

                query.set_expired(true);
            }
            break;

            case "item.drop":
            {
                if (query.isSuccess())
                {
                    if ((query as QueryItemDrop).is_drop_done)
                    {
                        // 이미 드롭 완료.
                        Debug.Log("[CLIENT CHAR] Item already dropped.");
                    }
                    else
                    {
                        Debug.Log("[CLIENT CHAR] Item dropped.");

                        this.controll.cmdItemDrop(this.controll.account_name);
                    }
                }

                query.set_expired(true);
            }
            break;

            case "house-move.start":
            {
                do
                {
                    if (!query.isSuccess())
                    {
                        break;
                    }

                    QueryHouseMoveStart query_start = query as QueryHouseMoveStart;

                    chrBehaviorNPC_House house = CharacterRoot.get().findCharacter <chrBehaviorNPC_House>(query_start.target);

                    if (house == null)
                    {
                        break;
                    }

                    var start_event = EventRoot.get().startEvent <HouseMoveStartEvent>();

                    start_event.setPrincipal(this);
                    start_event.setHouse(house);
                } while(false);

                query.set_expired(true);
            }
            break;

            case "house-move.end":
            {
                do
                {
                    if (!query.isSuccess())
                    {
                        break;
                    }

                    chrBehaviorNPC_House house = this.step_house_move.house;

                    var end_event = EventRoot.get().startEvent <HouseMoveEndEvent>();

                    end_event.setPrincipal(this);
                    end_event.setHouse(house);
                } while(false);

                query.set_expired(true);
            }
            break;

            case "talk":
            {
                if (query.isSuccess())
                {
                    QueryTalk query_talk = query as QueryTalk;

                    this.controll.cmdDispBalloon(query_talk.words);
                }
                query.set_expired(true);
            }
            break;
            }

            break;
        }
    }
Example #8
0
    // ================================================================ //

    // 이사 시작.
    public virtual void             beginHouseMove(chrBehaviorNPC_House house)
    {
        this.step_house_move.house = house;
    }
Example #9
0
	// ================================================================ //

	// 이사 시작.
	public virtual void		beginHouseMove(chrBehaviorNPC_House house)
	{
		this.step_house_move.house = house;
	}