Ejemplo n.º 1
0
        private DesignItemCol GetFilteredItems(DesignItemCol items, bool foundation, bool hues)
        {
            DesignItemCol buildItems = new DesignItemCol();

            for (int i = 0; i < items.Count; ++i)
            {
                if (!foundation && items[i].Level == 0)
                {
                    continue;
                }

                int z     = foundation ? items[i].Z : (items[i].Z - 7);
                int index = items[i].ItemID;
                int x     = items[i].X;
                int y     = items[i].Y;
                int hue   = 0;

                if (hues)
                {
                    hue = items[i].Hue;
                }

                buildItems.Add(new DesignItem(index, x, y, z, 0, hue));
            }

            return(buildItems);
        }
Ejemplo n.º 2
0
        public void SetItems(DesignItemCol items, bool UseCalculations)
        {
            _items = items;

            if (UseCalculations)
            {
                UpdateSize();
            }
        }
Ejemplo n.º 3
0
        public static BuildResponse BuildDesign(DesignItemCol items)
        {
            if (items.Count == 0)
            {
                return(null);
            }

            Ultima.Client.BringToTop();
            BuildRequestArgs args = new BuildRequestArgs(items);

            return((BuildResponse)ExecuteRequest("UOAR_BuildDesign", new BuildRequestArgs(items)));
        }
Ejemplo n.º 4
0
 private static void WriteUpdatedDesignComponentData(DesignItemCol designItems, BinaryFileWriter binWriter)
 {
     for (int i = 0; i < designItems.Count; ++i)
     {
         binWriter.WriteInt(COMPONENT_VERSION);
         binWriter.WriteInt(designItems[i].ItemID);
         binWriter.WriteInt(designItems[i].X);
         binWriter.WriteInt(designItems[i].Y);
         binWriter.WriteInt(designItems[i].Z);
         binWriter.WriteInt(designItems[i].Level);                 // level
         binWriter.WriteInt(designItems[i].Hue);
     }
 }
Ejemplo n.º 5
0
        public override DesignData ImportDesign()
        {
            string filename = GetImportFileName();

            if (!File.Exists(filename))
            {
                return(null);
            }

            DesignData    design      = new DesignData();
            DesignItemCol designItems = new DesignItemCol();

            StreamReader reader = new StreamReader(File.OpenRead(filename));

            string[] TextArr;
            string   Text;

            char[] Separator = { ' ' };

            try
            {
                while (reader.Peek() > -1)
                {
                    Text = reader.ReadLine();

                    if (IsMultiBlock(Text))
                    {
                        TextArr = Text.Split(Separator);

                        DesignItem designItem = new DesignItem();
                        designItem.ItemID = short.Parse(TextArr[0]);
                        designItem.X      = int.Parse(TextArr[1]);
                        designItem.Y      = int.Parse(TextArr[2]);
                        designItem.Z      = int.Parse(TextArr[3]);

                        designItems.Add(designItem);
                    }
                }

                design.ImportItems(designItems, true, false);
            }
            catch
            {
            }
            finally
            {
                reader.Close();
            }

            return(design);
        }
Ejemplo n.º 6
0
        private int CalculateMinZ(DesignItemCol items)
        {
            int minZ = 99999;

            for (int i = 0; i < items.Count; ++i)
            {
                if (items[i].Z < minZ)
                {
                    minZ = items[i].Z;
                }
            }

            return(minZ);
        }
Ejemplo n.º 7
0
		public override void OnRequest(OrbClientInfo clientInfo, OrbRequestArgs args)
		{
			FindOnlineMobile(clientInfo);

			if(args == null)
				SendResponse(null);
			else if(!(args is BuildRequestArgs))
				SendResponse(null);
			else if(!this.IsOnline)
				SendResponse(null);

			m_Items = ((BuildRequestArgs)args).Items;

			Mobile.SendMessage("Target the ground where you want to place the building");
			this.Mobile.Target = new BuildDesignTarget(this);
		}
Ejemplo n.º 8
0
        // import design from extracted design data
        public void ImportItems(DesignItemCol items, bool calculateOffsets, bool foundation)
        {
            if (items.Count == 0)
            {
                return;
            }

            _items.Clear();

            for (int i = 0; i < items.Count; ++i)
            {
                DesignItem item = items[i];

                int xoffset = 0;
                int yoffset = 0;
                int zoffset = 0;

                if (!foundation)
                {
                    item.Z += LevelZ[1];
                }

                if (calculateOffsets)
                {
                    xoffset = item.X - items.OriginX;
                    yoffset = item.Y - items.OriginY;
                    zoffset = item.Z - items.OriginZ;
                }
                else
                {
                    xoffset = item.X;
                    yoffset = item.Y;
                    zoffset = item.Z;
                }

                _items.Add(new DesignItem(item.ItemID, xoffset, yoffset, zoffset, GetZLevel(zoffset), item.Hue));
            }

            UpdateSize();
        }
Ejemplo n.º 9
0
        public override void OnRequest(OrbClientInfo clientInfo, OrbRequestArgs args)
        {
            FindOnlineMobile(clientInfo);

            if (args == null)
            {
                SendResponse(null);
            }
            else if (!(args is BuildRequestArgs))
            {
                SendResponse(null);
            }
            else if (!this.IsOnline)
            {
                SendResponse(null);
            }

            m_Items = ((BuildRequestArgs)args).Items;

            Mobile.SendMessage("Target the ground where you want to place the building");
            this.Mobile.Target = new BuildDesignTarget(this);
        }
Ejemplo n.º 10
0
        // Extract the user selected items
        private void StartExtraction(object state)
        {
            ExtractRequestArgs args = CreateExtractRequestArgs();
            // submit the request to the server
            ExtractResponse resp = Connection.ExtractDesign(args);

            if (resp == null)
            {
                RaiseExtractedEvent(null);
                return;
            }
            else
            {
                _items = resp.Items != null ? resp.Items : new DesignItemCol();
            }

            if (_frozen && _mode == ExtractMode.Area)
            {
                for (int i = 0; i < resp.Rects.Count; ++i)
                {
                    ExtractFrozenItems(resp.Rects[i], resp.Map, _hues);
                }
            }

            if (resp == null || resp.Items.Count == 0)
            {
                RaiseExtractedEvent(null);
            }

            DesignData design = null;

            if (resp.Items.Count > 0)
            {
                design = new DesignData(_name, _category, _subsection);
                design.ImportItems(resp.Items, true, _foundation);
            }

            RaiseExtractedEvent(design);
        }
Ejemplo n.º 11
0
        private void btnBuild_Click(object sender, System.EventArgs e)
        {
            if (!_design.IsLoaded)
            {
                _design.Load();
            }

            DesignItemCol items    = GetFilteredItems(_design.Items, _foundation, !_defaultHues);
            BuildResponse response = Connection.BuildDesign(items);

            _design.Unload();

            if (response == null || response.Count == 0)
            {
                moveItemControl1.Enabled = false;
            }
            else
            {
                _serials = response.ItemSerials;
                moveItemControl1.Enabled = true;
            }
        }
Ejemplo n.º 12
0
        public ArrayList ImportDesigns()
        {
            ArrayList designs  = new ArrayList();
            string    filename = GetImportFileName();

            if (filename == null || !File.Exists(filename))
            {
                return(designs);
            }

            try
            {
                using (StreamReader reader = new StreamReader(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)))
                {
                    string        line;
                    char[]        delimiter   = new char[] { '\t' };
                    DesignData    design      = null;
                    DesignItemCol designItems = new DesignItemCol();

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Length == 0)
                        {
                            continue;
                        }

                        string[] Values = line.Split(delimiter);

                        if (Values.Length > 5)                        // this is the multi header line
                        {
                            if (design != null && designItems.Count > 0)
                            {
                                design.ImportItems(designItems, true, true);
                                designs.Add(design);
                                design = null;
                                designItems.Clear();
                            }

                            design = new DesignData("Multi " + designs.Count + 1, "multicache", "misc");
                        }
                        else if (Values.Length == 5)                         // this is a multi component
                        {
                            if (design != null)
                            {
                                DesignItem item = new DesignItem();

                                item.ItemID = Convert.ToInt16(Values[0]);
                                item.X      = Convert.ToInt32(Values[2]);
                                item.Y      = Convert.ToInt32(Values[3]);
                                item.Z      = Convert.ToInt32(Values[4]);

                                if (item.ItemID != 1)
                                {
                                    designItems.Add(item);
                                }
                            }
                        }
                    }

                    reader.Close();

                    if (design != null && designItems.Count > 0)
                    {
                        design.ImportItems(designItems, true, true);
                        designs.Add(design);
                    }
                }
            }
            catch
            {
            }

            return(designs);
        }
Ejemplo n.º 13
0
        public override DesignData ImportDesign()
        {
            string filename = GetImportFileName();

            if (!File.Exists(filename))
            {
                return(null);
            }

            DesignData    design      = new DesignData();
            DesignItemCol designItems = new DesignItemCol();

            char[] Separator = { ' ' };

            try
            {
                XmlDocument document = new XmlDocument();
                document.Load(filename);

                XmlNodeList itemNodes = document.SelectNodes("//export/tile");

                for (int i = 0; i < itemNodes.Count; ++i)
                {
                    XmlNode node  = itemNodes[i];
                    string  Value = null;

                    int id  = 0;
                    int x   = 0;
                    int y   = 0;
                    int z   = 0;
                    int hue = 0;

                    Value = node.Attributes.GetNamedItem("id").Value;

                    if (Value != null && Value.Length > 0)
                    {
                        id = int.Parse(Value);
                    }

                    Value = node.Attributes.GetNamedItem("x").Value;

                    if (Value != null && Value.Length > 0)
                    {
                        x = int.Parse(Value);
                    }

                    Value = node.Attributes.GetNamedItem("y").Value;

                    if (Value != null && Value.Length > 0)
                    {
                        y = int.Parse(Value);
                    }

                    Value = node.Attributes.GetNamedItem("z").Value;

                    if (Value != null && Value.Length > 0)
                    {
                        z = int.Parse(Value);
                    }

                    Value = node.Attributes.GetNamedItem("hue").Value;

                    if (Value != null && Value.Length > 0)
                    {
                        hue = int.Parse(Value);
                    }

                    designItems.Add(new DesignItem(id, x, y, z, GetZLevel(z), hue));
                }

                design.ImportItems(designItems, true, false);
            }
            catch (Exception e)
            {
                design = null;
                MessageBox.Show("The import failed due to the following error.\n" + e.Message);
            }

            return(design);
        }