Ejemplo n.º 1
0
        /// <summary>Called on Awake</summary>
        public virtual void AwakeState()
        {
            MainTagHash          = Animator.StringToHash(ID.name);              //Store the Main Tag at Awake
            LastStatePendingExit = false;

            foreach (var mod in TagModifiers)
            {
                mod.TagHash = Animator.StringToHash(mod.AnimationTag);          //Convert all the Tags to HashTags
            }

            SpeedSet = null;
            foreach (var set in animal.speedSets) //Find if this state has a Speed Set
            {
                if (set.states.Contains(ID))
                {
                    SpeedSet = set;
                    break;
                }
            }

            EnterExitEvent = animal.OnEnterExitStates.Find(st => st.ID == ID);

            InputValue        = false;
            IgnoreLowerStates = false;
            IsPersistent      = false;
            IsPending         = false;
            OnQueue           = false;
            IsActiveState     = false;
        }
Ejemplo n.º 2
0
        /// <summary>Called on Awake</summary>
        public virtual void AwakeState()
        {
            MainTagHash = Animator.StringToHash(ID.name);                       //Store the Main Tag at Awake

            foreach (var mod in TagModifiers)
            {
                mod.TagHash = Animator.StringToHash(mod.AnimationTag);          //Convert all the Tags to HashTags
            }

            SpeedSet = null;
            foreach (var set in animal.speedSets) //Find if this state has a Speed Set
            {
                if (set.states.Contains(ID))
                {
                    SpeedSet = set;
                    break;
                }
            }

            EnterExitEvent = animal.OnEnterExitStates.Find(st => st.ID == ID);

            ExitState(); //Reset all the values to their default IMPORTANT
        }
Ejemplo n.º 3
0
        void Awake()
        {
            if (MainCamera == null)
            {
                MainCamera = MalbersTools.FindMainCamera().transform;
            }


            if (Anim == null)
            {
                Anim = GetComponentInParent <Animator>();                         //Cache the Animator
            }
            if (RB == null)
            {
                RB = GetComponentInParent <Rigidbody>();                        //Catche the Rigid Body
            }
            SpeedMultiplier = 1;
            GetHashIDs();
            OptionalAnimatorParameters();   //Enable Optional Animator Parameters on the Animator Controller;

            _transform = transform;         //Cache the Transform

            CurrentSpeedSet = new MSpeedSet()
            {
                Speeds = new List <MSpeed>(1)
                {
                    new MSpeed("Default", 1, 4, 4)
                }
            };

            foreach (var set in speedSets)
            {
                set.CurrentIndex = set.StartVerticalIndex;
            }

            if (RB)
            {
                RB.useGravity  = false;
                RB.constraints = RigidbodyConstraints.FreezeRotation;
            }

            GetAnimalColliders();

            //DefaultAnimatorUpdate = Anim.updateMode;//Cache the Update Mode on the Animator to Physics or Normal

            statesD = new Dictionary <int, State>();

            for (int i = 0; i < states.Count; i++)
            {
                if (states[i] != null)
                {
                    if (CloneStates)
                    {
                        State instance = (State)ScriptableObject.CreateInstance(states[i].GetType());
                        instance      = ScriptableObject.Instantiate(states[i]);                            //Create a clone from the Original Scriptable Objects! IMPORTANT
                        instance.name = instance.name.Replace("(Clone)", "(C)");
                        states[i]     = instance;
                    }

                    if (states[i].Active)
                    {
                        statesD.Add(states[i].ID.ID, states[i]);    //Convert it to a Dictionary
                    }
                    states[i].SetAnimal(this);                      //Awake all States
                    states[i].Priority = states.Count - i;
                    states[i].AwakeState();
                }
            }

            for (int i = 0; i < modes.Count; i++)
            {
                modes[i].Priority = modes.Count - i;
                modes[i].AwakeMode(this); //Awake all modes
            }


            InputSource = GetComponentInChildren <IInputSource>();      //Cache the Input Source

            SetPivots();
            CalculateHeight();

            HitDirection = Vector3.zero; //Reset the Damage Direction;
        }
Ejemplo n.º 4
0
        void Awake()
        {
            if (Anim == null)
            {
                Anim = GetComponentInParent <Animator>();                //Cache the Animator
            }
            if (RB == null)
            {
                RB = GetComponentInParent <Rigidbody>();                 //Catche the Rigid Body
            }
            if (MainCamera == null)
            {
                MainCamera = MTools.FindMainCamera()?.transform;         //Find the Camera
            }
            if (Rotator != null && RootBone == null)
            {
                RootBone = Rotator.GetChild(0);           //Find the First Rotator Child  THIS CAUSE ISSUES WITH TIMELINE!!!!!!!!!!!!
            }
            GetHashIDs();

            foreach (var set in speedSets)
            {
                set.CurrentIndex = set.StartVerticalIndex;
            }

            if (RB)
            {
                RB.useGravity  = false;
                RB.constraints = RigidbodyConstraints.FreezeRotation;
            }

            GetAnimalColliders();

            for (int i = 0; i < states.Count; i++)
            {
                if (states[i] != null)
                {
                    if (CloneStates)
                    {
                        State instance = (State)ScriptableObject.CreateInstance(states[i].GetType());
                        instance      = ScriptableObject.Instantiate(states[i]);                            //Create a clone from the Original Scriptable Objects! IMPORTANT
                        instance.name = instance.name.Replace("(Clone)", "(C)");
                        states[i]     = instance;
                    }

                    //statesD.Add(states[i].ID.ID, states[i]);        //Convert it to a Dictionary

                    states[i].SetAnimal(this);                                          //Awake all States
                    states[i].Priority = states.Count - i;
                    states[i].AwakeState();
                }
            }



            //Awake all modes
            for (int i = 0; i < modes.Count; i++)
            {
                modes[i].Priority = modes.Count - i;
                modes[i].AwakeMode(this);
            }

            SetPivots();
            CalculateHeight();

            currentSpeedSet = new MSpeedSet()
            {
                Speeds = new List <MSpeed>(1)
                {
                    new MSpeed("Default", 1, 4, 4)
                }
            };                                                                                                     //Create a Default Speed at Awake


            AlignUniqueID = UnityEngine.Random.Range(0, 99999);
        }