Пример #1
0
        public static void ResetScriptFile(string fileName, out string path)
        {
            ScriptFileMap.TryGetValue(fileName, out path);
            if (path == null)
            {
                path = Path.GetFullPath(Path.Combine(Core.BaseDirectory, ParsedScripts.UberScriptDirectory, fileName));

                if (!File.Exists(path))
                {
                    throw new UberScriptException("Script file did not exist at " + path);
                }
            }
            if (Scripts.ContainsKey(path))
            {
                Scripts.Remove(path);
            }
            foreach (KeyValuePair <string, string> filePair in ScriptFileMap)
            {
                foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
                {
                    XmlScript script = scriptPair.Key;
                    if (ScriptFileMap.ContainsKey(script.ScriptFile) && ScriptFileMap[script.ScriptFile] == path)
                    {
                        // hacky way to resubscribe the timers if at all possible
                        XmlScript.TimerSubscriptionFlag temp = script.TimerSubscriptions;
                        // unsubscribe them
                        script.TimerSubscriptions = XmlScript.TimerSubscriptionFlag.None;
                        // resubscribe them to what they were previously subscribed to
                        script.TimerSubscriptions = temp;

                        script.UpdateScriptTriggerLookup();
                    }
                }
            }
        }
Пример #2
0
 public void Update(float frame)
 {
     if (Scripts.ContainsKey(CurrentAnimationName))
     {
         Scripts[CurrentAnimationName].Update(frame);
     }
 }
Пример #3
0
 public void SetAnimation(string name)
 {
     CurrentAnimationName = name;
     if (Scripts.ContainsKey(CurrentAnimationName))
     {
         Scripts[CurrentAnimationName].Start();
     }
 }
Пример #4
0
 public void AddScript(int level, string script)
 {
     if (!Scripts.ContainsKey(level))
     {
         Scripts.Add(level, new StringBuilder());
     }
     Scripts[level].AppendLine(script);
 }
Пример #5
0
        /// <summary>
        /// Fügt eine Java-Script hinzu oder sersetzt dieses, falls vorhanden
        /// </summary>
        /// <param name="key">Der Schlüssel</param>
        /// <param name="code">Der Code</param>
        public virtual void AddScript(string key, string code)
        {
            var k = key.ToLower();

            if (Scripts.ContainsKey(k))
            {
                Scripts[k] = code;
            }
            else
            {
                Scripts.Add(k, code);
            }
        }
Пример #6
0
        private static IHtmlString RenderScript(HtmlHelper html, Object action)
        {
            String path = FormPath(html.ViewContext.RouteData.Values, action) + ".js";

            if (Scripts.ContainsKey(path))
            {
                return(Scripts[path]);
            }

            if (!ContentExists(html, "~/scripts/application/" + path))
            {
                return(Scripts[path] = MvcHtmlString.Empty);
            }

            BundleTable.Bundles.Add(new ScriptBundle("~/scripts/app/" + path).Include("~/scripts/application/" + path));

            return(Scripts[path] = System.Web.Optimization.Scripts.Render("~/scripts/app/" + path));
        }
Пример #7
0
        private Dictionary <string, string> GetScriptContainer(bool min, string scriptName)
        {
            string scriptPath = FindScript(scriptName);//Server.MapPath("~/scripts/{0}"._Format(scriptName));

            if (!Scripts.ContainsKey(scriptName) &&
                System.IO.File.Exists(scriptPath))
            {
                Scripts.Add(scriptName, System.IO.File.ReadAllText(scriptPath));
            }

            if (!MinScripts.ContainsKey(scriptName) &&
                System.IO.File.Exists(scriptPath))
            {
                JavaScriptCompressor compressor = new JavaScriptCompressor();
                MinScripts.Add(scriptName, compressor.Compress(Scripts[scriptName]));
            }

            Dictionary <string, string> container = min ? MinScripts : Scripts;

            return(container);
        }
Пример #8
0
        public void Start()
        {
            if (CurrentAnimationName == null)
            {
                return;
            }

            for (int i = 0; i < Attacks.Length; i++)
            {
                Attacks[i] = Attack.Default();
            }
            for (int i = 0; i < Grabs.Length; i++)
            {
                Grabs[i] = Catch.Default();
            }
            MotionRate = 1f;

            if (Scripts.ContainsKey(CurrentAnimationName))
            {
                Scripts[CurrentAnimationName].Start();
            }
        }