コード例 #1
0
    public void PlayerReady()
    {
        // this is where we would set the deck to be the one selected in the deck selection dialog
        LobbyController.LocalPlayer.SetDeck(new Deck());

        Debug.Log("Sending deck fragment");
        string deckData = LobbyController.LocalPlayer.Deck.ToString(false);

        MessageTypes.DeckFirstMessage msgFirst = new MessageTypes.DeckFirstMessage();
        msgFirst.deckDataFragment = deckData.Substring(0, Math.Min(deckData.Length, 1024));
        NetworkManager.singleton.client.Send((short)MessageTypes.MessageType.DECK_FIRST, msgFirst);

        for (int i = 1; i * 1024 < deckData.Length; i++)
        {
            Debug.Log("Sending deck fragment");
            MessageTypes.DeckFragmentMessage msgFrag = new MessageTypes.DeckFragmentMessage();
            msgFrag.deckDataFragment = deckData.Substring(i * 1024, Math.Min((deckData.Length - i * 1024), 1024));
            NetworkManager.singleton.client.Send((short)MessageTypes.MessageType.DECK_FRAGMENT, msgFrag);
        }

        Debug.Log("Sending ready message");
        MessageTypes.PlayerReadyMessage msg = new MessageTypes.PlayerReadyMessage();
        NetworkManager.singleton.client.Send((short)MessageTypes.MessageType.PLAYER_READY, msg);

        // disable the button
        var createGameButton = (Button)GameObject.Find("ReadyButton").GetComponent(typeof(Button));

        createGameButton.interactable = false;

        // create placeholder card objects
        for (int i = 0; i < LobbyController.LocalPlayer.Deck.Faction.StartingHandSize; i++)
        {
            Debug.Log("Adding fake card to hand");
            GameViewController.AddUnknownCardToHand();
        }
    }