Ejemplo n.º 1
0
    // 레벨 시작 시에 호출.
    public override void            start()
    {
        // 각 플레이어가 케이크를 획득한 수..

        this.cake_counts = new int[NetConfig.PLAYER_MAX];

        for (int i = 0; i < this.cake_counts.Length; i++)
        {
            if (GameRoot.get().isConnected(i))
            {
                this.cake_counts[i] = -1;
            }
            else
            {
                this.cake_counts[i] = 0;
            }
        }

        chrBehaviorLocal local_player = PartyControl.get().getLocalPlayer();

        this.cake_counts[local_player.getGlobalIndex()] = local_player.getCakeCount();

        QueryCakeCount query_cake = new QueryCakeCount(local_player.getAcountID(), local_player.getCakeCount());

        query_cake.timeout = 20.0f;

        QueryManager.get().registerQuery(query_cake);

        // Network 클래스의 컴포넌트 획득.
        GameObject obj = GameObject.Find("Network");

        if (obj != null)
        {
            this.m_network = obj.GetComponent <Network>();

            if (this.m_network != null)
            {
                this.m_network.RegisterReceiveNotification(PacketId.PrizeResult, OnReceivePrizeResultPacket);
            }
        }

        // 케이크 데이터 송신.
        sendPrizeData();

        this.step.set_next(STEP.WAIT_FRIEND);
    }
Ejemplo n.º 2
0
    // ---------------------------------------------------------------- //
    // 케이트 데이터 송수신.

    private void sendPrizeData()
    {
        PrizeData data = new PrizeData();

        chrBehaviorLocal local_player = PartyControl.get().getLocalPlayer();

        Debug.Log("[CLIENT] sendPrizeData");

        // 획득한 케이크 수를 설정.
        data.characterId = local_player.getAcountID();
        data.cakeNum     = local_player.getCakeCount();

        if (this.m_network != null)
        {
            PrizePacket packet = new PrizePacket(data);

            int serverNode = this.m_network.GetServerNode();
            this.m_network.SendReliable <PrizeData>(serverNode, packet);

            Debug.Log("[CLIENT] send cake num[" + data.characterId + "]:" + data.cakeNum);
        }
    }