Beispiel #1
0
 public static new ClientInfo decode(ref Lidgren.Network.NetIncomingMessage msg)
 {
     ClientInfo ci = new ClientInfo (Packet.decode (ref msg).ClientId);
     ci.Pseudo = msg.ReadString ();
     ci.Color = new Color(msg.ReadByte(), msg.ReadByte(), msg.ReadByte());
     return ci;
 }
Beispiel #2
0
 protected override void ReadData(Lidgren.Network.NetIncomingMessage Message)
 {
     if (!Guid.TryParse(Message.ReadString(), out Parent)) {
         throw new Exception("Could not parse parent guid for block type");
     }
     Code.Read(Message);
 }
 public override void Decode(Lidgren.Network.NetIncomingMessage msg)
 {
     timesDisplayed =      msg.ReadByte();
     ballColor = (MyColor) msg.ReadByte();
     textColor = (MyColor) msg.ReadByte();
     textWord =  (MyColor) msg.ReadByte();
 }
Beispiel #4
0
 /// <summary>
 /// deserialize into quaternion
 /// </summary>
 /// <param name="message"></param>
 public void OnDeserialize(Lidgren.Network.NetIncomingMessage message)
 {
     quaternion.x = message.ReadFloat();
     quaternion.y = message.ReadFloat();
     quaternion.z = message.ReadFloat();
     quaternion.w = message.ReadFloat();
 }
 public override void Encode(Lidgren.Network.NetOutgoingMessage msg)
 {
     msg.Write((byte) timesDisplayed);
     msg.Write((byte) ballColor);
     msg.Write((byte) textColor);
     msg.Write((byte) textWord);
 }
Beispiel #6
0
 /// <summary>
 /// serialize to the stream
 /// </summary>
 /// <param name="message"></param>
 public void OnSerialize(Lidgren.Network.NetOutgoingMessage message)
 {
     message.Write(quaternion.X);
     message.Write(quaternion.Y);
     message.Write(quaternion.Z);
     message.Write(quaternion.W);
 }
Beispiel #7
0
 /// <summary>
 /// Serialize the quaternion to the message
 /// </summary>
 /// <param name="quaternion"></param>
 /// <param name="message"></param>
 public static void Serialize(this Quaternion quaternion, Lidgren.Network.NetOutgoingMessage message)
 {
     message.Write(quaternion.x);
     message.Write(quaternion.y);
     message.Write(quaternion.z);
     message.Write(quaternion.w);
 }
Beispiel #8
0
 /// <summary>
 /// deserialize from the stream
 /// </summary>
 /// <param name="message"></param>
 public void OnDeserialize(Lidgren.Network.NetIncomingMessage message)
 {
     quaternion.X = message.ReadFloat();
     quaternion.Y = message.ReadFloat();
     quaternion.Z = message.ReadFloat();
     quaternion.W = message.ReadFloat();
 }
 void s2c_stub_OnResSend(Lidgren.Network.NetIncomingMessage im, S2C.Message.ResSend data)
 {
     if (data.ret == (short)S2C.Message.Flag.kFlagFail)
     {
         Console.WriteLine("Sending message to {0} was failed. Result = [{1}:{2}].", data.to_id, data.ret, data.ret_message);
     }
 }
        public override void Decode(Lidgren.Network.NetIncomingMessage msg)
        {
            byte temp = msg.ReadByte();
            if (temp > TeamCirclesInOrderHelper.nextToClick)
                TeamCirclesInOrderHelper.nextToClick = temp;

            buttonClicked = msg.ReadByte();
            if (buttonClicked != 255)
            {

                spawnAnimation(new Vector2(buttonPos(buttonClicked).X + 18, buttonPos(buttonClicked).Y + 18), msg.ReadBoolean());
                buttonClicked = 255;
            }

            buttons = new List<byte>(5);
            buttonText = new List<byte>(5);
            for (int i = 0; i < 5; i++)
            {
                temp = msg.ReadByte();
                if (temp != 255)
                    buttons.Add(temp);
                buttonText.Add((byte)((4 * i) + player.ID()));
            }
            for (int i = buttons.Count; i < 5; i++)
                buttonText.RemoveAt(0);
        }
Beispiel #11
0
 public static new ChatMessage decode(ref Lidgren.Network.NetIncomingMessage msg)
 {
     ChatMessage cm = new ChatMessage (Packet.decode (ref msg).ClientId);
     cm.Pseudo = msg.ReadString ();
     cm.Message = msg.ReadString ();
     return cm;
 }
Beispiel #12
0
 public override void encode(ref Lidgren.Network.NetOutgoingMessage msg)
 {
     base.encode (ref msg);
     msg.Write (pseudo);
     msg.Write(color.R);
     msg.Write(color.G);
     msg.Write(color.B);
 }
        public override NetworkMessage Read(Lidgren.Network.NetIncomingMessage msgIn)
        {
            base.Read(msgIn);

            values.FromByteArray(NetworkMessage.ReadByteBuffer(msgIn));

            return this;
        }
 void s2c_stub_OnNotifyLogout(Lidgren.Network.NetIncomingMessage im, S2C.Message.NotifyLogout data)
 {
     Console.WriteLine("{0} leaved out.", data.logout_id);
     if (data.logout_id == this.id)
     {
         Close();
     }            
 }
        public override NetworkMessage Write(Lidgren.Network.NetOutgoingMessage msgOut)
        {
            base.Write(msgOut);

            NetworkMessage.WriteByteBuffer(values.ToByteArray(), msgOut);

            return this;
        }
Beispiel #16
0
 protected override void ReadData(Lidgren.Network.NetIncomingMessage Message)
 {
     p = Game.FindPlayer(Message.ReadInt32());
     //TODO: nrodine3, add the player instead. Possibly merge with PlayerAdd message...?
     if (p != null) {
         p.Read(Message);
     }
 }
Beispiel #17
0
 public override void encode(ref Lidgren.Network.NetOutgoingMessage msg)
 {
     base.encode (ref msg);
     msg.Write(added);
     msg.Write(position.X);
     msg.Write(position.Y);
     msg.Write(blockType);
     msg.Write(layer);
 }
        void s2c_stub_OnNotifySendAll(Lidgren.Network.NetIncomingMessage im, S2C.Message.NotifySendAll data)
        {
            Console.WriteLine("OnNotifySendAll...[ThreadID:{0}]", Thread.CurrentThread.ManagedThreadId);

            if (data.from_id == id)
                return;

            Console.WriteLine("[{0}] {1}", data.from_id, data.message);
        }
Beispiel #19
0
 public static new BlockUpdate decode(ref Lidgren.Network.NetIncomingMessage msg)
 {
     BlockUpdate bu = new BlockUpdate (Packet.decode (ref msg).ClientId);
     bu.added = msg.ReadBoolean ();
     bu.position = new Vector2f(msg.ReadFloat(), msg.ReadFloat());
     bu.blockType = msg.ReadByte();
     bu.layer = msg.ReadByte();
     return bu;
 }
 void Client_StatusChanged(object sender, Lidgren.Library.Network.NetStatusEventArgs e)
 {
     if (Program.Client.Status == Lidgren.Library.Network.NetConnectionStatus.Connected)
     {
         DialogResult = DialogResult.OK;
     }
     if (Program.Client.Status == Lidgren.Library.Network.NetConnectionStatus.Disconnected && DialogResult != DialogResult.Cancel)
     {
         // Retry connexion
         Program.Client.Connect(Program.AppConfig.Host, int.Parse(Program.AppConfig.Port));
     }
 }
 public void Encode(Lidgren.Network.NetOutgoingMessage msg)
 {
     msg.Write((short)cursorPosition.X);
     msg.Write((short)cursorPosition.Y);
     //msg.Write(Mouse.GetState().LeftButton.IsClicked());
     msg.Write((byte)status);
     if (puzzle != null)
     {
         msg.Write(puzzle.ID());
         puzzle.Encode(msg);
     }
     else
         msg.Write((byte)0);
 }
Beispiel #22
0
        protected void OnServerAnswer(Lidgren.Network.NetIncomingMessage msg)
        {
            //SpaceWar2006.GameSystem.GameServerInfo info = p as SpaceWar2006.GameSystem.GameServerInfo;
            SpaceWar2006.GameSystem.GameServerInfo info;
            //if (info == null)
            {
                string p = msg.ReadString();
                info = new SpaceWar2006.GameSystem.GameServerInfo(p);
            }
            ListViewItem lvi=FindServer(msg.SenderEndpoint);
            bool add = false;

            string[] subitems = new string[5];
            if (lvi == null)
            {
                lvi = new ListViewItem();
                lvi.Tag = msg.SenderEndpoint.ToString();
                add = true;
            }

            //subitems[1] = msg.SenderEndpoint.ToString();

            if (info != null)
            {
                subitems[0] = msg.SenderEndpoint.ToString();
                subitems[1] = info.Map;
                subitems[2] = info.GameType;
                subitems[3] = info.NumPlayers.ToString() + "/" + info.MaxPlayers.ToString();
                subitems[4] = info.Password.ToString();
                lvi.Text = info.ServerName;
            }

            lvi.SubItems.Clear();
            lvi.SubItems.AddRange(subitems);

            if (info != null)
            {
                lvi.Text = info.ServerName;
            }
            else
            {
                lvi.Text = "???";
            }

            if(add)
                ServerList.Items.Add(lvi);
        }
        public void Decode(Lidgren.Network.NetIncomingMessage msg)
        {
            this.Visible = true;
            cursorPosition.X = msg.ReadInt16();
            cursorPosition.Y = msg.ReadInt16();
            //if (msg.ReadBoolean())
            status = msg.ReadByte();

            byte remotePuzzleType = msg.ReadByte();
            if (puzzle.ID() != remotePuzzleType && remotePuzzleType != 0)
            {
                if (puzzle != null)
                    Game.Components.Remove(puzzle);
                puzzle = remotePuzzleType.CreateFromID(Game, player);
                puzzle.Visible = true;
            }

            puzzle.Decode(msg);
        }
Beispiel #24
0
 protected override void WriteData(Lidgren.Network.NetOutgoingMessage Message)
 {
     Message.Write(Parent.ToString());
     this.Code.Write(Message);
 }
Beispiel #25
0
 public static void Answer(Lidgren.Network.NetIncomingMessage msg)
 {
     GameSystem.GameServerInfo info = new SpaceWar2006.GameSystem.GameServerInfo(msg.ReadString());
     servers[msg.SenderEndpoint] = info;
 }
Beispiel #26
0
 public StartGameArgs(Lidgren.Network.NetPeer netPeer, short team)
 {
     Team = team;
     NetPeer = netPeer;
 }
Beispiel #27
0
 protected override void WriteData(Lidgren.Network.NetOutgoingMessage Message)
 {
     Location.Write(Message);
 }
Beispiel #28
0
 protected override void ReadData(Lidgren.Network.NetIncomingMessage Message)
 {
     Location.Read(Message);
 }
Beispiel #29
0
 /// <summary>
 /// Get a new color3 from the incoming message
 /// </summary>
 /// <param name="color"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static Color3 Deserialize(this Color3 color, Lidgren.Network.NetIncomingMessage msg)
 {
     var cr = msg.ReadByte();
     var cg = msg.ReadByte();
     var cb = msg.ReadByte();
     return new Color3(BitConverter.ToInt32(new byte[] { cb, cg, cr, 0 }, 0));
 }
Beispiel #30
0
 public static new UserMessage decode(ref Lidgren.Network.NetIncomingMessage msg)
 {
     UserMessage um = new UserMessage (Packet.decode (ref msg).ClientId);
     um.time = DateTime.FromBinary (msg.ReadInt64 ());
     um.input.Up = msg.ReadBoolean ();
     um.input.Down = msg.ReadBoolean ();
     um.input.Left = msg.ReadBoolean ();
     um.input.Right = msg.ReadBoolean ();
     um.position = new Vector2f (msg.ReadFloat (), msg.ReadFloat ());
     um.ticktime = msg.ReadFloat();
     um.EyePosition = new Vector2f(msg.ReadFloat(), msg.ReadFloat());
     um.fallSpeed = msg.ReadFloat();
     um.layer = msg.ReadByte();
     um.noclip = msg.ReadBoolean();
     return um;
 }