示例#1
0
        private Expression TMethodOrProperty(string id)
        {
            PerfMon.Start("MethodOrProperty");

            string objectId = null;

            if (M(TokenType.Dot))
            {
                Consume();

                objectId = id;
                id       = T();

                Consume(TokenType.Id);
            }


            Expression result;

            if (M(TokenType.LeftPar))
            {
                result = TMethod(objectId, id);
            }
            else
            {
                result = TProperty(objectId, id);
            }

            PerfMon.Stop("MethodOrProperty");

            return(result);
        }
示例#2
0
        public override void Initialize(InitializeParameters p)
        {
            if (EnableTrace)
            {
                this.trace = new List <Tuple <double, double> >(2048);
            }

            if (!string.IsNullOrEmpty(this.From))
            {
                // Use the From/To properties
                this.CreateSubcomponents();
                this.Subcomponents.Add(new XKeyFrame()
                {
                    Time = "0", Value = this.From, Smoothing = this.Smoothing
                });
                this.Subcomponents.Add(new XKeyFrame()
                {
                    Time = this.Duration, Value = this.To, Smoothing = this.Smoothing
                });
            }

            base.Initialize(p);

            PerfMon.Start("Other-Ani");

            // get targets
            GenerateTargets();
            startValues = new List <double?>(new double?[targets.Count]);

            // collect keyFrames and check for consistency
            keyFrames = this.GetComponents <XKeyFrame>().ToList();
            if (keyFrames.Any(k => k.CurveKeys.Count != targets.Count))
            {
                throw new InvalidOperationException("Number of values in key frames must match number of targets.");
            }
            if (keyFrames.Count < 2)
            {
                throw new InvalidOperationException("Number of key frames must be 2 or more.");
            }
            lastFrame = keyFrames[keyFrames.Count - 1];

            // create curves
            curves = new List <TimeCurve>(targets.Count);
            for (int i = 0; i < targets.Count; i++)
            {
                var curve = new TimeCurve();
                curve.PostLoop = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle;
                curve.PreLoop  = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle;

                for (int j = 0; j < keyFrames.Count; j++)
                {
                    curve.Keys.Add(keyFrames[j].CurveKeys[i]);
                }

                curves.Add(curve);
            }
            PerfMon.Stop("Other-Ani");
        }
示例#3
0
文件: XDo.cs 项目: valsavva/dynacat
        public override void Initialize(InitializeParameters p)
        {
            base.Initialize(p);

            PerfMon.Start("Other-Do");

            actions = Compiler.CompileStatements(this, this.Action);

            PerfMon.Stop("Other-Do");
        }
示例#4
0
        public static List <IAction> CompileStatements(XObject currentObject, string text)
        {
            PerfMon.Start("CompileStatements");

            Instance.Initialize(currentObject, text);
            var result = Instance.CompileStatements();

            PerfMon.Stop("CompileStatements");

            return(result);
        }
示例#5
0
        public override void Initialize(InitializeParameters p)
        {
            base.Initialize(p);

            PerfMon.Start("Other-Tap");

            p.ScreenEngine.tapAreas.Add(this);

            InitActions(this.Action, ref this.pressActions);
            InitActions(this.MoveAction, ref this.moveActions);
            InitActions(this.ReleaseAction, ref this.releaseActions);

            PerfMon.Stop("Other-Tap");
        }
示例#6
0
        public override void Initialize(InitializeParameters p)
        {
            base.Initialize(p);

            PerfMon.Start("Other-KeyFrame");

            animation = (XNumAnimation)this.Parent;

            GenerateValueReaders();
            this.timeReader  = Compiler.CompileExpression <double>(this.Parent, this.Time);
            this.CurrentTime = 0f;

            PerfMon.Stop("Other-KeyFrame");
        }
示例#7
0
        protected T LoadResource <T>(ContentManager content, string buildProcessor, string defaultInExtension, string defaultOutExtension, string importer = "")
        {
#if DEBUG
            Console.WriteLine("==> Loading resource {0} Source: {1}", this.Id, this.Source);
#endif

            XResourceBundle r = (XResourceBundle)this.Parent;

            string fileName = Path.Combine(r.RootFolder.Replace('/', Path.DirectorySeparatorChar), this.Source);

#if WINDOWS
            var inFile = fileName;
            if (string.IsNullOrEmpty(Path.GetExtension(fileName)))
            {
                inFile = Path.ChangeExtension(inFile, defaultInExtension);
            }
            inFile = Path.Combine(Directory.GetCurrentDirectory(), content.RootDirectory, inFile);

            var outFile = Path.ChangeExtension(Path.Combine(Directory.GetCurrentDirectory(), content.RootDirectory, fileName), defaultOutExtension);

            var outputPath = Path.GetDirectoryName(inFile);

            if (File.Exists(inFile) &&
                (!File.Exists(outFile) || File.GetLastWriteTimeUtc(inFile) > File.GetLastWriteTimeUtc(outFile)))
            {
                using (Lunohod.ContentLoading.ContentBuilder b = new ContentLoading.ContentBuilder(outputPath))
                {
                    b.Add(inFile, this.Source, importer, buildProcessor);
                    string error = b.Build();

                    if (!string.IsNullOrEmpty(error))
                    {
                        throw new InvalidOperationException(string.Format("Could not compile resource: {0}", this.Source));
                    }
                }
            }
#endif
            PerfMon.Start("LoadResource");

            var result = content.Load <T>(fileName);

            PerfMon.Stop("LoadResource");

            return(result);
        }
示例#8
0
        public override void Initialize(InitializeParameters p)
        {
            base.Initialize(p);

            GameEngine.Instance.PauseLevelSoundEffects += HandleSystemPause;
            GameEngine.Instance.StopLevelSoundEffects  += HandleSystemStop;

            PerfMon.Start("Other-Sfx");

            this.soundFile = (XSoundResource)this.FindGlobal(this.FileId);

            if (this.soundFile == null)
            {
                throw new InvalidOperationException(string.Format("Sound effect resource with id '{0}' was not found", this.FileId));
            }

            this.soundFile.CheckOutInstance(this);

            PerfMon.Stop("Other-Sfx");
        }
示例#9
0
        public static IExpression <T> CompileExpression <T>(XObject currentObject, string text)
        {
            if (typeof(T) == typeof(double))
            {
                double numValue;
                if (double.TryParse(text, out numValue))
                {
                    return((IExpression <T>) new NumConstant(numValue));
                }
            }

            PerfMon.Start("CompileExpression");

            Instance.Initialize(currentObject, text);
            var result = Instance.CompileExpression <T>();

            PerfMon.Stop("CompileExpression");

            return(result);
        }
示例#10
0
        public override void Initialize(InitializeParameters p)
        {
            base.Initialize(p);

            PerfMon.Start("Other-SetBase");

            runnables = new List <IRunnable>();
            CollectRunnables(this, runnables);

            for (int i = 0; i < runnables.Count; i++)
            {
                runnables[i].InProgress = false;
            }

            if (this.inProgress)
            {
                this.Start();
            }

            PerfMon.Stop("Other-SetBase");
        }