Esempio n. 1
0
        protected override void _React(MAnimal animal)
        {
            switch (type)
            {
            case State_Reaction.Activate:
                animal.State_Activate(ID);
                break;

            case State_Reaction.AllowExit:
                if (animal.ActiveStateID == ID)
                {
                    animal.ActiveState.AllowExit();
                }
                break;

            case State_Reaction.ForceActivate:
                animal.State_Force(ID);
                break;

            case State_Reaction.Enable:
                animal.State_Enable(ID);
                break;

            case State_Reaction.Disable:
                animal.State_Disable(ID);
                break;

            case State_Reaction.SetStatus:
                animal.State_SetStatus(StateStatus);
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        private void AlignAnimalsOnly()
        {
            MAnimal ClosestAnimal   = null;
            float   ClosestDistance = float.MaxValue;

            foreach (var a in MAnimal.Animals)
            {
                if (a == animal || a.ActiveStateID.ID == StateEnum.Death)
                {
                    continue;                                                       //Don't Find yourself or don't find death animals
                }
                var animalsDistance = Vector3.Distance(animal.Center, a.Center);

                if (LookRadius >= animalsDistance && ClosestDistance >= animalsDistance)
                {
                    ClosestDistance = animalsDistance;
                    ClosestAnimal   = a;
                }
            }

            if (ClosestAnimal)
            {
                StartAligning(ClosestAnimal.Center);
            }
        }
Esempio n. 3
0
        // Use this for initialization
        void Start()
        {
            if (!MainAnimal)
            {
                Debug.LogWarning("MainAnimal is Empty, Please set the Main Animal");
                return;
            }
            if (!SecondAnimal)
            {
                SecondAnimal = MainAnimal;
            }

            RB = GetComponent <Rigidbody>();

            MainAnimal.transform.parent   = transform;
            SecondAnimal.transform.parent = transform;

            RHorseInitialPos = MainAnimal.transform.localPosition;          //Store the position of the Right Main Horse
            LHorseInitialPos = SecondAnimal.transform.localPosition;        //Store the position of the Right Main Horse

            MainAnimal.DisablePositionRotation   = true;
            SecondAnimal.DisablePositionRotation = true;

            SecondAnimal.RootMotion = false;
            MainAnimal.RootMotion   = false;
        }
Esempio n. 4
0
        public void PlayState(MAnimal CurrentAnimal)
        {
            switch (action)
            {
            case StateAction.Activate:
                CurrentAnimal.State_Activate(StateID);
                break;

            case StateAction.AllowExit:
                if (CurrentAnimal.ActiveStateID == StateID)
                {
                    CurrentAnimal.ActiveState.AllowExit();
                }
                break;

            case StateAction.ForceActivate:
                CurrentAnimal.State_Force(StateID);
                break;

            case StateAction.Enable:
                CurrentAnimal.State_Enable(StateID);
                break;

            case StateAction.Disable:
                CurrentAnimal.State_Disable(StateID);
                break;

            default:
                break;
            }
        }
Esempio n. 5
0
 public void ThinkAloud()
 {
     Console.WriteLine("Three injection methods!");
     if (PAnimal != null)
     {
         PAnimal.Say();
     }
     if (CAnimal != null)
     {
         CAnimal.Say();
     }
     if (MAnimal != null)
     {
         MAnimal.Say();
     }
     Console.WriteLine("Injiection array");
     if (Animals != null && Animals.Length > 0)
     {
         Animals.ToList().ForEach(it => it.Say());
     }
     Console.WriteLine("Injiection array with diferent methods");
     if (FeederNames != null && FeederNames.Length > 0)
     {
         FeederNames.ToList().ForEach(it => Console.WriteLine(it));
     }
     Console.WriteLine("Injection array null");
     if (PetNames != null && PetNames.Length > 0)
     {
         PetNames.ToList().ForEach(it => Console.WriteLine(it));
     }
 }
Esempio n. 6
0
 void Awake()
 {
     if (animal == null)
     {
         animal = this.FindComponent <MAnimal>();
     }
 }
Esempio n. 7
0
        protected override bool _TryReact(MAnimal animal)
        {
            var mode = animal.Mode_Get(ID);

            if (mode == null || ID == null)
            {
                return(false);
            }

            switch (type)
            {
            case Mode_Reaction.Activate:
                return(animal.Mode_TryActivate(ID, AbilityIndex));

            case Mode_Reaction.Interrupt:
                if (animal.ActiveMode.ID == ID)
                {
                    animal.Mode_Interrupt();
                    return(true);
                }
                return(false);

            case Mode_Reaction.SetActiveIndex:
                mode.AbilityIndex = AbilityIndex;
                return(true);

            case Mode_Reaction.ResetActiveIndex:
                mode.ResetAbilityIndex();
                return(true);

            case Mode_Reaction.Enable:
                animal.Mode_Enable(ID);
                return(true);

            case Mode_Reaction.Disable:
                animal.Mode_Disable(ID);
                return(true);

            case Mode_Reaction.CoolDown:
                mode.CoolDown.Value = coolDown;
                return(true);

            case Mode_Reaction.ForceActivate:
                animal.Mode_ForceActivate(ID, AbilityIndex);
                return(true);

            case Mode_Reaction.ActivateContinuously:
                animal.InputMode            = mode;
                animal.InputMode.InputValue = true;
                return(animal.Mode_TryActivate(ID, AbilityIndex));

            case Mode_Reaction.Stop:
                animal.Mode_Stop();
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 8
0
        override public void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
        {
            int newParam = Random.Range(1, Range + 1);

            MAnimal animal = animator.GetComponent <MAnimal>();

            animal.SetIntID(newParam);
        }
Esempio n. 9
0
        public bool TryReact(MAnimal animal)
        {
            if (animal && active)
            {
                return(_TryReact(animal));
            }

            return(false);
        }
Esempio n. 10
0
 void Start()
 {
     riderCombat     = GetComponentInChildren <RiderCombat>();
     animalAIControl = GetComponentInChildren <MAnimalAIControl>();
     mAnimal         = GetComponentInChildren <MAnimal>();
     rider           = GetComponentInChildren <MRider>();
     //animalAIControl.enabled = false;
     //  SetClosestWaypoint();
 }
Esempio n. 11
0
        void Reset()
        {
            ModeID modeID = MalbersTools.GetInstance<ModeID>("Attack1");
            animal = GetComponent<MAnimal>();

            if (modeID != null)
            {
                this.ModeID = modeID;
            }
        }
Esempio n. 12
0
        protected override void _React(MAnimal animal)
        {
            var mode = animal.Mode_Get(ID);

            if (mode == null || ID == null)
            {
                return;
            }
            _TryReact(animal);
        }
 private bool OnEnterMode(MAnimal animal)
 {
     if (animal.ActiveModeID == ModeID)
     {
         if (Ability == -1)
             return true; //Means that Is playing a random mode does not mater which one
         else
             return Ability == (animal.ModeAbility % 1000); //Return if the Ability is playing 
     }
     return false;
 }
Esempio n. 14
0
 private bool OnExitMode(MAnimal animal)
 {
     if (animal.LastMode != 0 && animal.LastModeStatus == MStatus.Completed || animal.LastModeStatus == MStatus.Interrupted)
     {
         //Forget Last Mode (IMPORTANT)
         animal.LastMode       = 0;
         animal.LastAbility    = 0;
         animal.LastModeStatus = MStatus.None;
         return(true);
     }
     return(false);
 }
Esempio n. 15
0
        [HideInInspector] public float[] DecisionsTimeElapsed;// { get; set; }
        #endregion


        void Awake()
        {
            animal     = GetComponent <MAnimal>();
            AIMovement = GetComponent <MAnimalAIControl>();
            var AnimalStatscomponent = GetComponent <Stats>();

            if (AnimalStatscomponent)
            {
                AnimalStats = AnimalStatscomponent.stats_D;
            }

            AgentHeight = transform.lossyScale.y * AIMovement.Agent.height;
        }
Esempio n. 16
0
        private bool CheckState(MAnimal animal)
        {
            switch (when)
            {
            case EEnterExit.Enter:
                return(animal.ActiveStateID == StateID.ID);

            case EEnterExit.Exit:
                return(animal.LastState.ID == StateID.ID);

            default:
                return(false);
            }
        }
        private bool AnimalMode(MAnimal animal)
        {
            if (animal == null) return false;

            switch (ModeState)
            {
                case EEnterExit.Enter:
                    return OnEnterMode(animal);
                case EEnterExit.Exit:
                    return OnExitMode(animal);
                default:
                    return false;
            }
        }
Esempio n. 18
0
 public void React(MAnimal animal)
 {
     if (animal && active)
     {
         if (delay > 0)
         {
             animal.StartCoroutine(DelayedReaction(animal));
         }
         else
         {
             _React(animal);
         }
     }
 }
Esempio n. 19
0
 private bool OnEnterMode(MAnimal animal)
 {
     if (animal.ActiveModeID == ModeID)
     {
         if (Ability == -1)
         {
             return(true); //Means that Is playing a random mode does not mater which one
         }
         else
         {
             return(Ability == (animal.ModeAbility % 1000)); //Return if the Ability is playing
         }
     }
     return(false);
 }
Esempio n. 20
0
        private void Reset()
        {
            Animal = GetComponent <MAnimal>();
            StraightSpineOffsetTransform = transform;

            MEvent RiderMountUIE = MalbersTools.GetInstance <MEvent>("Rider Mount UI");

            OnCanBeMounted = new BoolEvent();

            if (RiderMountUIE != null)
            {
                UnityEditor.Events.UnityEventTools.AddObjectPersistentListener <Transform>(OnCanBeMounted, RiderMountUIE.Invoke, transform);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(OnCanBeMounted, RiderMountUIE.Invoke);
            }
        }
Esempio n. 21
0
        protected override void _React(MAnimal animal)
        {
            switch (type)
            {
            case Speed_Reaction.LockSpeedChange:
                animal.Speed_Change_Lock(LockSpeedChanges);
                break;

            case Speed_Reaction.Increase:
                animal.SpeedUp();
                break;

            case Speed_Reaction.Decrease:
                animal.SpeedUp();
                break;

            case Speed_Reaction.Activate:
                animal.SpeedSet_Set_Active(SpeedSet, Index);
                break;

            case Speed_Reaction.TopSpeed:
                animal.Speed_SetTopIndex(SpeedSet, Index);
                break;

            case Speed_Reaction.AnimationSpeed:
                var Set = animal.SpeedSet_Get(SpeedSet);
                Set[Index - 1].animator.Value = animatorSpeed;
                break;

            case Speed_Reaction.GlobalAnimatorSpeed:
                animal.AnimatorSpeed = animatorSpeed;
                break;

            case Speed_Reaction.SetRandomSpeed:
                var topspeed = animal.SpeedSet_Get(SpeedSet);
                if (topspeed != null)
                {
                    animal.SpeedSet_Set_Active(SpeedSet, Random.Range(1, topspeed.TopIndex + 1));
                }
                break;

            default:
                break;
            }
        }
Esempio n. 22
0
        protected override void _React(MAnimal animal)
        {
            switch (type)
            {
            case Move_Reaction.UseCameraInput:
                animal.UseCameraInput = Value;
                break;

            case Move_Reaction.Sleep:
                animal.Sleep = Value;
                break;

            case Move_Reaction.LockInput:
                animal.LockInput = Value;
                break;

            case Move_Reaction.LockMovement:
                animal.LockMovement = Value;
                break;

            case Move_Reaction.AlwaysForward:
                animal.AlwaysForward = Value;
                break;

            case Move_Reaction.UseCameraUp:
                animal.UseCameraUp = Value;
                break;

            case Move_Reaction.LockForward:
                animal.LockForwardMovement = Value;
                break;

            case Move_Reaction.LockHorizontal:
                animal.LockHorizontalMovement = Value;
                break;

            case Move_Reaction.LockUpDown:
                animal.LockUpDownMovement = Value;
                break;
            }
        }
Esempio n. 23
0
        protected override void _React(MAnimal animal)
        {
            switch (type)
            {
            case Stance_Reaction.Set:
                animal.Stance_Set(ID);
                break;

            case Stance_Reaction.Reset:
                animal.Stance_Reset();
                break;

            case Stance_Reaction.Toggle:
                animal.Stance_Toggle(ID);
                break;

            case Stance_Reaction.SetDefault:
                animal.DefaultStance = ID.ID;
                break;
            }
        }
Esempio n. 24
0
        protected override bool _TryReact(MAnimal animal)
        {
            if (!animal.HasState(ID))
            {
                return(false);
            }

            switch (type)
            {
            case State_Reaction.Activate:
                return(animal.State_TryActivate(ID));

            case State_Reaction.AllowExit:
                if (animal.ActiveStateID == ID)
                {
                    animal.ActiveState.AllowExit();
                    return(true);
                }
                return(false);

            case State_Reaction.ForceActivate:
                animal.State_Force(ID);
                return(true);

            case State_Reaction.Enable:
                animal.State_Enable(ID);
                return(true);

            case State_Reaction.Disable:
                animal.State_Disable(ID);
                return(true);

            case State_Reaction.SetStatus:
                animal.State_SetStatus(StateStatus);
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 25
0
        protected virtual void SyncAnimator()
        {
            MAnimal animal = Montura.Animal;

            Anim.SetFloat(animal.hash_Vertical, animal.VerticalSmooth);
            Anim.SetFloat(animal.hash_Horizontal, animal.HorizontalSmooth);
            Anim.SetFloat(animal.hash_Slope, animal.SlopeNormalized);

            Anim.SetBool(animal.hash_Grounded, animal.Grounded);
            // Anim.SetInteger(animal.hash_State, animal.ActiveStateID);
            // Anim.SetInteger(animal.hash_Mode, animal.ModeID);


            Anim.SetInteger(animal.hash_IDInt, animal.IntID);
            Anim.SetFloat(animal.hash_IDFloat, animal.IDFloat);

            if (!Montura.UseSpeedModifiers)
            {
                SpeedMultiplier = animal.SpeedMultiplier;                             //In case the Mount is not using Speed Modifiers
            }
            SpeedMultiplier = Mathf.MoveTowards(SpeedMultiplier, TargetSpeedMultiplier, Time.deltaTime * 5f);
            Anim.SetFloat(animal.hash_SpeedMultiplier, SpeedMultiplier);
        }
Esempio n. 26
0
        private void Awake()
        {
            if (Animal == null)
            {
                Animal = GetComponent <MAnimal>();
            }
            Anim       = Animal.GetComponent <Animator>();
            MountInput = Animal.GetComponent <IInputSource>();

            MountTriggers = GetComponentsInChildren <MountTriggers>(true).ToList(); //Catche all the MountTriggers of the Mount

            CanBeDismountedByState = CanBeMountedByState = true;                    //Set as true can be mounted and canbe dismounted by state
            defaultStraightSpine   = StraightSpine;
            if (Anim)
            {
                DefaultAnimUpdateMode = Anim.updateMode;
            }

            if (!StraightSpineOffsetTransform)
            {
                StraightSpineOffsetTransform = transform;
            }
        }
Esempio n. 27
0
        protected override void _React(MAnimal animal)
        {
            switch (type)
            {
            case Gravity_Reaction.Enable:
                animal.UseGravity = Value;
                break;

            case Gravity_Reaction.Reset:
                animal.ResetGravityDirection();
                break;

            case Gravity_Reaction.GroundChangesGravity:
                animal.GroundChangesGravity(Value);
                break;

            case Gravity_Reaction.SnapAlignment:
                animal.AlignGravity();
                break;

            default:
                break;
            }
        }
Esempio n. 28
0
        IEnumerator IForceC(MAnimal animal)
        {
            var Force = force * Direction.normalized;

            if (Mode == DirectionType.Local)
            {
                Force = animal.transform.TransformDirection(Force);
            }

            var StartExtForce = animal.CurrentExternalForce + animal.GravityStoredVelocity; //Calculate the Starting force

            animal.CurrentExternalForce = StartExtForce;

            animal.Grounded = Grounded;

            animal.ExternalForce     = Force;
            animal.ExternalForceAcel = Aceleration;

            if (animal.ActiveState.ID == StateEnum.Fall) //If we enter to a zone from the Fall state.. Reset the Fall Current Distance
            {
                var fall = animal.ActiveState as Fall;
                fall.FallCurrentDistance = 0;
            }

            yield return(new WaitForSeconds(time));

            if (animal.ActiveState.ID == StateEnum.Fall)
            {
                animal.UseGravity = true; //If we are on the Fall State -- Reactivate the Gravity
            }
            if (ExitDrag > 0)             //
            {
                animal.ExternalForceAcel = ExitDrag;
                animal.ExternalForce     = Vector3.zero;
            }
        }
Esempio n. 29
0
 public void OnAnimalEventDecisionListen(MAnimalBrain brain, MAnimal animal, int index)
 {
     transitions[index].decision.OnAnimalEventDecisionListen(brain, animal, index);
 }
Esempio n. 30
0
 public void ChangeSpeed(MAnimal animal)
 {
     animal?.SpeedSet_Set_Active(SpeedSet, SpeedIndex);
 }