Beispiel #1
0
        void Start()
        {
            animations = new Dictionary <string, CustomAnimation>();

            foreach (CustomAnimation workingAnim in initialAnimations)
            {
                AnimationManager.instance.InitializeChildrenScripts(workingAnim);
                animations.Add(workingAnim.animName, workingAnim);

                if (workingAnim.animName == "Idle")
                {
                    idleAnimation = workingAnim;
                }
            }

            if (!animations.ContainsKey("Idle"))
            {
                idleAnimation          = gameObject.AddComponent <CustomAnimation>();
                idleAnimation.animName = "Idle";

                idleAnimation.objAnim = this;

                animations.Add("Idle", idleAnimation);
                idleAnimation.isNewIdle = true;
            }

            currentAnimation = idleAnimation;

            asyncAnimate = AnimationManager.instance.animateObjectsAsync;

            if (!asyncAnimate)
            {
                if (AnimationManager.instance.ObjectsToAnimate == null)
                {
                    AnimationManager.instance.ObjectsToAnimate = new List <AnimatedObject>();
                }

                AnimationManager.instance.ObjectsToAnimate.Add(this);
            }
            else
            {
                if (objAsyncAnimRef == null)
                {
                    objAsyncAnimRef            = gameObject.AddComponent <AsyncAnim>();
                    objAsyncAnimRef.parentAObj = this;
                }

                objAsyncAnimRef.AnimateAsync();
            }
        }
Beispiel #2
0
        public void ChangeAnimation()
        {
            if (currentAnimation.animName == "Death")
            { /*Fill later*/
            }

            if (!animationChangeRequest)
            {
                nextAnimName = idleAnimation.animName;
            }

            if (idleAnimation.isNewIdle)
            {
                idleAnimation.animSprites.Clear();
                idleAnimation.animSprites.Add(currentAnimation.animSprites[currentAnimation.animSprites.Count - 1]);
            }

            animationChangeRequest = false;

            currentAnimation.tickCount = 0;

            currentAnimation = animations[nextAnimName];
        }
Beispiel #3
0
        public void SetupObjectForAnimation(ExtendedGameObject intake)
        {
            if (intake.objAnim == null)
            {
                intake.objAnim = intake.gameObject.AddComponent <AnimatedObject>();
            }

            if (intake.objAnim.childName == null || intake.objAnim.childName == "")
            {
                intake.objAnim.childName = "Animated Object";
            }
            intake.objAnim.childParent = managerName;

            intake.objAnim.parent            = intake;
            intake.objAnim.initialAnimations = new List <CustomAnimation>();

            foreach (string temp in intake.objectAnimations)
            {
                CustomAnimation newAnimation = intake.gameObject.AddComponent <CustomAnimation>();

                newAnimation.animName = temp;
                newAnimation.objAnim  = intake.objAnim;

                newAnimation.childName   = newAnimation.animName;
                newAnimation.childParent = intake.objAnim.childName;

                intake.objAnim.initialAnimations.Add(newAnimation);

                InitializeChildrenScripts(newAnimation);

                if (intake.animateLeftRightSame)
                {
                    if (temp.Length > 8)
                    {
                        string newString = temp.Substring(temp.Length - 7, 6);

                        if (newString == "R Base" || newString == "L Base")
                        {
                            newAnimation.animName.Remove(newAnimation.animName.Length - 6, 5);

                            CustomAnimation newAnimation2 = intake.gameObject.AddComponent <CustomAnimation>();

                            newAnimation2.objAnim = intake.objAnim;

                            newAnimation2.animName = temp;
                            newAnimation2.animName.Remove(newAnimation2.animName.Length - 7, 6);
                            newAnimation2.animName += "L";

                            newAnimation2.childName   = newAnimation.animName;
                            newAnimation2.childParent = intake.objAnim.childName;

                            newAnimation2.flipped = true;

                            intake.objAnim.initialAnimations.Add(newAnimation2);

                            InitializeChildrenScripts(newAnimation2);

                            if (newString == "R Base")
                            {
                                newAnimation2.animName += "L";
                            }
                            else if (newString == "L Base")
                            {
                                newAnimation2.animName += "R";
                            }
                        }
                    }
                }

                InitializeChildrenScripts(intake.objAnim);
            }
        }