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


C# SFSObject.PutIntArray方法代码示例

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


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

示例1: SendCubesDataToServer

    private void SendCubesDataToServer(List<Vector3> cubePosList, List<Vector3> cubeRotList)
    {
        //pass cubes by room var
        List<RoomVariable> roomVars = new List<RoomVariable>();

        //list of cubes to pass to server
        SFSArray map = new SFSArray();
        SFSObject sfsObject;

        //convert each cube to a server passible object
        for (int i = 0; i < cubeList.Count; i++)
        {

            sfsObject = new SFSObject();
            sfsObject.PutInt("id", i);
            int[] sides;
            if (i < numberOfTeams)
            {
               sides = new int[] {i, i, i, i, i, i};
            }
            else
            {
                sides = new int[] { -1, -1, -1, -1, -1, -1 };
            }

            sfsObject.PutIntArray("sides", sides);
            sfsObject.PutFloat("x",cubePosList[i].x);
            sfsObject.PutFloat("y", cubePosList[i].y);
            sfsObject.PutFloat("z", cubePosList[i].z);
            sfsObject.PutFloat("rx", cubeRotList[i].x);
            sfsObject.PutFloat("ry", cubeRotList[i].y);
            sfsObject.PutFloat("rz", cubeRotList[i].z);
            map.AddSFSObject(sfsObject);
        }

        Debug.Log("sending room");
        roomVars.Add(new SFSRoomVariable("cubesInSpace", map));
        smartFox.Send(new SetRoomVariablesRequest(roomVars));
    }
开发者ID:eric-kansas,项目名称:Cubes-in-Space,代码行数:39,代码来源:GameManager.cs

示例2: SendCubesDataToServer

    private void SendCubesDataToServer(List<Vector3> cubePosList, List<Vector3> cubeRotList)
    {
        List<RoomVariable> roomVars = new List<RoomVariable>();
        SFSArray array = new SFSArray();
        SFSObject sfsObject;

        for (int i = 0; i < cubeList.Count; i++)
        {
            sfsObject = new SFSObject();
            sfsObject.PutInt("id", i);
            int[] sides= {-1,-1,-1,-1,-1,-1};
            sfsObject.PutIntArray("sides", sides);
            sfsObject.PutFloat("x",cubePosList[i].x);
            sfsObject.PutFloat("y", cubePosList[i].y);
            sfsObject.PutFloat("z", cubePosList[i].z);
            sfsObject.PutFloat("rx", cubeRotList[i].x);
            sfsObject.PutFloat("ry", cubeRotList[i].y);
            sfsObject.PutFloat("rz", cubeRotList[i].z);
            array.AddSFSObject(sfsObject);
        }

        Debug.Log("sending room");
        roomVars.Add(new SFSRoomVariable("cubesInSpace", array));
        smartFox.Send(new SetRoomVariablesRequest(roomVars));
    }
开发者ID:ice0001,项目名称:Cubes-in-Space,代码行数:25,代码来源:GameManager.cs

示例3: OnJoinRoom

    public void OnJoinRoom(BaseEvent evt)
    {
        Room room = (Room)evt.Params["room"];
        currentRoom = room;

        Debug.Log("onjoinroom = " + currentRoom.Name);

        //unlock the mouse
        Screen.lockCursor = false;
        Screen.showCursor = true;

        if (room.Name == "The Lobby")
        {
            //smartFox.RemoveAllEventListeners();
            Debug.Log("onjoinroom = " + smartFox.LastJoinedRoom.Name);
            Application.LoadLevel("The Lobby");
        }
        else if (room.IsGame)
        {
            //this is the game, so it should never actually happen
            Debug.Log("This is the game and should be loaded");
        }
        else
        {
            smartFox.RemoveAllEventListeners();
            //Debug.Log("GameRoom- OnJoinRoom: joined " + room.Name);

            if (GameValues.isHost)
            {
                //pass an updated room variable to the game lobby that talk about the scores
                ISFSObject obj = new SFSObject();
                string winner;
                obj.PutIntArray("scores", teamScores.ToArray());
                List<String> teamColors = new List<String>();
                int i;
                for (i = 0; i < numberOfTeams; i++)
                {
                    switch (i)
                    {
                        case 0:
                            teamColors.Add("Red");
                            break;
                        case 1:
                            teamColors.Add("Blue");
                            break;
                        case 2:
                            teamColors.Add("Green");
                            break;
                        case 3:
                            teamColors.Add("Yellow");
                            break;
                        case 4:
                            teamColors.Add("Purple");
                            break;
                        case 5:
                            teamColors.Add("Orange");
                            break;
                        case 6:
                            teamColors.Add("Pink");
                            break;
                        case 7:
                            teamColors.Add("Teal");
                            break;
                        default:
                            break;
                    }
                }

                int highestScore = -1;
                winner = "Tie";
                for (i = 0; i < numberOfTeams; i++)
                {
                    if (teamScores[i] > highestScore)
                    {
                        winner = teamColors[i];
                        highestScore = teamScores[i];
                    }
                    else if (teamScores[i] == highestScore)
                    {
                        if (winner.Contains("Tie: "))
                        {
                            winner += ", " + teamColors[i];
                        }
                        else
                        {
                            winner = "Tie: " + winner + ", " + teamColors[i];
                        }
                    }
                }
                obj.PutUtfString("winner", winner);
                obj.PutUtfStringArray("teamColors", teamColors.ToArray());
                List<RoomVariable> rm = new List<RoomVariable>();
                rm.Add(new SFSRoomVariable("lastGameScores", obj));
                smartFox.Send(new SetRoomVariablesRequest(rm));
            }

            Application.LoadLevel("Game Lobby");
            Debug.Log("loading Game Lobby");
            //smartFox.Send(new SpectatorToPlayerRequest());
        }
//.........这里部分代码省略.........
开发者ID:eric-kansas,项目名称:Cubes-in-Space,代码行数:101,代码来源:GameManager.cs


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