Exemplo n.º 1
0
 public Dialog()
 {
     m_Speech     = new Hashtable();
     m_Choice     = new Hashtable();
     m_Start      = new ArrayList();
     m_Init       = new ArrayList();
     m_SpeechList = new ArrayList();
     m_ChoiceList = new ArrayList();
     m_Outfit     = new Outfit();
     m_Props      = new NPCProps();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the properties defined by the props settings
        /// </summary>
        private void InitProps()
        {
            ClearProps();

            if (m_Dialog == null)
            {
                return;
            }

            try
            {
                NPCProps p = m_Dialog.Props;

                FightMode = (FightMode)Enum.Parse(typeof(FightMode), p.FightMode, false);
                AI        = (AIType)Enum.Parse(typeof(AIType), string.Format("AI_{0}", p.AI, false));

                Fame  = p.Fame;
                Karma = p.Karma;

                if (IsValidValue(p.Hits))
                {
                    if (IsSingleValue(p.Hits))
                    {
                        SetHits(GetValue(p.Hits));
                    }
                    else
                    {
                        SetHits(GetValues(p.Hits)[0], GetValues(p.Hits)[1]);
                    }
                }

                if (IsValidValue(p.Stam))
                {
                    if (IsSingleValue(p.Stam))
                    {
                        SetStam(GetValue(p.Stam));
                    }
                    else
                    {
                        SetStam(GetValues(p.Stam)[0], GetValues(p.Stam)[1]);
                    }
                }

                if (IsValidValue(p.Mana))
                {
                    if (IsSingleValue(p.Mana))
                    {
                        SetMana(GetValue(p.Mana));
                    }
                    else
                    {
                        SetMana(GetValues(p.Mana)[0], GetValues(p.Mana)[1]);
                    }
                }

                if (IsValidValue(p.Damage))
                {
                    if (IsSingleValue(p.Damage))
                    {
                        SetDamage(GetValue(p.Damage));
                    }
                    else
                    {
                        SetDamage(GetValues(p.Damage)[0], GetValues(p.Damage)[1]);
                    }
                }

                for (int i = 0; i < 5; i++)
                {
                    string d = p.Damages[i];
                    string r = p.Resistances[i];

                    if (IsValidValue(d))
                    {
                        if (IsSingleValue(d))
                        {
                            SetDamageType((ResistanceType)i, GetValue(d));
                        }
                        else
                        {
                            SetDamageType((ResistanceType)i, GetValues(d)[0], GetValues(d)[1]);
                        }
                    }

                    if (IsValidValue(r))
                    {
                        if (IsSingleValue(r))
                        {
                            SetResistance((ResistanceType)i, GetValue(r));
                        }
                        else
                        {
                            SetResistance((ResistanceType)i, GetValues(r)[0], GetValues(r)[1]);
                        }
                    }
                }

                if (p.Mount != null && p.Mount.Length > 0)
                {
                    try
                    {
                        Type t = FindType(p.Mount);

                        if (t != null)
                        {
                            object obj = Activator.CreateInstance(t);

                            IMount mount = obj as IMount;

                            if (mount != null)
                            {
                                (mount as Mobile).Hue = p.MountHue;
                                mount.Rider           = this;
                            }
                            else
                            {
                                Mobile m = obj as Mobile;
                                Item   i = obj as Item;

                                if (m != null)
                                {
                                    m.Delete();
                                }

                                if (i != null)
                                {
                                    i.Delete();
                                }
                            }
                        }
                    }
                    catch {}

                    for (int i = 0; i < p.Properties.Count; i++)
                    {
                        try
                        {
                            string prop = p.Properties[i] as string;
                            string val  = p.Values[i] as string;

                            PropertyInfo pinfo = GetType().GetProperty(prop);

                            if (pinfo != null)
                            {
                                Server.Commands.Properties.InternalSetValue(null, null, this, pinfo, pinfo.Name, val, false);
                            }
                        }
                        catch {}
                    }
                }
            }
            catch (Exception err)
            {
                Console.WriteLine("An error occurred when configuring a DialogNPC with the {0} datafile", DialogName);
                Console.WriteLine(err.ToString());
            }
        }
Exemplo n.º 3
0
		public Dialog()
		{
			m_Speech = new Hashtable();
			m_Choice = new Hashtable();
			m_Start = new ArrayList();
			m_Init = new ArrayList();
			m_SpeechList = new ArrayList();
			m_ChoiceList = new ArrayList();
			m_Outfit = new Outfit();
			m_Props = new NPCProps();
		}