Esempio n. 1
0
    // ================================================================ //
    // 비헤이비어용 커맨드.
    // 쿼리 계통.

    // 쿼리-말하기(말풍선).
    public QueryTalk        queryTalk(string words, bool local = true)
    {
        QueryTalk query = null;

        do
        {
            query = new QueryTalk(words);

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

        GameObject netObj = GameObject.Find("Network");

        if (netObj && local)
        {
            // Network 클래스의 컴포넌트 획득합니다.
            Network network = netObj.GetComponent <Network>();
            // 말풍선 요청을 보냅니다.
            ChatMessage chat = new ChatMessage();
            chat.characterId = GameRoot.getInstance().account_name_local;
            chat.message     = words;
            ChatPacket packet = new ChatPacket(chat);
            network.SendReliable <ChatMessage>(packet);
        }

        return(query);
    }
Esempio n. 2
0
    // ================================================================ //
    // 비헤이비어용 커맨드.
    // 쿼리 계.

    // 쿼리 대화(말풍선).
    public QueryTalk        queryTalk(string account_id, string words, bool is_local)
    {
        QueryTalk query = null;

        do
        {
            query = new QueryTalk(account_id, words);

            if (query == null)
            {
                break;
            }

            QueryManager.get().registerQuery(query);


            if (m_network != null && is_local)
            {
                // 말풍선 요청을 보낸다.
                ChatMessage chat = new ChatMessage();

                chat.characterId = PartyControl.get().getLocalPlayer().getAcountID();
                chat.message     = words;

                ChatPacket packet = new ChatPacket(chat);

                int serverNode = m_network.GetServerNode();
                m_network.SendReliable <ChatMessage>(serverNode, packet);
            }
        } while(false);


        return(query);
    }
Esempio n. 3
0
    public void             execute_queries()
    {
        // 조정이 끝난 쿼리를 찾는다.
        List <QueryBase> queries = QueryManager.get().findDoneQuery(this.control.getAccountID());

        foreach (QueryBase query in queries)
        {
            switch (query.getType())
            {
            case "talk":
            {
                Debug.Log("query talk: " + PartyControl.get().getLocalPlayer().getAcountID());

                if (query.isSuccess())
                {
                    QueryTalk query_talk = query as QueryTalk;

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

            // 용무가 끝났으므로 삭제한다.
            query.set_expired(true);

            if (!query.isSuccess())
            {
                continue;
            }
        }
    }
Esempio n. 4
0
    // 쿼리 대화(말풍선).
    public QueryTalk        cmdQueryTalk(string words, bool local = false)
    {
        QueryTalk query = null;

        do
        {
            query = CharacterRoot.get().queryTalk(words, local);

            if (query == null)
            {
                break;
            }

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

        return(query);
    }
Esempio n. 5
0
    public void     OnReceiveChatMessage(int node, PacketId id, byte[] data)
    {
        Debug.Log("OnReceiveChatMessage");

        ChatPacket  packet = new ChatPacket(data);
        ChatMessage chat   = packet.GetPacket();

        Debug.Log("[CharId]" + chat.characterId);
        Debug.Log("[CharMsg]" + chat.message);


        chrController controller = findPlayer(chat.characterId);

        // 채팅 메시지 표시 쿼리 발행.
        if (controller != null)
        {
            QueryTalk talk = queryTalk(chat.characterId, chat.message, false);
            if (talk != null)
            {
                talk.set_done(true);
                talk.set_success(true);
            }
        }
    }
Esempio n. 6
0
    public void     OnReceiveChatMessage(PacketId id, byte[] data)
    {
        Debug.Log("OnReceiveChatMessage");

        ChatPacket  packet = new ChatPacket(data);
        ChatMessage chat   = packet.GetPacket();

        Debug.Log("{CharId]" + chat.characterId);
        Debug.Log("[CharMsg]" + chat.message);

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

        // 채팅 메시지 표시 쿼리 발행.
        if (remote != null)
        {
            QueryTalk talk = remote.cmdQueryTalk(chat.message);
            if (talk != null)
            {
                talk.set_done(true);
                talk.set_success(true);
            }
        }
    }
Esempio n. 7
0
    // 쿼리  대화(말풍선).
    public QueryTalk        cmdQueryTalk(string words, bool local = false)
    {
        QueryTalk query = CharacterRoot.get().queryTalk(this.getAccountID(), words, local);

        return(query);
    }
Esempio n. 8
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;
        }
    }