コード例 #1
0
        /// <summary>
        ///  Check if the animal can change to fall state if there's no future ground to land on
        /// </summary>
        /// <param name="normalizedTime"></param>
        void Can_Fall(float normalizedTime)
        {
            Debug.DrawRay(animal.Pivot_fall, -animal.transform.up * animal.Pivot_Multiplier * fallRay, Color.red);


            if (Physics.Raycast(animal.Pivot_fall, -animal.transform.up, out JumpRay, animal.Pivot_Multiplier * fallRay, animal.GroundLayer))
            {
                if ((jumpPoint - JumpRay.point.y) <= (stepHeight * animal.ScaleFactor) &&
                    (Vector3.Angle(JumpRay.normal, Vector3.up) < animal.maxAngleSlope))         //If if finding a lower jump point;
                {
                    animal.SetIntID(0);                                                         //Keep the INTID in 0
                    MalbersTools.DebugTriangle(JumpRay.point, 0.1f, Color.red);
                }
                else
                {
                    if (normalizedTime > willFall)
                    {
                        animal.SetIntID(111);                                                   //Set INTID to 111 to activate the FALL transition
                    }
                    MalbersTools.DebugTriangle(JumpRay.point, 0.1f, Color.yellow);
                }
            }
            else
            {
                if (normalizedTime > willFall)
                {
                    animal.SetIntID(111);                            //Set INTID to 111 to activate the FALL transition
                }
                MalbersTools.DebugPlane(animal.Pivot_fall - (animal.transform.up * animal.Pivot_Multiplier * fallRay), 0.1f, Color.red);
            }
        }
コード例 #2
0
ファイル: PlayModeTask.cs プロジェクト: DevilN31/Wilde-Chase
        private void PlayMode(MAnimalBrain brain)
        {
            switch (affect)
            {
            case Affected.Self:

                if (brain.Animal.Mode_TryActivate(modeID, AbilityID))
                {
                    if (lookAtAlign && brain.Target)
                    {
                        brain.StartCoroutine(MalbersTools.AlignLookAtTransform(brain.transform, brain.Target, alignTime));
                    }
                }
                break;

            case Affected.Target:
                if (brain.TargetAnimal && brain.TargetAnimal.Mode_TryActivate(modeID, AbilityID))
                {
                    if (lookAtAlign && brain.Target)
                    {
                        brain.StartCoroutine(MalbersTools.AlignLookAtTransform(brain.TargetAnimal.transform, brain.transform, alignTime));
                    }
                }
                break;

            default:
                break;
            }
        }
コード例 #3
0
        /// <summary>
        /// Used for checking if the animal enables the action
        /// </summary>
        private void OnActionListener()
        {
            if (!oldAnimal)
            {
                return;                                        //Skip if there's no animal
            }
            if (ActionDelay > 0)
            {
                Invoke("OnActionEvent", ActionDelay);          //Invole the Event OnAction)
            }
            else
            {
                OnAction.Invoke(oldAnimal);                    //Invole the Event OnAction
            }

            if (Align && AlingPoint)
            {
                IEnumerator ICo = null;

                if (AlignLookAt)
                {
                    ICo = MalbersTools.AlignLookAtTransform(oldAnimal.transform, AlingPoint, AlignTime, AlignCurve);     //Align Look At the Zone
                }
                else
                {
                    ICo = MalbersTools.AlignTransformsC(oldAnimal.transform, AlingPoint, AlignTime, AlignPos, AlignRot, AlignCurve); //Aling Transform to another transform
                }

                StartCoroutine(ICo);
            }

            StartCoroutine(CheckForCollidersOff());
        }
コード例 #4
0
 /// <summary>
 ///  //Enable Optional Animator Parameters on the Animator Controller;
 /// </summary>
 protected void OptionalAnimatorParameters()
 {
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, Hash.Swim))
     {
         hasSwim = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, Hash.Dodge))
     {
         hasDodge = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, Hash.Fly))
     {
         hasFly = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, Hash.Attack2))
     {
         hasAttack2 = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, Hash.Stunned))
     {
         hasStun = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, Hash.Underwater))
     {
         hasUnderwater = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Float, Hash.UpDown))
     {
         hasUpDown = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Float, Hash.Slope))
     {
         hasSlope = true;
     }
 }
コード例 #5
0
ファイル: Fall.cs プロジェクト: DevilN31/Wilde-Chase
        public override void EnterCoreAnimation()
        {
            UpImpulse = MalbersTools.CleanUpVector(animal.DeltaPos, animal.Forward, animal.Right);   //Clean the Vector from Forward and Horizontal Influence

            IgnoreLowerStates = false;

            FallSpeed = new MSpeed(animal.CurrentSpeedModifier)
            {
                name     = "FallSpeed",
                position = animal.HorizontalSpeed,
                animator = 1,
                rotation = AirRotation.Value
            };

            if (debug && animal.debugStates)
            {
                Debug.Log($"Fall Speed: <B>{FallSpeed.position.Value:F3}</B>");
            }

            animal.UpdateDirectionSpeed = AirControl; //Set the Directional Speed to be Updated depending the Air Control var IMPORTANT
            animal.SetCustomSpeed(FallSpeed, true);

            if (animal.LastState.ID <= 1 && Vector3.Dot(UpImpulse, animal.UpVector) > 0) //means it was on locomotion or idle //Remove Up Impulse
            {
                UpImpulse = Vector3.zero;
            }
        }
コード例 #6
0
        void Start()
        {
            m_Rigidbody.constraints   = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
            m_OrigGroundCheckDistance = m_GroundCheckDistance;

            MainCamera = MalbersTools.FindMainCamera()?.transform;
        }
コード例 #7
0
        public override void AnimationStateEnter()
        {
            if (CurrentAnimTag == AnimTag.FallEdge)
            {
                IgnoreLowerStates = true;
            }
            else if (CurrentAnimTag == MainTagHash)
            {
                UpImpulse = MalbersTools.CleanUpVector(animal.DeltaPos, animal.Forward, animal.Right);   //Clean the Vector from Forward and Horizontal Influence

                IgnoreLowerStates = false;

                var speedMultiplier = Vector3.ProjectOnPlane(animal.Inertia, -animal.GravityDirection);


                FallSpeed = new MSpeed(animal.CurrentSpeedModifier)
                {
                    name     = "FallSpeed",
                    position = (speedMultiplier).magnitude / animal.ScaleFactor,
                    animator = 1,
                    rotation = AirRotation.Value
                };

                animal.UpdateDirectionSpeed = AirControl;
                animal.SetCustomSpeed(FallSpeed, true);
            }
        }
コード例 #8
0
        public override void Reset()
        {
            ID    = MalbersTools.GetInstance <StateID>("Jump");
            Input = "Jump";

            General = new AnimalModifier()
            {
                RootMotion        = true,
                Grounded          = false,
                Sprint            = false,
                OrientToGround    = false,
                CustomRotation    = false,
                IgnoreLowerStates = true, //IMPORTANT!
                Persistent        = false,
                AdditivePosition  = true,
                //AdditiveRotation = true,
                Colliders = true,
                Gravity   = false,
                modify    = (modifier)(-1),
            };

            jumpProfiles = new List <JumpProfile>()
            {
                new JumpProfile()
                {
                    name = "Jump", stepHeight = 0.1f, fallingTime = 0.7f, fallRay = 2, /* ForwardMultiplier = 1,*/ HeightMultiplier = 1, JumpLandDistance = 1.7f
                }
            };
        }
コード例 #9
0
        private void Can_Jump_on_Cliff(float normalizedTime)
        {
            if (normalizedTime >= activeJump.CliffTime.minValue && normalizedTime <= activeJump.CliffTime.maxValue)
            {
                if (debug)
                {
                    Debug.DrawRay(animal.Main_Pivot_Point, animal.GravityDirection * activeJump.CliffLandDistance * animal.ScaleFactor, Color.black);
                }


                if (Physics.Raycast(animal.Main_Pivot_Point, animal.GravityDirection, out JumpRay, activeJump.CliffLandDistance * animal.ScaleFactor, animal.GroundLayer, QueryTriggerInteraction.Ignore))
                {
                    if (debug)
                    {
                        MalbersTools.DebugTriangle(JumpRay.point, 0.1f, Color.black);
                    }

                    var TerrainSlope = Vector3.Angle(JumpRay.normal, animal.UpVector);
                    var DeepSlope    = TerrainSlope > animal.maxAngleSlope;

                    if (!DeepSlope)       //Jump to a jumpable cliff not an inclined one
                    {
                        if (debug)
                        {
                            Debug.Log("<B>Jump</b> State: Exit on a Cliff ");
                        }
                        animal.Grounded   = true; //Force the animal to be grounded so it can find go to Locomotion or IDLE
                        IgnoreLowerStates = false;
                        IsPersistent      = false;
                    }
                }
            }
        }
コード例 #10
0
        public override void OnModeEnter(Mode mode)
        {
            MAnimal animal = mode.Animal;

            var pos = animal.Center;

            var AllColliders = Physics.OverlapSphere(pos, FindRadius, animal.HitLayer);

            Collider MinDistanceCol = null;
            float    Distance       = float.MaxValue;

            foreach (var col in AllColliders)
            {
                if (col.transform.root == animal.transform.root)
                {
                    continue;                                              //Don't Find yourself
                }
                var DistCol = Vector3.Distance(animal.Center, col.transform.position);

                if (Distance > DistCol)
                {
                    Distance       = DistCol;
                    MinDistanceCol = col;
                }
            }

            if (MinDistanceCol)
            {
                animal.StartCoroutine(MalbersTools.AlignLookAtTransform(animal.transform, MinDistanceCol.transform, AlignTime));
            }
        }
コード例 #11
0
        void OnTriggerEnter(Collider other)
        {
            var Root = other.transform.root;

            if (other.isTrigger && TriggerInteraction == QueryTriggerInteraction.Ignore)
            {
                return;                                                                                                                             //just collapse when is a collider what we are hitting
            }
            if (!MalbersTools.Layer_in_LayerMask(other.gameObject.layer, HitLayer))
            {
                return;                                                                      //Just hit what is on the HitMask Layer
            }
            if (Root == Owner.transform)
            {
                return;                                                                    //Don't hit yourself;
            }
            if (!AlreadyHitted.Find(item => item == Root))                                 //if the entering collider is not already on the list add it
            {
                AlreadyHitted.Add(Root);
            }

            if (Root == CurrentAnimal)
            {
                return;                                                           //if the animal is the same, do nothing we already done the logic below
            }
            else
            {
                if (CurrentAnimal)
                {
                    AlreadyHitted = new List <Transform>();                        //Clean the colliders if you had a previus animal
                }
                CurrentAnimal = Root;                                              //Is a new Animal that is enetering the Attack Trigger

                var TargetPos = Root.position;

                var mesh = Root.GetComponentInChildren <Renderer>();
                if (mesh != null)
                {
                    TargetPos = mesh.bounds.center;                                         //Get the mesh Bounds Center
                }
                Vector3 direction = (Owner.position - TargetPos).normalized;                //Calculate the direction of the attack

                var interactable = other.transform.GetComponent <IInteractable>();          //Get the Animal on the Other collider

                interactable?.Interact();

                enemy = Root.GetComponentInChildren <IMDamage>();                           //Get the Animal on the Other collider

                if (enemy != null)                                                          //if the other does'nt have the Damagable Interface dont send the Damagable stuff
                {
                    enemy.HitDirection = direction;
                    enemy.Damage();
                    EnemyStatEnter.ModifyStat(Root.GetComponentInChildren <Stats>()); //Affect Stats
                }
                else if (other.attachedRigidbody && PushForce != 0)                   //If the other has a riggid body and it can be pushed
                {
                    other.attachedRigidbody.AddForce(-direction * PushForce, ForceMode.VelocityChange);
                }
            }
        }
コード例 #12
0
        void Reset()
        {
            MEventListener MeventL = GetComponent <MEventListener>();

            if (MeventL == null)
            {
                MeventL = gameObject.AddComponent <MEventListener>();
            }

            MeventL.Events = new System.Collections.Generic.List <MEventItemListener>(1)
            {
                new MEventItemListener()
            };

            var listener = MeventL.Events[0];

            listener.useTransform = true;
            listener.useVector3   = true;
            listener.useVoid      = false;

            listener.Event = MalbersTools.GetInstance <MEvent>("Follow UI Transform");

            if (listener.Event != null)
            {
                UnityEditor.Events.UnityEventTools.AddPersistentListener(listener.ResponseTransform, SetTransform);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(listener.ResponseVector3, SetScreenCenter);
            }
        }
コード例 #13
0
        void OnEnable()
        {
            if (MainCamera == null)
            {
                MainCamera = MalbersTools.FindMainCamera()?.transform; //Find the Camera
            }
            if (Animals == null)
            {
                Animals = new List <MAnimal>();
            }
            Animals.Add(this);          //Save the the Animal on the current List

            GetInputs(true);

            foreach (var state in states)
            {
                state.ResetState();
            }

            if (isPlayer)
            {
                SetMainPlayer();
            }


            SetBoolParameter  += SetAnimParameter;
            SetIntParameter   += SetAnimParameter;
            SetFloatParameter += SetAnimParameter;
        }
コード例 #14
0
ファイル: MAnimal.cs プロジェクト: nagibator9986/Tetris
        void SetModesListeners(MEventListener listener, string EventName, string ModeName)
        {
            MEvent e = MalbersTools.GetInstance <MEvent>(EventName);

            if (listener.Events.Find(item => item.Event == e) == null)
            {
                var item = new MEventItemListener()
                {
                    Event   = e,
                    useVoid = true, useInt = true, useBool = true,
                };

                ModeID att2 = MalbersTools.GetInstance <ModeID>(ModeName);

                UnityEditor.Events.UnityEventTools.AddObjectPersistentListener <ModeID>(item.ResponseBool, Mode_Pin, att2);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseBool, Mode_Pin_Input);
                UnityEditor.Events.UnityEventTools.AddObjectPersistentListener <ModeID>(item.ResponseInt, Mode_Pin, att2);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(item.ResponseInt, Mode_Pin_Ability);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(item.Response, Mode_Interrupt);

                listener.Events.Add(item);

                Debug.Log("<B>" + EventName + "</B> Added to the Event Listeners");
            }
        }
コード例 #15
0
ファイル: Fall.cs プロジェクト: rurush47/ndvw-ecosystem
        public override void AnimationStateEnter()
        {
            if (CurrentAnimTag == AnimTag.FallEdge)
            {
                //  Debug.Log("Enter Fall Edge Animation");
                IgnoreLowerStates = true;
            }
            else if (InMainTagHash)
            {
                UpImpulse = MalbersTools.CleanUpVector(animal.DeltaPos, animal.Forward, animal.Right);   //Clean the Vector from Forward and Horizontal Influence

                IgnoreLowerStates = false;

                FallSpeed = new MSpeed(animal.CurrentSpeedModifier)
                {
                    name     = "FallSpeed",
                    position = animal.HorizontalSpeed,
                    animator = 1,
                    rotation = AirRotation.Value
                };

                if (debug && animal.debugStates)
                {
                    Debug.Log($"Fall Speed: <B>{FallSpeed.position.Value.ToString("F3")}</B>");
                }


                animal.UpdateDirectionSpeed = AirControl;
                animal.SetCustomSpeed(FallSpeed, true);
            }
        }
コード例 #16
0
ファイル: Jump.cs プロジェクト: rurush47/ndvw-ecosystem
        /// <summary>Check if the animal can change to fall state if there's no future ground to land on</summary>
        private void Check_for_Falling()
        {
            IgnoreLowerStates  = false; //Means that it will directly to fall
            OneCastingFall_Ray = true;
            IsPersistent       = false;

            float RayLength = animal.ScaleFactor * activeJump.JumpLandDistance; //Ray Distance with the Scale Factor

            var MainPivot = animal.Main_Pivot_Point;
            var Direction = animal.GravityDirection;

            if (debug)
            {
                Debug.Log("Doing: <b>" + activeJump.name + "</b>. RayLegth:" + RayLength);
            }

            if (activeJump.JumpLandDistance > 0) //greater than 0 it can complete the Jump on an even Ground
            {
                if (debug)
                {
                    Debug.DrawRay(MainPivot, Direction * RayLength, Color.red, 0.25f);
                }

                if (Physics.Raycast(MainPivot, Direction, out JumpRay, RayLength, animal.GroundLayer, QueryTriggerInteraction.Ignore))
                {
                    if (debug)
                    {
                        Debug.Log("Min Distance to complete " + activeJump.name + " " + JumpRay.distance);
                        MalbersTools.DebugTriangle(JumpRay.point, 0.1f, Color.yellow);
                    }

                    var TerrainSlope = Vector3.Angle(JumpRay.normal, animal.UpVector);
                    var DeepSlope    = TerrainSlope > animal.maxAngleSlope;

                    if (DeepSlope)     //if wefound something but there's a deep slope
                    {
                        if (debug)
                        {
                            Debug.Log("Jump State: Try to Land but the Sloope is too Deep. Exiting Jump State " + TerrainSlope);
                        }
                        IgnoreLowerStates = false;
                        return;
                    }

                    IgnoreLowerStates = true;                           //Means that it can complete the Jump
                    if (debug)
                    {
                        Debug.Log("Can finish the Jump. Going to Jump End");
                    }
                }
                else
                {
                    if (debug)
                    {
                        Debug.Log(activeJump.name + ": Go to Fall.. No ground was found");
                    }
                    IgnoreLowerStates = false;
                }
            }
        }
コード例 #17
0
ファイル: JumpBasic.cs プロジェクト: rurush47/ndvw-ecosystem
        public override void Reset()
        {
            ID    = MalbersTools.GetInstance <StateID>("Jump");
            Input = "Jump";

            SleepFromState = new List <StateID>()
            {
                MalbersTools.GetInstance <StateID>("Fall"), MalbersTools.GetInstance <StateID>("Fly")
            };
            SleepFromMode = new List <ModeID>()
            {
                MalbersTools.GetInstance <ModeID>("Action"), MalbersTools.GetInstance <ModeID>("Attack1")
            };


            General = new AnimalModifier()
            {
                RootMotion        = false,
                Grounded          = false,
                Sprint            = false,
                OrientToGround    = false,
                CustomRotation    = false,
                IgnoreLowerStates = true, //IMPORTANT!
                Persistent        = false,
                AdditivePosition  = true,
                Colliders         = true,
                Gravity           = true,
                modify            = (modifier)(-1),
            };

            ExitFrame = false;
        }
コード例 #18
0
 public virtual void LoadDataPlayerPref()
 {
     if (usePlayerPref && PlayerPrefs.HasKey(PlayerPrefKey))
     {
         Save = MalbersTools.Deserialize <SelectorSave>(PlayerPrefs.GetString(PlayerPrefKey));            //Get the Data from the Player Preff.
     }
 }
コード例 #19
0
        void Reset()
        {
            SetOwner(transform.root);

            EnemyStatEnter = new StatModifier()
            {
                ID     = MalbersTools.GetInstance <StatID>("Health"),
                modify = StatOption.SubstractValue,
                Value  = new Scriptables.FloatReference()
                {
                    UseConstant = true, ConstantValue = 10
                },
            };

            Trigger = GetComponent <Collider>();
            if (!Trigger)
            {
                Trigger = gameObject.AddComponent <BoxCollider>();
            }
            Trigger.isTrigger = true;
            Owner             = transform.root; //Set which is the owner of this AttackTrigger
            this.enabled      = false;



            IMHitLayer mHit = GetComponentInParent <IMHitLayer>();

            if (mHit != null)
            {
                HitLayer           = mHit.HitLayer;
                TriggerInteraction = mHit.TriggerInteraction;
            }
        }
コード例 #20
0
 /// <summary>─Get jumping on a cliff</summary>
 void Can_Jump_on_Cliff(float normalizedTime)
 {
     if (normalizedTime >= Cliff.minValue && normalizedTime <= Cliff.maxValue)
     {
         if (Physics.Raycast(animal.Main_Pivot_Point, -transform.up, out JumpRay, CliffRay * animal.ScaleFactor, animal.GroundLayer))
         {
             if (Vector3.Angle(JumpRay.normal, Vector3.up) < animal.maxAngleSlope)       //Jump to a jumpable cliff not an inclined one
             {
                 if (animal.debug)
                 {
                     Debug.DrawLine(animal.Main_Pivot_Point, JumpRay.point, Color.black);
                     MalbersTools.DebugTriangle(JumpRay.point, 0.1f, Color.black);
                 }
                 animal.SetIntID(110);
             }
         }
         else
         {
             if (animal.debug)
             {
                 Debug.DrawRay(animal.Main_Pivot_Point, -transform.up * CliffRay * animal.ScaleFactor, Color.black);
                 MalbersTools.DebugPlane(animal.Main_Pivot_Point - (transform.up * CliffRay * animal.ScaleFactor), 0.1f, Color.black);
             }
         }
     }
 }
コード例 #21
0
        public override void OnStateMove(float deltaTime)
        {
            if (CurrentAnimTag == MainTagHash)
            {
                if (JumpPressed)
                {
                    JumpPressedMultiplier = Mathf.Lerp(JumpPressedMultiplier, InputValue ? 1 : 0, deltaTime * JumpPressedLerp);
                }

                if (!General.RootMotion)
                {
                    Vector3 ExtraJumpForce = (animal.UpVector * activeJump.HeightMultiplier);
                    animal.AdditivePosition += ExtraJumpForce * deltaTime * JumpPressedMultiplier;
                }
                else
                {
                    Vector3 RootMotionUP = MalbersTools.CleanUpVector(Anim.deltaPosition, animal.Forward, animal.Right); //Get the Up vector of the Animation

                    float UP = Vector3.Dot(RootMotionUP, animal.Up);                                                     //Check if the Jump Root Animation is going  UP;


                    if (UP > 0)
                    {
                        animal.AdditivePosition -= RootMotionUP;                                                       //Remove the default Root Motion Jump
                        animal.AdditivePosition += RootMotionUP * activeJump.HeightMultiplier * JumpPressedMultiplier; //Add the New Root Motion Jump scaled by the Height Multiplier
                    }

                    {
                        Vector3 RootMotionForward = Vector3.ProjectOnPlane(Anim.deltaPosition, animal.Up);
                        animal.AdditivePosition -= RootMotionForward;                                    //Remove the default Root Motion Jump
                        animal.AdditivePosition += RootMotionForward * activeJump.ForwardMultiplier;     //Add the New Root Motion Jump scaled by the Height Multiplier
                    }
                }
            }
        }
コード例 #22
0
        private void Reset()
        {
            DismountInput.GetPressed = InputButton.LongPress;
#if UNITY_EDITOR
            MEvent Dismountkey     = MalbersTools.GetInstance <MEvent>("Dismount Key");
            MEvent MountDismountUI = MalbersTools.GetInstance <MEvent>("Mount Dismount UI");

            if (Dismountkey)
            {
                UnityEditor.Events.UnityEventTools.AddPersistentListener(DismountInput.OnLongPress, Dismountkey.Invoke);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(DismountInput.OnPressedNormalized, Dismountkey.Invoke);
                UnityEditor.Events.UnityEventTools.AddIntPersistentListener(DismountInput.OnInputDown, Dismountkey.Invoke, 0);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(DismountInput.OnInputUp, Dismountkey.Invoke);
            }

            if (MountDismountUI)
            {
                OnStartMounting = new UnityEvent();
                UnityEditor.Events.UnityEventTools.AddBoolPersistentListener(OnStartMounting, MountDismountUI.Invoke, false);
            }

            var malbersinput = GetComponent <MalbersInput>();
            if (malbersinput)
            {
                UnityEditor.Events.UnityEventTools.AddBoolPersistentListener(OnStartMounting, malbersinput.EnableMovement, false);
                UnityEditor.Events.UnityEventTools.AddBoolPersistentListener(OnEndDismounting, malbersinput.EnableMovement, true);
            }
#endif
        }
コード例 #23
0
 void OnDrawGizmos()
 {
     if (meleeCollider)
     {
         MalbersTools.DrawTriggers(meleeCollider.transform, meleeCollider, DebugColor);
     }
 }
コード例 #24
0
 /// <summary>
 ///  //Enable Optional Animator Parameters on the Animator Controller;
 /// </summary>
 protected void OptionalAnimatorParameters()
 {
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, "Swim"))
     {
         hasSwim = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, "Dodge"))
     {
         hasDodge = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, "Fly"))
     {
         hasFly = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, "Attack2"))
     {
         hasAttack2 = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Bool, "Underwater"))
     {
         hasUnderwater = true;
     }
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Float, "UpDown"))
     {
         hasUpDown = true;
     }
 }
コード例 #25
0
ファイル: Fall.cs プロジェクト: rurush47/ndvw-ecosystem
        private bool TryFallSphereCastNonAlloc(Vector3 fall_Pivot, float Multiplier)
        {
            fallHits = Physics.SphereCastNonAlloc(fall_Pivot, animal.RayCastRadius * animal.ScaleFactor, -transform.up, FallHits, Multiplier, animal.GroundLayer, QueryTriggerInteraction.Ignore);

            if (fallHits > 0)
            {
                FallRayCast = FallHits[0];

                DistanceToGround = FallRayCast.distance;

                if (debug)
                {
                    Debug.DrawRay(fall_Pivot, -transform.up * Multiplier, Color.magenta);
                    MalbersTools.DebugPlane(FallRayCast.point, animal.RayCastRadius * animal.ScaleFactor, Color.magenta, true);
                }

                if (!animal.Grounded)
                {
                    var TerrainSlope = Vector3.Angle(FallRayCast.normal, animal.UpVector);
                    var DeepSlope    = TerrainSlope > animal.maxAngleSlope;

                    if (DeepSlope)
                    {
                        if (debug && animal.debugStates)
                        {
                            Debug.Log("Try <B>Fall</B> State: The Animal is on Air but angle SLOPE of the ground found is too Deep");
                        }
                        return(true);
                    }
                }
                else if (animal.Grounded && animal.DeepSlope)     //if wefound something but there's a deep slope
                {
                    if (debug && animal.debugStates)
                    {
                        Debug.Log("Try <B>Fall</B> State: The Ground angle SLOPE is too Deep");
                    }
                    return(true);
                }

                if (animal.Height >= DistanceToGround && !animal.Grounded) //If the distance to ground is very small means that we are very close to the ground
                {
                    if (debug && animal.debugStates)
                    {
                        Debug.Log("Try <B>Fall</B> State: The distance to ground is very small means that we are very close to the ground.// Ground = true");
                    }
                    // animal.Grounded = true;     //This Allow Locomotion and Idle to Try Activate themselves
                    return(false);
                }
            }
            else
            {
                if (debug && animal.debugStates)
                {
                    Debug.Log("Try <B>Fall</B>: There's no Ground beneath the Animal");
                }
                return(true);
            }

            return(false);
        }
コード例 #26
0
        /// <summary>
        /// Update the Data values with the Items values
        /// </summary>
        public virtual void UpdateData(SelectorManager manager)
        {
            for (int i = 0; i < manager.Editor.Items.Count; i++)            //Save the Locked Elements
            {
                Save.Locked[i]      = manager.Editor.Items[i].Locked;
                Save.ItemsAmount[i] = manager.Editor.Items[i].Amount;

                if (Save.UseMaterialChanger && manager.Editor.Items[i].MatChanger)
                {
                    Save.MaterialIndex[i] = manager.Editor.Items[i].MatChanger.AllIndex;
                }

                if (Save.UseActiveMesh && manager.Editor.Items[i].ActiveMesh)
                {
                    Save.ActiveMeshIndex[i] = manager.Editor.Items[i].ActiveMesh.AllIndex;
                }
            }

            Save.FocusedItem = manager.Controller.FocusedItemIndex;

            if (usePlayerPref)
            {
                PlayerPrefs.SetString(PlayerPrefKey, MalbersTools.Serialize <SelectorSave>(Save));
            }


#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }
コード例 #27
0
        void Awake()
        {
            MainCamera = MalbersTools.FindMainCamera();

            graphic = GetComponent <Graphic>();

            ScreenCenter = transform.position;
        }
コード例 #28
0
 void Awake()
 {
     if (MalbersTools.FindAnimatorParameter(Anim, AnimatorControllerParameterType.Int, Hash.Type))
     {
         Anim.SetInteger(Hash.Type, animalTypeID);  //Adjust the layer for the curret animal Type this is of offseting the bones to another pose
     }
     WaterLayer = LayerMask.GetMask("Water");
 }
コード例 #29
0
ファイル: StepTrigger.cs プロジェクト: juanibar10/WOTW
 void OnTriggerExit(Collider other)
 {
     if (!MalbersTools.CollidersLayer(other, _StepsManager.GroundLayer))
     {
         return;       //Ignore layers that are not Ground
     }
     hastrack = false; // if the feet is on the air then can put a track
 }
コード例 #30
0
ファイル: ActionZone.cs プロジェクト: Indirect91/HaHanHakHyun
        void OnTriggerEnter(Collider other)
        {
            if (!MalbersTools.CollidersLayer(other, LayerMask.GetMask("Animal")))
            {
                return;                                                                   //Just accept animal layer only
            }
            if (HeadOnly && !other.name.ToLower().Contains("head"))
            {
                return;                                                             //If is Head Only and no head was found Skip
            }
            Animal newAnimal = other.GetComponentInParent <Animal>();               //Get the animal on the entering collider

            if (!newAnimal)
            {
                return;                                                             //If there's no animal do nothing
            }
            newAnimal.ActionID = ID;                                                //Set the ID on the ANIMAL that entered the Action


            if (animal_Colliders.Find(coll => coll == other) == null)               //if the entering collider is not already on the list add it
            {
                animal_Colliders.Add(other);
            }


            if (newAnimal == oldAnimal)
            {
                return;                                                             //if the animal is the same do nothing (when entering two animals on the same Zone)
            }
            else
            {
                if (oldAnimal)
                {
                    oldAnimal.ActionID = -1;                            //Remove the old animal and remove the Action ID
                    animal_Colliders   = new List <Collider>();         //Clean the colliders
                }

                oldAnimal = newAnimal;                                             //Set a new Animal

                // if (animalProxy) animalProxy.SetAnimal(newAnimal);                 //Set to the Proxy the current animal entering the zone
            }

            newAnimal.OnAction.AddListener(OnActionListener);                      //Listen when the animal activate the Action Input

            OnEnter.Invoke(newAnimal);


            if (automatic)       //Just activate when is on the Locomotion State if this is automatic
            {
                if (newAnimal.AnimState == AnimTag.Jump && !ActiveOnJump)
                {
                    return;                                                         //Dont start an automatic action if is jumping and active on jump is disabled
                }
                // newAnimal.OnAction.RemoveListener(OnActionListener);
                newAnimal.SetAction(ID);
                StartCoroutine(ReEnable(newAnimal));
            }
        }