Example #1
0
    private void RemovePlayer(int id, int teamId)
    {
        SFSObject gameInfo = (SFSObject)currentActiveRoom.GetVariable("gameInfo").GetSFSObjectValue();
        SFSArray idsLeft = (SFSArray)gameInfo.GetSFSArray("playerIDs");

        //update room variable
        SFSArray returnInts = new SFSArray();
        returnInts.AddInt(GameValues.playerID);
        Debug.Log("here in stuff: " + returnInts.GetInt(0));
        for (int i = 0; i < idsLeft.Size(); i++)
        {
            returnInts.AddInt(idsLeft.GetInt(i));
            Debug.Log("here in stuff: " + returnInts.GetInt(i + 1));
        }

        for (int i = 0; i < currentIDs.Size(); i++)
        {
            if (currentIDs.GetInt(i) == id)
            {
                currentIDs.RemoveElementAt(i);
                break;
            }
        }

        currentTeams[teamId]--;

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