Beispiel #1
0
        private void PlayMode(MAnimalBrain brain)
        {
            switch (affect)
            {
            case Affected.Self:

                if (brain.Animal.Mode_TryActivate(modeID, AbilityID))
                {
                    if (lookAtAlign && brain.Target)
                    {
                        brain.StartCoroutine(MTools.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(MTools.AlignLookAtTransform(brain.TargetAnimal.transform, brain.transform, alignTime));
                    }
                }
                break;

            default:
                break;
            }
        }
Beispiel #2
0
        public override void OnModeEnter(Mode mode)
        {
            MAnimal animal = mode.Animal;

            var pos = animal.Center;

            var AllColliders = Physics.OverlapSphere(pos, FindRadius, Layer.Value);

            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(MTools.AlignLookAtTransform(animal.transform, MinDistanceCol.transform, AlignTime));
            }
        }
Beispiel #3
0
        public override void StartTask(MAnimalBrain brain, int index)
        {
            if (AlignTarget != null || AlignTarget.Value == null)
            {
                brain.StartCoroutine(MTools.AlignLookAtTransform(brain.Animal.transform, AlignTarget.Value, alignTime));
            }
            else
            {
                Debug.LogWarning($"The Align Target is empty or Null");
            }

            brain.TaskDone(index);
        }
Beispiel #4
0
        private void TryPickUpAnimations()
        {
            if (character != null && !character.IsPlayingAction) //Try Picking UP WHEN THE CHARACTER IS NOT MAKING ANY ANIMATION
            {
                if (item.Align)
                {
                    StartCoroutine(MTools.AlignLookAtTransform(transform, item.transform, item.AlignTime));
                    StartCoroutine(MTools.AlignTransformRadius(transform, item.transform, item.AlignTime, item.AlignDistance * transform.localScale.y));
                }

                if (!item.PickReaction.TryReact(gameObject)) //Means if the animal does not have a pick up Animation that calls the PickUP method then It will do it manually
                {
                    PickUpItem();
                }
            }
            else
            {
                PickUpItem();
            }
        }
Beispiel #5
0
        private void PlayMode(MAnimalBrain brain)
        {
            switch (affect)
            {
            case Affected.Self:
                var Direction_to_Target = brain.Target != null ? (brain.Target.position - brain.Eyes.position) : brain.Animal.Forward;

                var EyesForward = Vector3.ProjectOnPlane(brain.Eyes.forward, brain.Animal.UpVector);
                if (ModeAngle == 360f || Vector3.Dot(Direction_to_Target.normalized, EyesForward) > Mathf.Cos(ModeAngle * 0.5f * Mathf.Deg2Rad))     //Mean is in Range:
                {
                    if (brain.Animal.Mode_TryActivate(modeID, AbilityID))
                    {
                        if (lookAtAlign && brain.Target)
                        {
                            brain.StartCoroutine(MTools.AlignLookAtTransform(brain.Animal.transform, brain.AIMovement.GetTargetPosition(), alignTime));
                        }
                    }
                }
                break;

            case Affected.Target:
                Direction_to_Target = brain.Eyes.position - brain.Target.position;                                          //Reverse the Direction
                EyesForward         = Vector3.ProjectOnPlane(brain.Target.forward, brain.Animal.UpVector);
                if (Vector3.Dot(Direction_to_Target.normalized, EyesForward) > Mathf.Cos(ModeAngle * 0.5f * Mathf.Deg2Rad)) //Mean is in Range:
                {
                    if (brain.TargetAnimal && brain.TargetAnimal.Mode_TryActivate(modeID, AbilityID))
                    {
                        if (lookAtAlign && brain.Target)
                        {
                            brain.StartCoroutine(MTools.AlignLookAtTransform(brain.TargetAnimal.transform, brain.transform, alignTime));
                        }
                    }
                }
                break;

            default:
                break;
            }
        }