示例#1
0
        public static Effect GetEffect(uint kind)
        {
            Effect e = null;

            e = Factory.Instance.CreateObject(kind) as Effect;
            if (e == null)
            {
                return(null);
            }

            // Attach static script info
            EffectInfo ei = new EffectInfo();

            if (Effect.EffectInfos.TryGetValue(kind, out ei))
            {
                e.Information = ei;
            }

            return(e);
        }
示例#2
0
文件: Effect.cs 项目: kamilion/WISP
        public static Effect GetEffect(uint kind)
        {
            Effect e = null;

            e = Factory.Instance.CreateObject(kind) as Effect;
            if (e == null)
            {
                return null;
            }

            // Attach static script info
            EffectInfo ei = new EffectInfo();
            if (Effect.EffectInfos.TryGetValue(kind, out ei))
            {
                e.Information = ei;
            }

            return e;
        }
示例#3
0
        public static int ReadStaticEffectData()
        {
            try
            {
#if !SILVERLIGHT
                EffectInfos = new Dictionary <uint, EffectInfo>();
                XPathNavigator nav = null;

                XPathDocument     docNav        = null;
                XPathNodeIterator NodeIter      = null;
                String            strExpression = null;

                // Open the XML.
                docNav = XMLHelper.LoadDocument(Environment.CurrentDirectory + "\\Config\\Effects.xml", true);
                // Create a navigator to query with XPath.
                nav           = docNav.CreateNavigator();
                strExpression = "//Effects/Effect";
                NodeIter      = nav.Select(strExpression);

                int numLoaded = 0;

                //Iterate through the results showing the element value.
                while (NodeIter.MoveNext())
                {
                    EffectInfo ei = new EffectInfo();
                    ei.DurationKind = (EffectDurationType)Enum.Parse(typeof(EffectDurationType), NodeIter.Current.SelectSingleNode("DurationKind").Value);
                    ei.Duration     = NodeIter.Current.SelectSingleNode("Duration").ValueAsLong;
                    ei.Group        = NodeIter.Current.SelectSingleNode("Group").Value;
                    ei.DisplayName  = NodeIter.Current.SelectSingleNode("DisplayName").Value;
                    ei.Description  = NodeIter.Current.SelectSingleNode("Description").Value;
                    ei.TickLength   = NodeIter.Current.SelectSingleNode("TickLength").ValueAsLong;

                    XPathNodeIterator ingIt     = NodeIter.Current.Select("./EventsToListenTo/Event");
                    GameEventType[]   listeners = new GameEventType[ingIt.Count];
                    int i = 0;
                    while (ingIt.MoveNext())
                    {
                        string        strRes = ingIt.Current.GetAttribute("type", "");
                        GameEventType eType  = (GameEventType)Enum.Parse(typeof(GameEventType), strRes);
                        listeners[i] = eType;
                        i++;
                    }
                    ei.EventsToListenTo = listeners;
                    ei.EffectKind       = Factory.GetStableHash(ei.DisplayName);
                    Console.WriteLine("Loaded Effect data for " + ei.DisplayName);
                    if (EffectInfos.ContainsKey(ei.EffectKind))
                    {
                        Console.WriteLine("Skipping loading Effect due to Effect name collision for " + ei.DisplayName);
                        continue;
                    }
                    numLoaded++;
                    EffectInfos.Add(ei.EffectKind, ei);
                }

                return(numLoaded);
#endif
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Error loading Effects: " + e.Message);
            }

            return(-1);
        }
示例#4
0
文件: Effect.cs 项目: kamilion/WISP
        public static int ReadStaticEffectData()
        {
            try
            {
            #if !SILVERLIGHT
                EffectInfos = new Dictionary<uint, EffectInfo>();
                XPathNavigator nav = null;

                XPathDocument docNav = null;
                XPathNodeIterator NodeIter = null;
                String strExpression = null;

                // Open the XML.
                docNav = XMLHelper.LoadDocument(Environment.CurrentDirectory + "\\Config\\Effects.xml", true);
                // Create a navigator to query with XPath.
                nav = docNav.CreateNavigator();
                strExpression = "//Effects/Effect";
                NodeIter = nav.Select(strExpression);

                int numLoaded = 0;

                //Iterate through the results showing the element value.
                while (NodeIter.MoveNext())
                {
                    EffectInfo ei = new EffectInfo();
                    ei.DurationKind = (EffectDurationType)Enum.Parse(typeof(EffectDurationType), NodeIter.Current.SelectSingleNode("DurationKind").Value);
                    ei.Duration = NodeIter.Current.SelectSingleNode("Duration").ValueAsLong;
                    ei.Group = NodeIter.Current.SelectSingleNode("Group").Value;
                    ei.DisplayName = NodeIter.Current.SelectSingleNode("DisplayName").Value;
                    ei.Description = NodeIter.Current.SelectSingleNode("Description").Value;
                    ei.TickLength = NodeIter.Current.SelectSingleNode("TickLength").ValueAsLong;

                    XPathNodeIterator ingIt = NodeIter.Current.Select("./EventsToListenTo/Event");
                    GameEventType[] listeners = new GameEventType[ingIt.Count];
                    int i = 0;
                    while (ingIt.MoveNext())
                    {
                        string strRes = ingIt.Current.GetAttribute("type", "");
                        GameEventType eType = (GameEventType)Enum.Parse(typeof(GameEventType), strRes);
                        listeners[i] = eType;
                        i++;
                    }
                    ei.EventsToListenTo = listeners;
                    ei.EffectKind = Factory.GetStableHash(ei.DisplayName);
                    Console.WriteLine("Loaded Effect data for " + ei.DisplayName);
                    if(EffectInfos.ContainsKey(ei.EffectKind))
                    {
                        Console.WriteLine("Skipping loading Effect due to Effect name collision for " + ei.DisplayName);
                        continue;
                    }
                    numLoaded++;
                    EffectInfos.Add(ei.EffectKind, ei);
                }

                return numLoaded;
            #endif
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Error loading Effects: " + e.Message);
            }

            return -1;
        }