Ejemplo n.º 1
0
    public virtual bool OpCreateGame(string gameID, bool isVisible, bool isOpen, byte maxPlayers, Hashtable customGameProperties, Hashtable customActorProperties)
    {
        if (this.DebugOut >= DebugLevel.INFO)
        {
            this.Listener.DebugReturn(DebugLevel.INFO, "OpCreateGame()");
        }

        Hashtable gameProperties = new Hashtable();

        gameProperties[GameProperties.IsOpen]    = isOpen;
        gameProperties[GameProperties.IsVisible] = isVisible;
        gameProperties.MergeStringKeys(customGameProperties);
        if (maxPlayers > 0)
        {
            gameProperties[GameProperties.MaxPlayers] = maxPlayers;
        }

        Dictionary <byte, object> op = new Dictionary <byte, object>();

        op[ParameterCode.GameProperties]  = gameProperties;
        op[ParameterCode.ActorProperties] = customActorProperties;
        op[ParameterCode.Broadcast]       = true;

        if (!string.IsNullOrEmpty(gameID))
        {
            op[ParameterCode.GameId] = gameID;
        }

        Listener.DebugReturn(DebugLevel.INFO, OperationCode.CreateGame + ": " + SupportClass.DictionaryToString(op));
        return(this.OpCustom(OperationCode.CreateGame, op, true));
    }
Ejemplo n.º 2
0
    private void OnWebRpcResponse(WebRpcResponse response)
    {
        if (response.ReturnCode != 0)
        {
            Debug.Log(response.ToStringFull());     // in an error case, it's often helpful to see the full response
            return;
        }

        if (response.Name.Equals("GetGameList"))
        {
            this.SavedGames.Clear();

            if (response.Parameters == null)
            {
                Debug.Log("WebRpcResponse for GetGameList contains no rooms: " + response.ToStringFull());
                return;
            }

            // the response for GetGameList contains a Room's name as Key and another Dictionary<string,object> with the values the web service sends
            foreach (KeyValuePair <string, object> pair in response.Parameters)
            {
                // per key (room name), we send
                // "ActorNr" which is the PlayerId/ActorNumber this user had in the room
                // "Properties" which is another Dictionary<string,object> with the properties that the lobby sees
                Dictionary <string, object> roomValues = pair.Value as Dictionary <string, object>;

                int savedActorNumber = (int)roomValues["ActorNr"];
                Dictionary <string, object> savedRoomProps = roomValues["Properties"] as Dictionary <string, object>; // we are not yet using these in this demo

                this.SavedGames.Add(pair.Key, savedActorNumber);
                Debug.Log(pair.Key + " actorNr: " + savedActorNumber + " props: " + SupportClass.DictionaryToString(savedRoomProps));
            }
        }
    }
Ejemplo n.º 3
0
    public void LoadBoardFromProperties(bool calledByEvent)
    {
        //board.InitializeBoard();

        Hashtable roomProps = this.CurrentRoom.CustomProperties;

        Debug.Log(string.Format("Board Properties: {0}", SupportClass.DictionaryToString(roomProps)));

        if (roomProps.Count == 0)
        {
            // we are in a fresh room with no saved board.
            board.InitializeBoard();
            board.RandomBoard();
            this.SaveBoardToProperties();
        }


        // we are in a game that has props (a board). read those (as update or as init, depending on calledByEvent)
        bool success = board.SetBoardByCustomProperties(roomProps, calledByEvent);

        if (!success)
        {
            Debug.LogError("Not loaded board from props?");
        }


        // we set properties "pt" (player turn) and "t#" (turn number). those props might have changed
        // it's easier to use a variable in gui, so read the latter property now
        if (this.CurrentRoom.CustomProperties.ContainsKey("t#"))
        {
            this.TurnNumber = (int)this.CurrentRoom.CustomProperties["t#"];
        }
        else
        {
            this.TurnNumber = 1;
        }

        if (this.CurrentRoom.CustomProperties.ContainsKey("pt"))
        {
            this.PlayerIdToMakeThisTurn = (int)this.CurrentRoom.CustomProperties["pt"];
            //Debug.Log("This turn was played by player.ID: " + this.PlayerIdToMakeThisTurn);
        }
        else
        {
            this.PlayerIdToMakeThisTurn = 0;
        }

        // if the game didn't save a player's turn yet (it is 0): use master
        if (this.PlayerIdToMakeThisTurn == 0)
        {
            this.PlayerIdToMakeThisTurn = this.CurrentRoom.MasterClientId;
        }

        this.MyPoints     = GetPlayerPointsFromProps(this.LocalPlayer);
        this.OthersPoints = GetPlayerPointsFromProps(this.Opponent);
    }
 // Token: 0x0600B1E5 RID: 45541 RVA: 0x00415E2C File Offset: 0x0041402C
 public string ToStringFull()
 {
     return(string.Format("{0}={2}: {1} \"{3}\"", new object[]
     {
         this.Name,
         SupportClass.DictionaryToString(this.Parameters),
         this.ReturnCode,
         this.DebugMessage
     }));
 }
    // Token: 0x0600B211 RID: 45585 RVA: 0x00415F2C File Offset: 0x0041412C
    public string FHMPCEFFJHK()
    {
        string format = ".completed";

        object[] array = new object[3];
        array[0] = this.KKLNEKKBBAA();
        array[1] = SupportClass.DictionaryToString(this.BDAAEEFJPAC());
        array[8] = this.GNNMPACHPCF();
        array[0] = this.MBAKELMCPHE();
        return(string.Format(format, array));
    }
    // Token: 0x0600B20C RID: 45580 RVA: 0x00415EAC File Offset: 0x004140AC
    public string NNLBMHKCGNH()
    {
        string format = "_Value3";

        object[] array = new object[8];
        array[0] = this.KKBCAPBHNME();
        array[1] = SupportClass.DictionaryToString(this.IMFKPFFOLHH());
        array[3] = this.JINAJEJPFKD();
        array[4] = this.DebugMessage;
        return(string.Format(format, array));
    }
    // Token: 0x0600B1C9 RID: 45513 RVA: 0x00415D64 File Offset: 0x00413F64
    public string GKIBADAOLHF()
    {
        string format = "_ColorRGB";

        object[] array = new object[8];
        array[1] = this.KKBCAPBHNME();
        array[0] = SupportClass.DictionaryToString(this.IMFKPFFOLHH());
        array[3] = this.DLOBNKDIJJA();
        array[7] = this.KHDHJDGHEDJ();
        return(string.Format(format, array));
    }
    // Token: 0x0600B1CD RID: 45517 RVA: 0x00415DAC File Offset: 0x00413FAC
    public string KJBLJAACPHN()
    {
        string format = "CameraFilterPack/Blend2Camera_LighterColor";

        object[] array = new object[1];
        array[0] = this.KFDKGMFAMMD();
        array[1] = SupportClass.DictionaryToString(this.MGGLMAOFEPP());
        array[0] = this.GNNMPACHPCF();
        array[8] = this.MBAKELMCPHE();
        return(string.Format(format, array));
    }
    // Token: 0x0600B21A RID: 45594 RVA: 0x00415F6C File Offset: 0x0041416C
    public string NIDDALHEBFD()
    {
        string format = "DPADVER";

        object[] array = new object[0];
        array[1] = this.KKLNEKKBBAA();
        array[0] = SupportClass.DictionaryToString(this.Parameters);
        array[2] = this.CKJNNAEHGDM();
        array[4] = this.MBAKELMCPHE();
        return(string.Format(format, array));
    }
    // Token: 0x0600B1F4 RID: 45556 RVA: 0x00415E6C File Offset: 0x0041406C
    public string OLOGEPLCOCC()
    {
        string format = "/icon";

        object[] array = new object[0];
        array[1] = this.NLICCMJPLMD();
        array[1] = SupportClass.DictionaryToString(this.DKCFCPMMDNM());
        array[5] = this.GNNMPACHPCF();
        array[2] = this.DebugMessage;
        return(string.Format(format, array));
    }
    // Token: 0x0600B1B4 RID: 45492 RVA: 0x00415C5B File Offset: 0x00413E5B
    public string MLAINMDLNFL()
    {
        string format = "CameraFilterPack/AAA_Super_Hexagon";

        object[] array = new object[7];
        array[0] = this.Name;
        array[1] = SupportClass.DictionaryToString(this.BLGOLPHJIPP());
        array[5] = this.FNOOPFIFCLP();
        array[0] = this.KIOAJOBNBLE();
        return(string.Format(format, array));
    }
    // Token: 0x0600B20E RID: 45582 RVA: 0x00415EEC File Offset: 0x004140EC
    public string DCPNIACBMJE()
    {
        string format = "SetParticlesParticleSize";

        object[] array = new object[4];
        array[1] = this.MONALMNMMOH();
        array[0] = SupportClass.DictionaryToString(this.CINFBCECGKC());
        array[3] = this.GNNMPACHPCF();
        array[6] = this.DebugMessage;
        return(string.Format(format, array));
    }
    // Token: 0x0600B1D9 RID: 45529 RVA: 0x00415DEC File Offset: 0x00413FEC
    public string KKPBFCFLOMI()
    {
        string format = "_TintColor";

        object[] array = new object[]
        {
            this.NLICCMJPLMD(),
            SupportClass.DictionaryToString(this.MGGLMAOFEPP()),
            null,
            this.DLOBNKDIJJA()
        };
        array[3] = this.DebugMessage;
        return(string.Format(format, array));
    }
Ejemplo n.º 14
0
    public void SaveBoardAsProperty()
    {
        CubeBoard board = GameObject.FindObjectOfType(typeof(CubeBoard)) as CubeBoard;

        this.turnNumber     = this.turnNumber + 1;
        this.lastTurnPlayer = this.LocalPlayer.ID;

        Hashtable boardProps = board.GetBoardAsCustomProperties();

        boardProps.Add("lt", this.lastTurnPlayer);  // "lt" is for "last turn" and contains the ID/actorNumber of the player who did the last one
        boardProps.Add("t#", this.turnNumber);

        this.OpSetCustomPropertiesOfRoom(boardProps);

        Debug.Log("saved board to props " + SupportClass.DictionaryToString(boardProps));
    }
Ejemplo n.º 15
0
        private void UpdateView()
        {
            if (this.availableRoomsListBox.InvokeRequired)
            {
                UpdateViewDelegate d = new UpdateViewDelegate(this.UpdateView);
                this.Invoke(d);
            }
            else
            {
                if (RobotClientStarter.Instance.Client.AppId.Equals("<your appid>"))
                {
                    Console.Out.WriteLine("The appId is not set. Customize your appId in RobotClient.cs. Find help in readme.txt");
                    this.Text = "Error: default appId in use. Customize your appId in RobotClient.cs.";
                }

                this.showGame = RobotClientStarter.Instance.Client.State == ClientState.Joined;

                this.lobbyPanel.Visible = !this.showGame;
                this.gamePanel.Visible  = this.showGame;

                this.availableRoomsListBox.Items.Clear();
                foreach (var v in RobotClientStarter.Instance.Client.RoomInfoList.Values)
                {
                    this.availableRoomsListBox.Items.Add(v);
                }
                this.roomCountLabel.Text = RobotClientStarter.Instance.Client.RoomInfoList.Values.Count.ToString();

                this.playerListBox.Items.Clear();

                // display the room's properties first
                if (RobotClientStarter.Instance.Client != null && RobotClientStarter.Instance.Client.CurrentRoom != null)
                {
                    // display room's name, player count, event count (something this demo's RobotClient does) and properties
                    this.roomNameLabel.Text        = RobotClientStarter.Instance.Client.CurrentRoom.Name;
                    this.roomPlayerCountLabel.Text = RobotClientStarter.Instance.Client.CurrentRoom.PlayerCount.ToString();

                    this.roomPropsLabel.Text   = SupportClass.DictionaryToString(RobotClientStarter.Instance.Client.CurrentRoom.CustomProperties);
                    this.eventsCountLabel.Text = RobotClientStarter.Instance.Client.ReceivedCountMeEvents.ToString();

                    // list all players (by keys, which are most likely sorted)
                    foreach (int playerId in RobotClientStarter.Instance.Client.CurrentRoom.Players.Keys)
                    {
                        this.playerListBox.Items.Add(RobotClientStarter.Instance.Client.CurrentRoom.Players[playerId]);
                    }
                }
            }
        }
Ejemplo n.º 16
0
    /// <remarks>the hashtable is (optionally) used to filter games: only those that fit the contained custom properties will be matched</remarks>
    public virtual bool OpJoinRandom(Hashtable expectedGameProperties)
    {
        if (this.DebugOut >= DebugLevel.INFO)
        {
            this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandom()");
        }

        Dictionary <byte, object> op = new Dictionary <byte, object>();

        if (expectedGameProperties != null && expectedGameProperties.Count > 0)
        {
            op[ParameterCode.Properties] = expectedGameProperties;
        }

        Listener.DebugReturn(DebugLevel.INFO, OperationCode.JoinRandomGame + ": " + SupportClass.DictionaryToString(op));
        return(this.OpCustom(OperationCode.JoinRandomGame, op, true));
    }
Ejemplo n.º 17
0
        private void LoadGameFromProperties(bool calledByEvent)
        {
            Hashtable roomProps = CurrentRoom.CustomProperties;

            Debug.Log(string.Format("Board Properties: {0}", SupportClass.DictionaryToString(roomProps)));

            if (IsGameStart || roomProps.ContainsKey(Consts.PropNames.IsStart))
            {
                if (Info == null)
                {
                    DealGameStart();
                }

                // we set properties "pt" (player turn) and "t#" (turn number). those props might have changed
                // it's easier to use a variable in gui, so read the latter property now
                if (this.CurrentRoom.CustomProperties.ContainsKey(Consts.PropNames.TurnNum))
                {
                    Info.turnNum = (int)this.CurrentRoom.CustomProperties[Consts.PropNames.TurnNum];
                }
                else
                {
                    Info.turnNum = 0;
                }

                if (this.CurrentRoom.CustomProperties.ContainsKey(Consts.PropNames.PlayerIdToMakeThisTurn))
                {
                    Info.playerIdToMakeThisTurn = (int)this.CurrentRoom.CustomProperties[Consts.PropNames.PlayerIdToMakeThisTurn];
                }
                else
                {
                    Info.playerIdToMakeThisTurn = 0;
                }

                // if the game didn't save a player's turn yet (it is 0): use master
                if (Info.playerIdToMakeThisTurn == 0)
                {
                    Info.playerIdToMakeThisTurn = this.CurrentRoom.MasterClientId;
                }
            }
        }
Ejemplo n.º 18
0
    public virtual bool OpJoin(string gameID, Hashtable actorProperties)
    {
        if (this.DebugOut >= DebugLevel.INFO)
        {
            this.Listener.DebugReturn(DebugLevel.INFO, "OpJoin()");
        }

        if (string.IsNullOrEmpty(gameID))
        {
            this.Listener.DebugReturn(DebugLevel.ERROR, "OpJoin() failed. Please specify a roomname.");
            return(false);
        }

        Dictionary <byte, object> op = new Dictionary <byte, object>();

        op[ParameterCode.GameId]          = gameID;
        op[ParameterCode.ActorProperties] = actorProperties;
        op[ParameterCode.Broadcast]       = true;

        Listener.DebugReturn(DebugLevel.INFO, OperationCode.JoinGame + ": " + SupportClass.DictionaryToString(op));
        return(this.OpCustom(OperationCode.JoinGame, op, true));
    }
    /// <summary>
    /// Don't use this method directly, unless you know how to cache and apply customActorProperties.
    /// The PhotonNetwork methods will handle player and room properties for you and call this method.
    /// </summary>
    public virtual bool OpCreateRoom(string gameID, bool isVisible, bool isOpen, byte maxPlayers, bool autoCleanUp, Hashtable customGameProperties, Hashtable customPlayerProperties, string[] customRoomPropertiesForLobby)
    {
        if (this.DebugOut >= DebugLevel.INFO)
        {
            this.Listener.DebugReturn(DebugLevel.INFO, "OpCreateRoom()");
        }

        Hashtable gameProperties = new Hashtable();

        gameProperties[GameProperties.IsOpen]             = isOpen;
        gameProperties[GameProperties.IsVisible]          = isVisible;
        gameProperties[GameProperties.PropsListedInLobby] = customRoomPropertiesForLobby;
        gameProperties.MergeStringKeys(customGameProperties);
        if (maxPlayers > 0)
        {
            gameProperties[GameProperties.MaxPlayers] = maxPlayers;
        }

        Dictionary <byte, object> op = new Dictionary <byte, object>();

        op[ParameterCode.GameProperties]   = gameProperties;
        op[ParameterCode.PlayerProperties] = customPlayerProperties;
        op[ParameterCode.Broadcast]        = true;

        if (!string.IsNullOrEmpty(gameID))
        {
            op[ParameterCode.RoomName] = gameID;
        }

        if (autoCleanUp)
        {
            op[ParameterCode.CleanupCacheOnLeave] = autoCleanUp;
            gameProperties[GameProperties.CleanupCacheOnLeave] = autoCleanUp;
        }

        Listener.DebugReturn(DebugLevel.INFO, OperationCode.CreateGame + ": " + SupportClass.DictionaryToString(op));
        return(this.OpCustom(OperationCode.CreateGame, op, true));
    }
Ejemplo n.º 20
0
 /// <summary>Simple printingin method.</summary>
 /// <returns>String showing the RoomInfo.</returns>
 public override string ToString()
 {
     return(string.Format("Room: '{0}' visible: {1} open: {2} max: {3} count: {4}\ncustomProps: {5}", this.nameField, this.visibleField, this.openField, this.maxPlayersField, this.playerCount, SupportClass.DictionaryToString(this.customPropertiesField)));
 }
Ejemplo n.º 21
0
 /// <summary>Simple printing method.</summary>
 /// <returns>String showing the RoomInfo.</returns>
 public override string ToString()
 {
     return(string.Format("Room: '{0}' visible: {1} open: {2} max: {3} count: {4} customProps: {5}", this.name, this.isVisible, this.isOpen, this.maxPlayers, this.PlayerCount, SupportClass.DictionaryToString(this.customProperties)));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Converts the player info into a string.
 /// </summary>
 /// <returns>String showing basic info about this player.</returns>
 public override string ToString()
 {
     return(this.ID + "'" + this.Name + "':" + this.GetGroup() + " " + this.PosX + ":" + this.PosY + " PlayerProps: " + SupportClass.DictionaryToString(this.CustomProperties));
 }
Ejemplo n.º 23
0
 public string ToStringFull()
 {
     object[] args = { Name, SupportClass.DictionaryToString(Parameters), ReturnCode, DebugMessage };
     return(string.Format("{0}={2}: {1} \"{3}\"", args));
 }
Ejemplo n.º 24
0
 /// <summary>Returns a summary of this Room instance as longer string, including Custom Properties.</summary>
 /// <returns>Summary of this Room instance.</returns>
 public new string ToStringFull()
 {
     return(string.Format("Room: '{0}' {1},{2} {4}/{3} players.\ncustomProps: {5}", this.name, this.isVisible ? "visible" : "hidden", this.isOpen ? "open" : "closed", this.maxPlayers, this.PlayerCount, SupportClass.DictionaryToString(this.CustomProperties)));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Returns a string-representation of the IDictionary's content, inlcuding type-information.
 /// Note: This might turn out a "heavy-duty" call if used frequently but it's usfuly to debug Dictionary or Hashtable content.
 /// </summary>
 /// <param name="origin">Some Dictionary or Hashtable.</param>
 /// <returns>String of the content of the IDictionary.</returns>
 public static string ToStringFull(this IDictionary origin)
 {
     return(SupportClass.DictionaryToString(origin, false));
 }
Ejemplo n.º 26
0
 public string ToStringFull()
 {
     return(string.Format("\"{0}\"[{1}] {2} ({3})", RoomName, MyPlayerId, MyTurn, SupportClass.DictionaryToString(AvailableProperties)));
 }
Ejemplo n.º 27
0
    private void OnWebRpcResponse(WebRpcResponse response)
    {
        Debug.Log(string.Format("OnWebRpcResponse. Code: {0} Content: {1}", response.ReturnCode, SupportClass.DictionaryToString(response.Parameters)));
        if (response.ReturnCode == 0)
        {
            if (response.Parameters == null)
            {
                Debug.Log("WebRpc executed ok but didn't get content back. This happens for empty save-game lists.");
                memoryGui.GameListUpdate();
                return;
            }

            if (response.Name.Equals("GetGameList"))
            {
                this.SavedGames.Clear();

                // the response for GetGameList contains a Room's name as Key and another Dictionary<string,object> with the values the web service sends
                foreach (KeyValuePair <string, object> pair in response.Parameters)
                {
                    // per key (room name), we send
                    // "ActorNr" which is the PlayerId/ActorNumber this user had in the room
                    // "Properties" which is another Dictionary<string,object> with the properties that the lobby sees
                    Dictionary <string, object> roomValues = pair.Value as Dictionary <string, object>;

                    SaveGameInfo si = new SaveGameInfo();
                    si.RoomName            = pair.Key;
                    si.DisplayName         = pair.Key; // we might have a better display name for this room. see below.
                    si.MyPlayerId          = (int)roomValues["ActorNr"];
                    si.AvailableProperties = roomValues["Properties"] as Dictionary <string, object>;

                    // let's find out of it's our turn to play and if we know the opponent's name (which we will display as game name).
                    if (si.AvailableProperties != null)
                    {
                        // PropTurn is a value per room that gets set to the player who's turn is next.
                        if (si.AvailableProperties.ContainsKey(PropTurn))
                        {
                            int nextPlayer = (int)si.AvailableProperties[PropTurn];
                            si.MyTurn = nextPlayer == si.MyPlayerId;
                        }

                        // PropNames is set to a list of the player names. this can easily be turned into a name for the game to display
                        if (si.AvailableProperties.ContainsKey(PropNames))
                        {
                            string display = (string)si.AvailableProperties[PropNames];
                            display        = display.ToLower();
                            display        = display.Replace(this.PlayerName.ToLower(), "");
                            display        = display.Replace(";", "");
                            si.DisplayName = "vs. " + display;
                        }
                    }

                    //Debug.Log(si.ToStringFull());
                    this.SavedGames.Add(si);
                }
                memoryGui.GameListUpdate();
            }
        }
    }
Ejemplo n.º 28
0
 public override string ToString()
 {
     return(this.ActorNumber + "'" + this.NickName + "':" + this.XPosition + ":" + this.YPosition + " PlayerProps: " + SupportClass.DictionaryToString(this.CustomProperties));
 }
Ejemplo n.º 29
0
 /// <summary>
 /// This Player's NickName and custom properties as string.
 /// </summary>
 public override string ToString()
 {
     return(this.NickName + " " + SupportClass.DictionaryToString(this.CustomProperties));
 }
Ejemplo n.º 30
0
 public string ToStringFull()
 {
     return(string.Format("{0}={2}: {1} \"{3}\"", Name, SupportClass.DictionaryToString(Parameters), ReturnCode, DebugMessage));
 }