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


C# Message.getRawText方法代码示例

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


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

示例1: handleMessage

        public void handleMessage(Message msg)
        {
            if (msg is RoomEnterMessage)
            {
                RoomEnterMessage rms = (RoomEnterMessage)msg;
                this.nomssg.Add(rms.roomName);

            }

            if (msg is RoomInfoMessage)
            {
                Console.WriteLine("joinleave bearbeitet: " + msg.getRawText());
                //"removed";
                //"updated";
                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
                string roomname = (string)dictionary["roomName"];

                

                if (msg.getRawText().Contains("removed"))
                {
                    Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["removed"];

                    for (int i = 0; i < d.Length; i++)
                    {
                        string ltext = d[i]["name"] + " has left the room";
                        
                        RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
                        App.ChatUI.handleMessage(leftmessage);
                        App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
                    }

                }

                if (msg.getRawText().Contains("updated") && this.nomssg.Contains(roomname))
                {
                    nomssg.RemoveAll(item => item == roomname);
                }
                else
                {
                    if (msg.getRawText().Contains("updated"))
                    {
                        Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["updated"];

                        for (int i = 0; i < d.Length; i++)
                        {
                            string ltext = d[i]["name"] + " has joined the room";
                            RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
                            App.ChatUI.handleMessage(leftmessage);
                            App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
                        }

                    }

                }
            }
            
            return;
        }
开发者ID:noHero123,项目名称:joinleave.mod,代码行数:60,代码来源:joinleave.cs

示例2: handleMessage

        public void handleMessage(Message msg)
        {

            if (msg is CardTypesMessage)
            {
                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
                Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"];

                this.cardids = new int[d.GetLength(0)];
                this.cardnames = new string[d.GetLength(0)];
                this.cardImageid = new int[d.GetLength(0)];

                for (int i = 0; i < d.GetLength(0); i++)
                {
                    cardids[i] = Convert.ToInt32(d[i]["id"]);
                    cardnames[i] = d[i]["name"].ToString();
                    cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]);
                }
                
                App.Communicator.removeListener(this);//dont need the listener anymore
            }
            
            return;
        }
开发者ID:noHero123,项目名称:imagechanger.mod,代码行数:25,代码来源:imagechanger.cs

示例3: handleMessage

        public void handleMessage(Message msg)
        {
            if (msg is BattleRedirectMessage || msg is BattleRejoinMessage || msg is FailMessage || msg is OkMessage)
                return;

            if (msg is GameInfoMessage) {
                gameID = (msg as GameInfoMessage).gameId.ToString();
            }

            messages.Add (msg.getRawText());

            if (msg is NewEffectsMessage && msg.getRawText().Contains("EndGame")) {
                //save
                File.WriteAllLines (saveFolder+Path.DirectorySeparatorChar+gameID+".sgr", messages.ToArray ());
            }

            if (msg is HandViewMessage)
                return;

            //TO-DO:
            //steaming
        }
开发者ID:kevinskyba,项目名称:ScrollsModLoader,代码行数:22,代码来源:Recorder.cs

示例4: handleMessage

    public void handleMessage(Message msg)
    {
        if (gameStart) {
            GameLog.WriteLine (msg.getRawText());
        }

        if (!gameStart && msg.ToString().Contains("BattleRedirect"))
            gameStart = true;
        if (gameStart && msg.getRawText ().Contains ("EndGame")) {
            gameStart = false;
            GameLog.Flush ();
            GameLog.Close ();
        }

        Log.WriteLine ("Server:" +msg.getRawText());
    }
开发者ID:kevinskyba,项目名称:ScrollsModLoader,代码行数:16,代码来源:Logger.cs

示例5: handleMessage

        public void handleMessage(Message msg)
        { // collect data for enchantments (or units who buff)

            if (msg is CardTypesMessage)
            {

                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
                Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"];
                this.cardids = new int[d.GetLength(0)];
                this.cardnames = new string[d.GetLength(0)];
                this.cardImageid = new int[d.GetLength(0)];

                for (int i = 0; i < d.GetLength(0); i++)
                {
                    cardids[i] = Convert.ToInt32(d[i]["id"]);
                    cardnames[i] = d[i]["name"].ToString();
                    cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]);
                }

                //App.Communicator.removeListener(this);//dont need the listener anymore
            }

            if(msg is AbilityInfoMessage)
            {
                AbilityInfoMessage aim = (AbilityInfoMessage)msg;
                if (aim.abilityId == "Move")//aim.isPlayable &&
                {
                    this.showLobbers = TileColor.white;
                    if (aim.unitPosition.color == TileColor.white) this.showLobbers = TileColor.black;

                    
                    this.calculateEnemyLobbers(this.showLobbers);

                }
                this.showLobbers = TileColor.unknown;
            }

            if (msg is CardInfoMessage)
            {
                CardInfoMessage aim = (CardInfoMessage)msg;
                //Console.WriteLine("cardinfo");
                if (aim.card.getPieceKind() == CardType.Kind.CREATURE || aim.card.getPieceKind() == CardType.Kind.STRUCTURE)//aim.isPlayable &&
                {
                    this.mark =true;
                    if (aim.data.selectableTiles.Count >= 1)
                    {
                        //Console.WriteLine("cardinfo " + aim.data.selectableTiles.tileSets[0][0].color);
                        this.showLobbers = aim.data.selectableTiles.tileSets[0][0].color.otherColor();
                        this.calculateEnemyLobbers(this.showLobbers);
                    }

                }
                this.showLobbers = TileColor.unknown;
            }


            return;
        }
开发者ID:noHero123,项目名称:enchmouseover.mod,代码行数:59,代码来源:enchmouseover.cs

示例6: handleMessage

        public void handleMessage(Message msg)
        {
            // Check if we should start recording
            if( msg is BattleRedirectMessage ) {
                enabled = true;
                return;

            // Grab version for metadata
            } else if( msg is ServerInfoMessage ) {
                currentVersion = (msg as ServerInfoMessage).version;

            // If you disconnect mid game, it'll have to trigger this on reconnect
            // so only do this part if we flagged it as not being in a game, which means it really ended.
            } else if( !inGame && enabled && msg is ProfileInfoMessage ) {
                if( mod.config.GetString("replay").Equals("ask") ) {
                    App.Popups.ShowOkCancel(this, "replay", "Upload Replay?", "Do you want this replay to be uploaded to ScrollsPost.com?", "Yes", "No");
                }

                enabled = false;

            // Not logging yet
            } else if( !enabled ) {
                return;
            }

            // Initial game start
            if( msg is GameInfoMessage ) {
                if( inGame )
                    return;

                inGame = true;
                lastMessage = mod.TimeSinceEpoch();

                GameInfoMessage info = (GameInfoMessage) msg;

                Dictionary<String, object> metadata = new Dictionary<String, object>();
                metadata["perspective"] = info.color == TileColor.white ? "white" : "black";
                metadata["white-id"] = info.getPlayerProfileId(TileColor.white);
                metadata["black-id"] = info.getPlayerProfileId(TileColor.black);
                metadata["white-name"] = info.getPlayerName(TileColor.white);
                metadata["black-name"] = info.getPlayerName(TileColor.black);
                metadata["deck"] = info.deck;
                metadata["game-id"] = Convert.ToDouble(info.gameId);
                metadata["winner"] = "SPWINNERSP";
                metadata["played-at"] = (int) lastMessage;
                metadata["version"] = currentVersion;

                replayPath = replayFolder + Path.DirectorySeparatorChar + String.Format("{0}-{1}.spr", metadata["game-id"], metadata["perspective"]);

                // Store metadata for easier parsing
                int buffer = mod.config.ContainsKey("buffer") ? mod.config.GetInt("buffer") : 4096;
                sw = new StreamWriter(replayPath, true, Encoding.UTF8, buffer);
                sw.WriteLine(String.Format("metadata|{0}", new JsonWriter().Write(metadata)));

            // Junk we can ignore
            } else if( msg is BattleRejoinMessage || msg is FailMessage || msg is OkMessage ) {
                return;
            }

            if( !inGame )
                return;

            double epoch = mod.TimeSinceEpoch();
            sw.WriteLine(String.Format("elapsed|{0}|{1}", Math.Round(epoch - lastMessage, 2), msg.getRawText().Replace("\n", "")));

            // Game over
            if( msg is NewEffectsMessage && msg.getRawText().Contains("EndGame") ) {
                inGame = false;

                // Finish off
                sw.Flush();
                sw.Close();
                sw = null;

                // Bit of a hack, need to improve somehow
                String contents = File.ReadAllText(replayPath);
                contents = contents.Replace("SPWINNERSP", msg.getRawText().Contains("winner\":\"white\"") ? "white" : "black");
                File.WriteAllText(replayPath, contents);

                // Start uploading immediately since we don't need to wait for anyone
                if( mod.config.GetString("replay").Equals("auto") ) {
                    new Thread(new ThreadStart(Upload)).Start();
                } else {
                    LogNotUploaded(replayPath);
                }
            }

            lastMessage = epoch;
        }
开发者ID:Tomseibert,项目名称:ScrollsPost,代码行数:89,代码来源:ReplayLogger.cs

示例7: handleMessage

		public void handleMessage(Message msg)
		{
			if (playing && msg is NewEffectsMessage && msg.getRawText().Contains("EndGame"))
			{
				playing = false;
				//App.Communicator.setData("");
			}
		}
开发者ID:noHero123,项目名称:GameReplay.Mod,代码行数:8,代码来源:Player.cs

示例8: handleMessage

        public void handleMessage(Message msg)
        { // collect data for enchantments (or units who buff)

            if (msg is CardTypesMessage)
            {
                
                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
                Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"];
                this.cardids = new int[d.GetLength(0)];
                this.cardnames = new string[d.GetLength(0)];
                this.cardImageid = new int[d.GetLength(0)];
                this.cardType = new string[d.GetLength(0)];
                this.longestcardname = 0;
                for (int i = 0; i < d.GetLength(0); i++)
                {
                    cardids[i] = Convert.ToInt32(d[i]["id"]);
                    cardnames[i] = d[i]["name"].ToString().ToLower();
                    cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]);
                    cardType[i] = d[i]["kind"].ToString();
                    if (cardnames[i].Split(' ').Length > longestcardname) { longestcardname = cardnames[i].Split(' ').Length; };

                }
                App.Communicator.removeListener(this);//dont need the listener anymore
            }

            return;
        }
开发者ID:noHero123,项目名称:betterchat.mod,代码行数:28,代码来源:BetterChat.cs

示例9: handleMessage

 public void handleMessage(Message msg)
 {
     if (playing && msg is NewEffectsMessage && msg.getRawText ().Contains ("EndGame")) {
         playing = false;
         App.Communicator.setData ("");
         //App.SceneValues.battleMode = new SceneValues.SV_BattleMode (false);
         //App.Communicator.isActive = true;
         //SceneLoader.loadScene("_HomeScreen");
     }
 }
开发者ID:kevinskyba,项目名称:ScrollsModLoader,代码行数:10,代码来源:Player.cs


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