示例#1
0
 public ChatInfo(int time, Player from, TalkTo to, Player toPlayer, string message)
 {
     this.time     = new TimeSpan(0, 0, 0, 0, time);
     this.from     = from;
     this.to       = to;
     this.toPlayer = toPlayer;
     this.message  = message;
 }
示例#2
0
 public ChatInfo(int time, Player from, TalkTo to, Player toPlayer, string message)
 {
     this.time = new TimeSpan(0, 0, 0, 0, time);
     this.from = from;
     this.to = to;
     this.toPlayer = toPlayer;
     this.message = message;
 }
示例#3
0
        private void LoadActions(BinaryReader reader)
        {
            int  time     = 0;
            bool isPaused = false;

            while (reader.BaseStream.Length - reader.BaseStream.Position > 0)
            {
                byte blockId = reader.ReadByte();
                switch (blockId)
                {
                case 0x1A:
                case 0x1B:
                case 0x1C:
                    reader.BaseStream.Seek(reader.BaseStream.Position + 4, SeekOrigin.Begin);
                    break;

                case 0x22:
                    reader.BaseStream.Seek(reader.BaseStream.Position + 5, SeekOrigin.Begin);
                    break;

                case 0x23:
                    reader.BaseStream.Seek(reader.BaseStream.Position + 10, SeekOrigin.Begin);
                    break;

                case 0x2F:
                    reader.BaseStream.Seek(reader.BaseStream.Position + 8, SeekOrigin.Begin);
                    break;

                //leave game
                case 0x17:
                    reader.ReadInt32();
                    byte   playerId = reader.ReadByte();
                    Player p        = GetPlayerById(playerId);
                    p.Time = time;
                    reader.ReadInt64();
                    break;

                //chat
                case 0x20:
                    byte fromId = reader.ReadByte();
                    reader.ReadBytes(2);
                    byte   chatType = reader.ReadByte();
                    TalkTo to       = TalkTo.All;
                    if (chatType != 0x10)
                    {
                        to = (TalkTo)reader.ReadInt32();
                    }
                    string message = ParserUtility.ReadString(reader);
                    if (chatType != 0x10)
                    {
                        ChatInfo chat = new ChatInfo(time, GetPlayerById(fromId), to, GetPlayerById((byte)(to - 3)), message);
                        chats.Add(chat);
                    }
                    break;

                //time slot
                case 0x1E:
                case 0x1F:
                    short rest          = reader.ReadInt16();
                    short increasedTime = reader.ReadInt16();
                    if (!isPaused)
                    {
                        time += increasedTime;
                    }
                    rest -= 2;
                    LoadTimeSlot(reader, rest, time, ref isPaused);
                    break;

                case 0:
                    return;

                default:
                    throw new W3gParserException("未知的数据块ID.");
                }
            }
        }