当前位置: 首页>>代码示例>>C#>>正文


C# Room.GetVariable方法代码示例

本文整理汇总了C#中Room.GetVariable方法的典型用法代码示例。如果您正苦于以下问题:C# Room.GetVariable方法的具体用法?C# Room.GetVariable怎么用?C# Room.GetVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Room的用法示例。


在下文中一共展示了Room.GetVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupTheFox

    private void SetupTheFox()
    {
        bool debug = true;
        running = true;
        if (SmartFoxConnection.IsInitialized)
        {
            smartFox = SmartFoxConnection.Connection;
        }
        else
        {
            smartFox = new SmartFox(debug);
        }
        currentRoom = smartFox.LastJoinedRoom;
        clientName = smartFox.MySelf.Name;

        // set up arrays of positions
        positions = new List<Vector3>();
        GameObject[] spawnPoints = GameObject.FindGameObjectsWithTag("SpawnTag");
        for (int i = 0; i < spawnPoints.Length; i++)
        {
            positions.Add(spawnPoints[i].transform.position);
        }

        lobbyGameInfo = (SFSObject)currentRoom.GetVariable("gameInfo").GetSFSObjectValue();

        host = lobbyGameInfo.GetUtfString("host");
        numberOfTeams = lobbyGameInfo.GetInt("numTeams");
        numberOfPlayers = currentRoom.GetVariable("numberOfPlayers").GetIntValue();
        teams = (SFSArray)lobbyGameInfo.GetSFSArray("teams");
        gameLength = lobbyGameInfo.GetInt("gameLength");

        gameLength = (int)lobbyGameInfo.GetInt("gameLength") * 1000;

        SetupListeners();
    }
开发者ID:ice0001,项目名称:Cubes-in-Space,代码行数:35,代码来源:GameManager.cs

示例2: OnRoomJoinSucceed

 /// <summary>
 /// Успешно вошли в какую-то комнату
 /// </summary>
 /// <param name="room"></param>
 void OnRoomJoinSucceed(Room room)
 {
     if (room.Name.Contains("Game"))
     {
         PlayModes playMode = (PlayModes) Enum.Parse(typeof(PlayModes), room.GetVariable("playMode").GetStringValue());
         IOL.Instance.GameLoad(playMode);
     }
 }
开发者ID:PanCrucian,项目名称:IOL,代码行数:12,代码来源:ServerResponses.cs

示例3: Start

    void Start()
    {
        Debug.Log("start game lobby");
        smartFox = SmartFoxConnection.Connection;
        currentActiveRoom = smartFox.LastJoinedRoom;

        smartFox.AddLogListener(LogLevel.INFO, OnDebugMessage);
        screenW = Screen.width;
        AddEventListeners();

        username = smartFox.MySelf.Name;

        lobbyGameInfo = (SFSObject)currentActiveRoom.GetVariable("gameInfo").GetSFSObjectValue();

        maxPlayers = currentActiveRoom.MaxUsers;
        host = lobbyGameInfo.GetUtfString("host");
        numberOfTeams = lobbyGameInfo.GetInt("numTeams");
        Debug.Log("start number of teams: " + numberOfTeams);
        if (GameValues.isHost)
            currentTeams = new int[8];

        teams = (SFSArray)lobbyGameInfo.GetSFSArray("teams");
        playerPerTeam = numberOfPlayers / numberOfTeams;
        gameLength = (int)lobbyGameInfo.GetInt("gameLength");

        //Make Contents for the popup gameLength list
        gameLengthList[0] = (new GUIContent("60"));
        gameLengthList[1] = (new GUIContent("120"));
        gameLengthList[2] = (new GUIContent("300"));
        gameLengthList[3] = (new GUIContent("600"));

        //Make Contents for the popup number of teams list
        teamNumberList[0] = (new GUIContent("2"));
        teamNumberList[1] = (new GUIContent("3"));
        teamNumberList[2] = (new GUIContent("4"));
        teamNumberList[3] = (new GUIContent("5"));
        teamNumberList[4] = (new GUIContent("6"));
        teamNumberList[5] = (new GUIContent("7"));
        teamNumberList[6] = (new GUIContent("8"));

        //Set team scroll positions to zero
        for(int i = 0; i < 8; i++)
        {
            teamScrollPositions.Add(Vector2.zero);
        }

        //Make a gui style for the lists
        listStyle.normal.textColor = Color.white;
        Texture2D tex = new Texture2D(2, 2);
        Color[] colors = new Color[4];
        for (int i = 0; i < 4; i++)
        {
            colors[i] = Color.white;
        }
        tex.SetPixels(colors);
        tex.Apply();
        listStyle.hover.background = tex;
        listStyle.onHover.background = tex;
        listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4;

        if (GameValues.isHost)
        {
            currentIDs.AddInt(0);
            GameValues.playerID = 0;
            GameValues.teamNum = 0;
            currentTeams[0]++;
            List<UserVariable> uData = new List<UserVariable>();
            uData.Add(new SFSUserVariable("playerID", GameValues.playerID));
            uData.Add(new SFSUserVariable("playerTeam", GameValues.teamNum));
            smartFox.Send(new SetUserVariablesRequest(uData));

            SFSObject gameInfo = (SFSObject)currentActiveRoom.GetVariable("gameInfo").GetSFSObjectValue();

            //send back to store on server
            List<RoomVariable> rData = new List<RoomVariable>();
            gameInfo.PutSFSArray("playerIDs", currentIDs);
            rData.Add(new SFSRoomVariable("gameInfo", gameInfo));
            smartFox.Send(new SetRoomVariablesRequest(rData));

        }

        if (currentActiveRoom.ContainsVariable("lastGameScores"))
        {
            Debug.Log("scores from last game are present, adding to the message window...");
            //write out the last games scores to the chat window
            //format:
            //scores: int array
            //winner: string
            SFSObject lastGameData = (SFSObject)currentActiveRoom.GetVariable("lastGameScores").GetSFSObjectValue();
            int[] scoresArray = lastGameData.GetIntArray("scores");
            string[] teamColors = lastGameData.GetUtfStringArray("teamColors");

            messages.Add("Previous Game's Scores");
            messages.Add("The Winner is... " + lastGameData.GetUtfString("winner").ToString());
            for (int i = 0; i < scoresArray.Length; i++)
            {
                string teamName = teamColors[i] + " Team";
                messages.Add(teamName + "\tscored " + scoresArray[i].ToString() + " points.");
            }
        }
//.........这里部分代码省略.........
开发者ID:eric-kansas,项目名称:Cubes-in-Space,代码行数:101,代码来源:GameLobby.cs


注:本文中的Room.GetVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。