Beispiel #1
0
    public void OnClickStart()
    {
        // monobitView.RPC("StartGame", MonobitTargets.All);
        if (MonobitNetwork.isHost) // ホスト側なので、ゲームスタートボタンの処理
        {
            int length = MonobitNetwork.playerList.Length;
            for (int i = 0; i < MonobitNetwork.playerList.Length; ++i)
            {
                if ((bool)MonobitNetwork.playerList[i].customParameters["ready"] == false)
                {
                    Debug.Log(MonobitNetwork.playerList[i].name + "is not ready.");

                    return;
                }
            }
            monobitView.RPC("StartGame", MonobitTargets.All);
            Debug.Log("Game Start!");
        }
        else // ゲスト側なので、Readyボタンの処理
        {
            Hashtable playerCustomParam = MonobitNetwork.player.customParameters;

            playerCustomParam["ready"] = ((bool)playerCustomParam["ready"] == true) ? false : true;

            MonobitNetwork.SetPlayerCustomParameters(playerCustomParam);
        }
    }
Beispiel #2
0
    public void OnHostChanged(MonobitPlayer newHost)
    {
        // 新しくホストになったプレイヤーが自分で無ければ処理は不要
        if (!MonobitNetwork.isHost)
        {
            return;
        }

        // ホストに変更があったのでプレイヤーの情報を更新する
        int length = m_PlayerInfos.Length;

        for (int i = 0; i < length; ++i)
        {
            PlayerInfoGUI plyaerInfo = m_PlayerInfos[i].GetComponent <PlayerInfoGUI>();

            plyaerInfo.InfoUpdate();
        }

        Hashtable playerCustomParam = MonobitNetwork.player.customParameters;

        playerCustomParam["ready"] = true;
        MonobitNetwork.SetPlayerCustomParameters(playerCustomParam);

        string startButtonText = MonobitNetwork.isHost ? "Start" : "Ready";

        m_Start.transform.Find("Text").GetComponent <Text>().text = startButtonText;
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        if (!MonobitNetwork.inRoom)
        {
            Debug.Log("ルームに入っていない");
            return;
        }
        Hashtable playerCustomParams = new Hashtable();

        playerCustomParams["ready"] = MonobitNetwork.isHost;
        MonobitNetwork.SetPlayerCustomParameters(playerCustomParams);

        string startButtonText = MonobitNetwork.isHost ? "Start" : "Ready";

        m_Start.transform.Find("Text").GetComponent <Text>().text = startButtonText;


        m_RoomMemberCountObj = Instantiate(Resources.Load("uGUI_Text")) as GameObject;
        m_RoomMemberCountObj.transform.SetParent(m_Canvas.transform);
        m_RoomMemberCountObj.transform.localPosition = new Vector3(0, 0, 0);
        UpdatePlayersCount();

        // ルームに入れるプレイヤーの最大数分だけプレイヤー情報表示を作成する
        m_PlayerInfos = new GameObject[MonobitNetwork.room.maxPlayers];
        for (int i = 0; i < MonobitNetwork.room.maxPlayers; ++i)
        {
            // PlayerInfoGUI.csが追加されたPrefabをインスタンス化
            m_PlayerInfos[i] = Instantiate(Resources.Load("PlayerInfoGUI")) as GameObject;
            m_PlayerInfos[i].transform.SetParent(m_Canvas.transform);
            m_PlayerInfos[i].transform.localPosition = new Vector3(0, -24 * i - 24, 0);
        }

        // 作成したプレイヤー情報表示に参加プレイヤーの情報を設定
        int length = MonobitNetwork.playerList.Length;

        for (int i = 0; i < length; ++i)
        {
            m_PlayerInfos[i].GetComponent <PlayerInfoGUI>().Set(MonobitNetwork.playerList[i]);
            m_PlayerInfos[i].SetActive(true);
        }
    }