Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 9
0
 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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 13
0
        public override NetworkMessage Read(Lidgren.Network.NetIncomingMessage msgIn)
        {
            base.Read(msgIn);

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

            return this;
        }
Ejemplo n.º 14
0
 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();
     }            
 }
Ejemplo n.º 15
0
        public override NetworkMessage Write(Lidgren.Network.NetOutgoingMessage msgOut)
        {
            base.Write(msgOut);

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

            return this;
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 20
0
 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 24
0
 protected override void WriteData(Lidgren.Network.NetOutgoingMessage Message)
 {
     Message.Write(Parent.ToString());
     this.Code.Write(Message);
 }
Ejemplo n.º 25
0
 public static void Answer(Lidgren.Network.NetIncomingMessage msg)
 {
     GameSystem.GameServerInfo info = new SpaceWar2006.GameSystem.GameServerInfo(msg.ReadString());
     servers[msg.SenderEndpoint] = info;
 }
Ejemplo n.º 26
0
 public StartGameArgs(Lidgren.Network.NetPeer netPeer, short team)
 {
     Team = team;
     NetPeer = netPeer;
 }
Ejemplo n.º 27
0
 protected override void WriteData(Lidgren.Network.NetOutgoingMessage Message)
 {
     Location.Write(Message);
 }
Ejemplo n.º 28
0
 protected override void ReadData(Lidgren.Network.NetIncomingMessage Message)
 {
     Location.Read(Message);
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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;
 }