Exemplo n.º 1
0
        // Legacy... binary serialization only used in v1.00, deserialization preserved to migrate data.
        public static SR_Rune Deserialize(GenericReader reader, int version)
        {
            SR_Rune rune = null;

            string name       = reader.ReadString();
            bool   isRunebook = reader.ReadBool();

            Map     targetMap = reader.ReadMap();
            Point3D targetLoc = reader.ReadPoint3D();

            if (isRunebook)
            {
                rune = new SR_Rune(name, isRunebook);
            }
            else
            {
                rune = new SR_Rune(name, targetMap, targetLoc);
            }

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                rune.AddRune(SR_Rune.Deserialize(reader, version));
            }

            return(rune);
        }
Exemplo n.º 2
0
        public override void OnResponse(Mobile mob, string text)
        {
            text = text.Trim();

            if (text.Length > 40)
            {
                text = text.Substring(0, 40);
            }

            if (text.Length > 0)
            {
                SR_Rune rune = null;
                if (this.IsRunebook)
                {
                    rune = new SR_Rune(text, true);
                }
                else
                {
                    rune = new SR_Rune(text, this.TargetMap, this.TargetLoc);
                }

                if (this.RuneAcc.ChildRune == null)
                {
                    this.RuneAcc.AddRune(rune);
                }
                else
                {
                    this.RuneAcc.ChildRune.AddRune(rune);
                }
            }

            SR_Gump.Send(mob, this.RuneAcc);
        }
Exemplo n.º 3
0
        public void DisplayRunebooks(int y, int h, int w, int tiers)
        {
            this.AddBackground(0, y, w, h, 9270);
            this.AddImageTiled(10, y + 10, w - 20, h - 20, 2624);
            this.AddAlphaRegion(10, y + 10, w - 20, h - 20);
            for (int i = tiers, j = 1; i > 0; i--, j++)
            {
                this.AddBackground(j * 5, y + 37, ((i - 1) * 5) + 278, 42, 9270);
                if (i == 1)
                {
                    this.AddImageTiled((j * 5) + 10, y + 47, ((i - 1) * 5) + 258, 22, 2624);
                    this.AddAlphaRegion((j * 5) + 10, y + 47, ((i - 1) * 5) + 258, 22);
                }
            }

            SR_Rune rune = this.RuneAcc.Runes[this.RuneAcc.PageIndex];

            this.AddItem(SR_Utilities.ItemOffsetX(rune), y + SR_Utilities.ItemOffsetY(rune) + 12, SR_Utilities.RunebookID, SR_Utilities.ItemHue(rune));
            this.AddLabelCropped(35, y + 12, w - 108, 20, 2100, rune.Name);
            this.AddButton(w - 70, y + 10, 4014, 4016, 5, GumpButtonType.Reply, 0);
            this.AddButton(w - 40, y + 10, 4017, 4019, 4, GumpButtonType.Reply, 0);

            if (tiers > 0)
            {
                rune = this.RuneAcc.ChildRune;
                this.AddItem(SR_Utilities.ItemOffsetX(rune) + tiers * 5, y + SR_Utilities.ItemOffsetY(rune) + 12 + 37, SR_Utilities.RunebookID, SR_Utilities.ItemHue(rune));
                this.AddLabelCropped(35 + tiers * 5, y + 12 + 37, 170, 20, 2100, rune.Name);
                this.AddButton(w - 70, y + 10 + 37, 4014, 4016, 7, GumpButtonType.Reply, 0);
                this.AddButton(w - 40, y + 10 + 37, 4017, 4019, 6, GumpButtonType.Reply, 0);
            }
            // AddButton(238, 30 + bgY + 10, 4011, 4013, 0, GumpButtonType.Reply, 0);
        }
Exemplo n.º 4
0
 public static int ItemOffsetX(SR_Rune rune)
 {
     if (rune.IsRunebook)
     {
         return(-1);
     }
     return(-2);
 }
Exemplo n.º 5
0
        private static SR_Rune AddTree(LocationTree tree, Map map)
        {
            SR_Rune runeBook = new SR_Rune(map.ToString(), true);

            for (int i = 0; i < tree.Root.Children.Length; i++)
            {
                runeBook.AddRune(AddNode(tree.Root.Children[i], map));
            }

            return(runeBook);
        }
Exemplo n.º 6
0
        public static int ItemHue(SR_Rune rune)
        {
            int hue = 0;

            if (rune.IsRunebook)
            {
                hue = 1121;
            }
            else
            {
                hue = RuneHues[MapInt(rune.TargetMap) /*+ (rune.House != null) ? 5 : 0*/];
            }

            return(hue);
        }
Exemplo n.º 7
0
        // Legacy... binary serialization only used in v1.00, deserialization preserved to migrate data.
        public static void Deserialize(GenericReader reader, int version)
        {
            List <SR_Rune> runes = new List <SR_Rune>();

            string username = reader.ReadString();

            Console.Write("  Account: {0}... ", username);
            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                runes.Add(SR_Rune.Deserialize(reader, version));
            }
            new SR_RuneAccount(username, runes);
            Console.WriteLine("done.");
        }
Exemplo n.º 8
0
		public void AddRune( SR_Rune rune )
		{
			for( int i = 0; i < Count; i++ )
				if( Runes[i] == rune )
					Runes.RemoveAt(i);

			if( rune.IsRunebook )
			{
				Runes.Insert( RunebookCount, rune );
				RunebookCount++;
			}
			else
			{
				Runes.Add( rune );
				RuneCount++;
			}
		}
Exemplo n.º 9
0
        public static void WriteRuneNode(SR_Rune r, XmlTextWriter xml)
        {
            xml.WriteStartElement(r.IsRunebook ? "Runebook" : "Rune");

            xml.WriteAttributeString("Name", r.Name);
            if (!r.IsRunebook)
            {
                xml.WriteAttributeString("TargetMap", r.TargetMap.ToString());
                xml.WriteAttributeString("X", r.TargetLoc.X.ToString());
                xml.WriteAttributeString("Y", r.TargetLoc.Y.ToString());
                xml.WriteAttributeString("Z", r.TargetLoc.Z.ToString());
            }
            else
                for (int i = 0; i < r.Count; i++)
                    WriteRuneNode(r.Runes[i], xml);

            xml.WriteEndElement();
        }
Exemplo n.º 10
0
        private static SR_Rune AddNode(object o, Map map)
        {
            if (o is ParentNode)
            {
                ParentNode parentNode = o as ParentNode;
                SR_Rune    runeBook   = new SR_Rune(parentNode.Name, true);

                for (int i = 0; i < parentNode.Children.Length; i++)
                {
                    runeBook.AddRune(AddNode(parentNode.Children[i], map));
                }

                return(runeBook);
            }

            ChildNode childNode = o as ChildNode;

            return(new SR_Rune(childNode.Name, map, childNode.Location));
        }
Exemplo n.º 11
0
        public static SR_Rune ReadRuneNode(XmlElement parent)
        {
            if (parent.LocalName == "Runebook")
            {
                SR_Rune runebook = new SR_Rune(parent.GetAttribute("Name"), true);
                if (parent.HasChildNodes)
                {
                    XmlElement child = parent.FirstChild as XmlElement;
                    runebook.AddRune(ReadRuneNode(child));
                    while (child.NextSibling != null)
                    {
                        child = child.NextSibling as XmlElement;
                        runebook.AddRune(ReadRuneNode(child));
                    }
                }
                return runebook;
            }
            //else if( parent.LocalName == "Rune" )

            return new SR_Rune(parent.GetAttribute("Name"), Map.Parse(parent.GetAttribute("TargetMap")), new Point3D(Utility.ToInt32(parent.GetAttribute("X")),Utility.ToInt32(parent.GetAttribute("Y")),Utility.ToInt32(parent.GetAttribute("Z"))));
        }
Exemplo n.º 12
0
        public void AddRune(SR_Rune rune)
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (this.Runes[i] == rune)
                {
                    this.Runes.RemoveAt(i);
                }
            }

            if (rune.IsRunebook)
            {
                this.Runes.Insert(this.RunebookCount, rune);
                this.RunebookCount++;
            }
            else
            {
                this.Runes.Add(rune);
                this.RuneCount++;
            }
        }
Exemplo n.º 13
0
        public static SR_Rune ReadRuneNode(XmlElement parent)
        {
            if (parent.LocalName == "Runebook")
            {
                SR_Rune runebook = new SR_Rune(parent.GetAttribute("Name"), true);
                if (parent.HasChildNodes)
                {
                    XmlElement child = parent.FirstChild as XmlElement;
                    runebook.AddRune(ReadRuneNode(child));
                    while (child.NextSibling != null)
                    {
                        child = child.NextSibling as XmlElement;
                        runebook.AddRune(ReadRuneNode(child));
                    }
                }
                return(runebook);
            }
            //else if( parent.LocalName == "Rune" )

            return(new SR_Rune(parent.GetAttribute("Name"), Map.Parse(parent.GetAttribute("TargetMap")), new Point3D(Utility.ToInt32(parent.GetAttribute("X")), Utility.ToInt32(parent.GetAttribute("Y")), Utility.ToInt32(parent.GetAttribute("Z")))));
        }
Exemplo n.º 14
0
        // Legacy... binary serialization only used in v1.00, deserialization preserved to migrate data.
        public static SR_Rune Deserialize(GenericReader reader, int version)
        {
            SR_Rune rune = null;

            string name = reader.ReadString();
            bool isRunebook = reader.ReadBool();

            Map targetMap = reader.ReadMap();
            Point3D targetLoc = reader.ReadPoint3D();

            if (isRunebook)
                rune = new SR_Rune(name, isRunebook);
            else
                rune = new SR_Rune(name, targetMap, targetLoc);

            int count = reader.ReadInt();
            for (int i = 0; i < count; i++)
                rune.AddRune(SR_Rune.Deserialize(reader, version));

            return rune;
        }
Exemplo n.º 15
0
        public static void WriteRuneNode(SR_Rune r, XmlTextWriter xml)
        {
            xml.WriteStartElement(r.IsRunebook ? "Runebook" : "Rune");

            xml.WriteAttributeString("Name", r.Name);
            if (!r.IsRunebook)
            {
                xml.WriteAttributeString("TargetMap", r.TargetMap.ToString());
                xml.WriteAttributeString("X", r.TargetLoc.X.ToString());
                xml.WriteAttributeString("Y", r.TargetLoc.Y.ToString());
                xml.WriteAttributeString("Z", r.TargetLoc.Z.ToString());
            }
            else
            {
                for (int i = 0; i < r.Count; i++)
                {
                    WriteRuneNode(r.Runes[i], xml);
                }
            }

            xml.WriteEndElement();
        }
Exemplo n.º 16
0
		public override void OnResponse( Mobile mob, string text )
		{
			text = text.Trim();

			if ( text.Length > 40 )
				text = text.Substring( 0, 40 );

			if ( text.Length > 0 )
			{
				SR_Rune rune = null;
				if( IsRunebook )
					rune = new SR_Rune( text, true );
				else
					rune = new SR_Rune( text, TargetMap, TargetLoc );

				if( RuneAcc.ChildRune == null )
					RuneAcc.AddRune( rune );
				else
					RuneAcc.ChildRune.AddRune( rune );
			}

			SR_Gump.Send( mob, RuneAcc );
		}
Exemplo n.º 17
0
        public void AddRune(SR_Rune rune)
        {
            for (int i = 0; i < Count; i++)
            {
                if (Runes[i] == rune)
                {
                    Runes.RemoveAt(i);
                }
            }

            if (rune.IsRunebook)
            {
                Runes.Insert(RunebookCount, rune);
                RunebookCount++;
            }
            else
            {
                Runes.Add(rune);
                RuneCount++;
            }

            rune.ParentRune = this;
        }
Exemplo n.º 18
0
        public void AddRune(SR_Rune rune)
        {
            for (int i = 0; i < this.Count; i++)
                if (this.Runes[i] == rune)
                    this.Runes.RemoveAt(i);

            if (rune.IsRunebook)
            {
                this.Runes.Insert(this.RunebookCount, rune);
                this.RunebookCount++;
            }
            else
            {
                this.Runes.Add(rune);
                this.RuneCount++;
            }
        }
Exemplo n.º 19
0
        private static SR_Rune AddTree( LocationTree tree, Map map )
        {
            SR_Rune runeBook = new SR_Rune( map.ToString(), true );

            for( int i = 0; i < tree.Root.Children.Length; i++ )
                runeBook.AddRune( AddNode( tree.Root.Children[i], map ) );

            return runeBook;
        }
Exemplo n.º 20
0
        private static SR_Rune AddNode( object o, Map map )
        {
            if( o is ParentNode )
            {
                ParentNode parentNode = o as ParentNode;
                SR_Rune runeBook = new SR_Rune( parentNode.Name, true );

                for( int i = 0; i < parentNode.Children.Length; i++ )
                    runeBook.AddRune( AddNode( parentNode.Children[i], map ) );

                return runeBook;
            }

            ChildNode childNode = o as ChildNode;

            return new SR_Rune( childNode.Name, map, childNode.Location );
        }
Exemplo n.º 21
0
 public static int ItemOffsetY( SR_Rune rune )
 {
     if( rune.IsRunebook )
         return -1;
     return 3;
 }
Exemplo n.º 22
0
        public static int ItemHue( SR_Rune rune )
        {
            int hue = 0;

            if( rune.IsRunebook )
                hue = 1121;
            else
                hue = RuneHues[MapInt(rune.TargetMap) /*+ (rune.House != null) ? 5 : 0*/];

            return hue;
        }
Exemplo n.º 23
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int    button = info.ButtonID;
            Mobile mob    = sender.Mobile;

            switch (button)
            {
            case 0:
                break;

            case 1:
                mob.SendMessage("Enter a description:");
                mob.Prompt = new SR_NewRunePrompt(this.RuneAcc, mob.Location, mob.Map);
                Send(mob, SR_Utilities.FetchInfo(mob.Account));
                break;

            case 2:
                mob.SendMessage("Target a location to mark:");
                mob.Target = new SR_NewRuneTarget(this.RuneAcc);
                Send(mob, SR_Utilities.FetchInfo(mob.Account));
                break;

            case 3:
                mob.SendMessage("Enter a description:");
                mob.Prompt = new SR_NewRunePrompt(this.RuneAcc);
                Send(mob, SR_Utilities.FetchInfo(mob.Account));
                break;

            case 4:
                this.RuneAcc.RemoveRune(this.RuneAcc.PageIndex, true);
                Send(mob, SR_Utilities.FetchInfo(mob.Account));
                break;

            case 5:
                this.RuneAcc.ResetPageIndex();
                Send(mob, SR_Utilities.FetchInfo(mob.Account));
                break;

            case 6:
                this.RuneAcc.ChildRune.ParentRune.RemoveRune(this.RuneAcc.ChildRune.ParentRune.PageIndex, true);
                Send(mob, SR_Utilities.FetchInfo(mob.Account));
                break;

            case 7:
                this.RuneAcc.ChildRune.ParentRune.ResetPageIndex();
                Send(mob, SR_Utilities.FetchInfo(mob.Account));
                break;

            default:
                bool moongate = false;
                button -= 10;
                if (button >= 60000)
                {
                    if (this.RuneAcc.ChildRune == null)
                    {
                        this.RuneAcc.RemoveRune(button - 60000);
                    }
                    else
                    {
                        this.RuneAcc.ChildRune.RemoveRune(button - 60000);
                    }
                    Send(mob, SR_Utilities.FetchInfo(mob.Account));
                    break;
                }

                if (button >= 30000)
                {
                    button  -= 30000;
                    moongate = true;
                }
                SR_Rune rune = null;
                if (this.RuneAcc.ChildRune == null)
                {
                    rune = this.RuneAcc.Runes[button];
                }
                else
                {
                    rune = this.RuneAcc.ChildRune.Runes[button];
                }

                if (rune.IsRunebook)
                {
                    if (this.RuneAcc.ChildRune == null)
                    {
                        this.RuneAcc.PageIndex = button;
                    }
                    else
                    {
                        this.RuneAcc.ChildRune.PageIndex = button;
                    }

                    Send(mob, SR_Utilities.FetchInfo(mob.Account));
                }
                else
                {
                    if (mob.Location == rune.TargetLoc && mob.Map == rune.TargetMap)
                    {
                        mob.SendMessage("You are already there.");
                    }
                    else if (!moongate)
                    {
                        mob.PlaySound(0x1FC);
                        mob.MoveToWorld(rune.TargetLoc, rune.TargetMap);
                        mob.PlaySound(0x1FC);
                    }
                    else
                    {
                        if (SR_Utilities.FindItem(typeof(Moongate), mob.Location, mob.Map))
                        {
                            mob.SendMessage("You are standing on top of a moongate, please move.");
                        }
                        else if (SR_Utilities.FindItem(typeof(Moongate), rune.TargetLoc, rune.TargetMap))
                        {
                            mob.SendMessage("There is already a moongate there, sorry.");
                        }
                        else
                        {
                            mob.SendLocalizedMessage(501024);     // You open a magical gate to another location

                            Effects.PlaySound(mob.Location, mob.Map, 0x20E);

                            SR_RuneGate firstGate = new SR_RuneGate(rune.TargetLoc, rune.TargetMap);
                            firstGate.MoveToWorld(mob.Location, mob.Map);

                            Effects.PlaySound(rune.TargetLoc, rune.TargetMap, 0x20E);

                            SR_RuneGate secondGate = new SR_RuneGate(mob.Location, mob.Map);
                            secondGate.MoveToWorld(rune.TargetLoc, rune.TargetMap);
                        }
                    }
                }

                break;
            }
        }