Esempio n. 1
0
    public void     OnReceiveAttackPacket(int node, PacketId id, byte[] data)
    {
        AttackPacket packet = new AttackPacket(data);
        AttackData   attack = packet.GetPacket();

        //Debug.Log("[CLIENT] Receive Attack packet:" + attack.characterId);

        chrController controller = findPlayer(attack.characterId);

        if (controller == null)
        {
            return;
        }

        // 캐릭터 좌표 보간.
        chrBehaviorNet behavior = controller.behavior as chrBehaviorNet;

        if (behavior != null)
        {
            if (attack.attackKind == 0)
            {
                behavior.cmdShotAttack();
            }
            else
            {
                behavior.cmdMeleeAttack();
            }
        }
    }
Esempio n. 2
0
    // 네트 플레이어 만들기.
    public void             createNetPlayer(int account_global_index)
    {
        chrBehaviorLocal local_player = this.players[0].GetComponent <chrBehaviorLocal>();

        chrBehaviorNet net_player = null;

        int local_index = this.players.Count;

        AccountData account_data = AccountManager.get().getAccountData(account_global_index);

        string avator_name = "Player_" + account_data.avator_id;

        net_player = CharacterRoot.getInstance().createPlayerAsNet(avator_name).GetComponent <chrBehaviorNet>();

        net_player.control.local_index  = local_index;
        net_player.control.global_index = account_global_index;
        net_player.local_player         = local_player;

        net_player.position_in_formation = this.getInFormationOffset(account_global_index);

        SHOT_TYPE shot_type = GlobalParam.get().shot_type[account_global_index];

        net_player.changeBulletShooter(shot_type);

        net_player.transform.Translate(this.getLocalPlayer().control.getPosition() + net_player.position_in_formation);

        this.players.Add(net_player);
    }
Esempio n. 3
0
    protected void          create_debug_window()
    {
        var window = dbwin.root().createWindow("query");

        window.createButton("줍는다")
        .setOnPress(() =>
        {
            chrBehaviorLocal player = CharacterRoot.get().findCharacter <chrBehaviorLocal>(GameRoot.getInstance().account_name_local);

            player.controll.cmdItemQueryPick("Tarai");
        });

        window.createButton("버린다")
        .setOnPress(() =>
        {
            chrBehaviorLocal player = CharacterRoot.get().findCharacter <chrBehaviorLocal>(GameRoot.getInstance().account_name_local);

            player.controll.cmdItemQueryDrop();
        });

        window.createButton("말풍선")
        .setOnPress(() =>
        {
            //chrBehaviorLocal	player = CharacterRoot.get().findCharacter<chrBehaviorLocal>(GameRoot.getInstance().account_name_local);
            chrBehaviorNet player = CharacterRoot.get().findCharacter <chrBehaviorNet>("Daizuya");

            player.controll.cmdQueryTalk("멀리 있는 사람과 Talk한다", true);
        });

        window.createButton("이사 시작")
        .setOnPress(() =>
        {
            chrBehaviorLocal player = CharacterRoot.get().findCharacter <chrBehaviorLocal>(GameRoot.getInstance().account_name_local);
            //chrBehaviorNet		player = CharacterRoot.get().findCharacter<chrBehaviorNet>(GameRoot.getInstance().account_name_net);

            player.controll.cmdQueryHouseMoveStart("House1");
        });

        window.createButton("이사 끝")
        .setOnPress(() =>
        {
            chrBehaviorLocal player = CharacterRoot.get().findCharacter <chrBehaviorLocal>(GameRoot.getInstance().account_name_local);
            //chrBehaviorNet		player = CharacterRoot.get().findCharacter<chrBehaviorNet>(GameRoot.getInstance().account_name_net);

            player.controll.cmdQueryHouseMoveEnd();
        });
    }
Esempio n. 4
0
    public void     OnReceiveCharacterPacket(PacketId id, byte[] data)
    {
        CharacterDataPacket packet   = new CharacterDataPacket(data);
        CharacterData       charData = packet.GetPacket();

        if (GlobalParam.get().is_in_my_home != GlobalParam.get().is_remote_in_my_home)
        {
            return;
        }

        chrBehaviorNet remote = CharacterRoot.get().findCharacter <chrBehaviorNet>(charData.characterId);

        if (remote != null)
        {
            remote.CalcCoordinates(charData.index, charData.coordinates);
        }
    }
Esempio n. 5
0
    // ---------------------------------------------------------------- //

    public void     OnReceiveCharacterPacket(int node, PacketId id, byte[] data)
    {
        CharacterDataPacket packet   = new CharacterDataPacket(data);
        CharacterData       charData = packet.GetPacket();

        chrController controller = findPlayer(charData.characterId);

        if (controller == null)
        {
            return;
        }

        // 캐릭터 좌표 보간.
        chrBehaviorNet behavior = controller.behavior as chrBehaviorNet;

        if (behavior != null)
        {
            behavior.CalcCoordinates(charData.index, charData.coordinates);
        }
    }
Esempio n. 6
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);
        }

        // ---------------------------------------------------------------- //
    }
Esempio n. 7
0
    protected void          create_debug_window()
    {
        var window = dbwin.root().createWindow("query");

        window.createButton("select.done")
        .setOnPress(() =>
        {
            for (int i = 0; i < NetConfig.PLAYER_MAX; i++)
            {
                var query = new QuerySelectDone(AccountManager.get().getAccountData(i).account_id);

                QueryManager.get().registerQuery(query);
            }
        });
        window.createButton("select.finish")
        .setOnPress(() =>
        {
            var query = new QuerySelectFinish("Daizuya");

            QueryManager.get().registerQuery(query);
        });

        window.createButton("summon dog")
        .setOnPress(() =>
        {
            QuerySummonBeast query_summon = new QuerySummonBeast("Daizuya", "Dog");

            QueryManager.get().registerQuery(query_summon);
        });

        window.createButton("summon neko")
        .setOnPress(() =>
        {
            QuerySummonBeast query_summon = new QuerySummonBeast("Daizuya", "Neko");

            QueryManager.get().registerQuery(query_summon);
        });

        window.createButton("cake count")
        .setOnPress(() =>
        {
            for (int i = 0; i < PartyControl.get().getFriendCount(); i++)
            {
                chrBehaviorPlayer friend = PartyControl.get().getFriend(i);

                QueryCakeCount query_cake = new QueryCakeCount(friend.getAcountID(), (i + 1) * 10);

                QueryManager.get().registerQuery(query_cake);
            }
        });

#if false
        window.createButton("버린다")
        .setOnPress(() =>
        {
            chrBehaviorLocal player = CharacterRoot.get().findCharacter <chrBehaviorLocal>(GameRoot.getInstance().account_name_local);

            player.controll.cmdItemQueryDrop();
        });

        window.createButton("말풍선")
        .setOnPress(() =>
        {
            //chrBehaviorLocal	player = CharacterRoot.get().findCharacter<chrBehaviorLocal>(GameRoot.getInstance().account_name_local);
            chrBehaviorNet player = CharacterRoot.get().findCharacter <chrBehaviorNet>("Daizuya");

            player.controll.cmdQueryTalk("멀리 있는 사람과 Talk한다", true);
        });
#endif
    }