Exemplo n.º 1
0
    // 쿼리 이사를 시작해도 되는가?.
    public QueryHouseMoveStart      cmdQueryHouseMoveStart(string house_name, bool local = true)
    {
        QueryHouseMoveStart query = null;

        do
        {
            query = CharacterRoot.get().queryHouseMoveStart(house_name, local);

            if (query == null)
            {
                break;
            }

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

        return(query);
    }
Exemplo n.º 2
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;
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
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;
        }
    }