Exemplo n.º 1
0
        public static AnimatedKeyframeViewModel FromSave(AnimationReferenceSave save)
        {
            AnimatedKeyframeViewModel toReturn = new AnimatedKeyframeViewModel();

            toReturn.AnimationName = save.Name;
            toReturn.Time          = save.Time;
            // There's no easing/interpolation supported for animation references

            return(toReturn);
        }
Exemplo n.º 2
0
        public AnimationReferenceSave ToAnimationReferenceSave()
        {
            AnimationReferenceSave toReturn = new AnimationReferenceSave();

            if (string.IsNullOrEmpty(AnimationName))
            {
                throw new InvalidOperationException("Could not convert this to an AnimationReference because it doesn't have a valid Animation name");
            }

            toReturn.Name = this.AnimationName;
            toReturn.Time = this.Time;

            return(toReturn);
        }
        public static string PropertyNameInCode(this AnimationReferenceSave animation)
        {
            string upperCaseRootName;

            var firstChar = animation.RootName.Substring(0, 1).ToUpperInvariant();

            upperCaseRootName = firstChar + animation.RootName.Substring(1) + "Animation";

            if (string.IsNullOrEmpty(animation.SourceObject))
            {
                return(upperCaseRootName);
            }
            else
            {
                return(FileManager.RemovePath(animation.SourceObject) + "." + upperCaseRootName);
            }
        }
Exemplo n.º 4
0
        private static void CreateInstructionForSubAnimation(ICodeBlock currentBlock, AnimationReferenceSave animationReferenceSave, AbsoluteOrRelative absoluteOrRelative, AnimationSave parentAnimation, StateCodeGeneratorContext context)
        {
            currentBlock = currentBlock.Block();

            //var instruction = new FlatRedBall.Instructions.DelegateInstruction(() =>
            //FlatRedBall.Instructions.InstructionManager.Instructions.AddRange(ClickableBushInstance.GrowAnimation));
            //instruction.TimeToExecute = FlatRedBall.TimeManager.CurrentTime + asdf;
            //yield return instruction;

            var isReferencingMissingInstance = !string.IsNullOrEmpty(animationReferenceSave.SourceObject) &&
                                               context.Element.GetInstance(animationReferenceSave.SourceObject) == null;

            ////////////////Early Out///////////////
            if (isReferencingMissingInstance)
            {
                currentBlock.Line($"// This animation references a missing instance named {animationReferenceSave.SourceObject}");
                return;
            }
            /////////////End Early Out/////////////


            string animationName = animationReferenceSave.PropertyNameInCode();

            //animationReferenceSave. FlatRedBall.IO.FileManager.RemovePath(animationReferenceSave.Name) + "Animation";
            if (absoluteOrRelative == AbsoluteOrRelative.Relative)
            {
                animationName += "Relative";
            }

            currentBlock.Line($"var instruction = new FlatRedBall.Instructions.DelegateInstruction(()=>{animationName}.Play({parentAnimation.PropertyNameInCode()}));");
            currentBlock.Line("instruction.TimeToExecute = FlatRedBall.TimeManager.CurrentTime + " + ToFloatString(animationReferenceSave.Time) + ";");


            currentBlock.Line("yield return instruction;");
            currentBlock = currentBlock.End();
        }
        private static void CreateInstructionForSubAnimation(ICodeBlock currentBlock, AnimationReferenceSave animationReferenceSave, AbsoluteOrRelative absoluteOrRelative, AnimationSave parentAnimation)
        {
            currentBlock = currentBlock.Block();

            //var instruction = new FlatRedBall.Instructions.DelegateInstruction(() =>
            //FlatRedBall.Instructions.InstructionManager.Instructions.AddRange(ClickableBushInstance.GrowAnimation));
            //instruction.TimeToExecute = FlatRedBall.TimeManager.CurrentTime + asdf;
            //yield return instruction;

            string animationName = animationReferenceSave.PropertyNameInCode();

            //animationReferenceSave. FlatRedBall.IO.FileManager.RemovePath(animationReferenceSave.Name) + "Animation";
            if (absoluteOrRelative == AbsoluteOrRelative.Relative)
            {
                animationName += "Relative";
            }

            currentBlock.Line($"var instruction = new FlatRedBall.Instructions.DelegateInstruction(()=>{animationName}.Play({parentAnimation.PropertyNameInCode()}));");
            currentBlock.Line("instruction.TimeToExecute = FlatRedBall.TimeManager.CurrentTime + " + ToFloatString(animationReferenceSave.Time) + ";");


            currentBlock.Line("yield return instruction;");
            currentBlock = currentBlock.End();
        }