Ejemplo n.º 1
0
        /// <summary>
        /// Updates our zonelist screen with required info
        /// </summary>
        /// <param name="msg">Incoming message</param>
        public void UpdateList(Lidgren.Network.NetIncomingMessage msg)
        {
            if (Zones.Count > 0)
            {
                foreach (string zname in Zones.Keys)
                {
                    oldZones.Add(zname);
                }
            }
            Zones.Clear();

            int count = msg.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                ZoneSettings _zone = new ZoneSettings();
                _zone.ID          = msg.ReadInt64();
                _zone.Name        = msg.ReadString();
                _zone.Description = msg.ReadString();
                _zone.Address     = msg.ReadIPEndPoint();

                //Add it to our dictionary
                Zones.Add(_zone.Name, _zone);

                //Remove it from our old list
                if (oldZones.Contains(_zone.Name))
                {
                    oldZones.Remove(_zone.Name);
                }
            }

            UpdateButtons();
        }
Ejemplo n.º 2
0
        public ItemChest(Lidgren.Network.NetIncomingMessage r)
        {
            destroyable    = r.ReadBoolean();
            chest_name     = r.ReadString();
            security       = r.ReadString();
            world_top_left = new Point(r.ReadUInt16(), r.ReadUInt16());
            furniture_id   = r.ReadUInt16();
            items          = new List <Cubby>();
            int num_items = r.ReadByte();

            for (int i = 0; i < num_items; i++)
            {
                items.Add(new Cubby(r));
            }
        }
Ejemplo n.º 3
0
 public ActorStats(Lidgren.Network.NetIncomingMessage r)
 {
     life        = new Container(r);
     breath      = new FloatContainer(r);
     power       = new Container(r);
     share_power = r.ReadBoolean();
     ammo        = new Container(r);
     experience  = r.ReadInt32();
     level       = 1 + (int)Math.Pow(experience / 5, .5f);
     if (level > 1)
     {
         experience_to_level = new Container(experience - ((int)Math.Pow((level - 1), 2) * 5), ((int)Math.Pow((level), 2) * 5) - (int)Math.Pow((level - 1), 2) * 5);
     }
     else
     {
         experience_to_level = new Container(experience, (int)Math.Pow((level), 2) * 5);
     }
     complexity             = r.ReadInt32();
     armor                  = r.ReadString();
     jump_speed             = r.ReadSingle();
     run_speed              = r.ReadSingle();
     jump_max_time          = r.ReadSingle();
     jump_cur_time          = 0f;
     can_swim               = r.ReadBoolean();
     boyant                 = r.ReadBoolean();
     jump_can_resume        = r.ReadBoolean();
     life_regen             = r.ReadSingle();
     accum_life_regen       = 0f;
     ammo_regen             = r.ReadSingle();
     accum_ammo_regen       = 0f;
     energy_regen           = r.ReadSingle();
     accum_energy_regen     = 0f;
     water_jump_proficiency = r.ReadSingle();
     max_safe_fall          = r.ReadInt32();
 }
Ejemplo n.º 4
0
        public static string[] ReadStringArray(this Lidgren.Network.NetIncomingMessage im)
        {
            var strs = new string[(int)im.ReadVariableUInt32()];

            for (int i = 0; i < strs.Length; i++)
            {
                strs[i] = im.ReadString();
            }
            return(strs);
        }
Ejemplo n.º 5
0
        public Item(Lidgren.Network.NetIncomingMessage r)
        {
            init_empty();
            item_name = r.ReadString();
            int num_sub_pieces = r.ReadInt32();

            for (int x = 0; x < num_sub_pieces; x++)
            {
                pieces.Add(new ItemPieceEnumeration(r));
            }
            construct_item(item_name);
        }
Ejemplo n.º 6
0
 public PlantUnit(Lidgren.Network.NetIncomingMessage r)
 {
     top_left   = new Point(r.ReadUInt16(), r.ReadUInt16());
     width      = r.ReadByte();
     height     = r.ReadByte();
     piece_type = r.ReadString();
     images     = new ushort[r.ReadByte()];
     for (int x = 0; x < images.Length; x++)
     {
         images[x] = r.ReadUInt16();
     }
 }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
        public Plant(Lidgren.Network.NetIncomingMessage r)
        {
            is_empty    = false;
            plant_index = r.ReadByte();
            name        = r.ReadString();
            top_left    = new Point(r.ReadUInt16(), r.ReadUInt16());
            height      = r.ReadByte();
            int num_pieces = r.ReadByte();

            pieces = new List <PlantUnit>();
            for (int x = 0; x < num_pieces; x++)
            {
                pieces.Add(new PlantUnit(r));
            }
            passable = Exilania.plant_manager.plants[plant_index].passable;
        }
Ejemplo n.º 9
0
        protected override void ReadFrom(Lidgren.Network.NetIncomingMessage incomingMessage)
        {
            base.ReadFrom(incomingMessage);

            StartUpPositions = new Vector2[4];
            for (var i = 0; i < 4; i++)
            {
                StartUpPositions[i].X = incomingMessage.ReadFloat();
                StartUpPositions[i].Y = incomingMessage.ReadFloat();
            }

            TileSetAssetName = incomingMessage.ReadString();

            //todo: refactor usage
            Data = new MapData[15 * 13];
            for (var i = 0; i < Data.Length; i++)
            {
                Data[i].GroundBlockType = (BlockType)incomingMessage.ReadByte();
                Data[i].FringeBlockType = (BlockType)incomingMessage.ReadByte();
                Data[i].FringeItemType  = (ItemType)incomingMessage.ReadByte();
            }
        }
 public override void ReadObject(Lidgren.Network.NetIncomingMessage msg)
 {
     Color      = msg.ReadColor();
     RenderSize = msg.ReadInt32();
     Source     = new Uri(msg.ReadString());
 }
Ejemplo n.º 11
0
 public override void ReadObject(Lidgren.Network.NetIncomingMessage msg)
 {
     base.ReadObject(msg);
     Name = msg.ReadString();
 }
Ejemplo n.º 12
0
 public static void Answer(Lidgren.Network.NetIncomingMessage msg)
 {
     GameSystem.GameServerInfo info = new SpaceWar2006.GameSystem.GameServerInfo(msg.ReadString());
     servers[msg.SenderEndpoint] = info;
 }