Exemple #1
0
        /// <summary>Return the Correct Mount Trigger using the DismountType</summary>
        private MountTriggers GetDismountTrigger()
        {
            switch (DismountType)
            {
            case DismountType.Last:
                return(MountTrigger);

            case DismountType.Input:
                var MoveInput = Montura.Animal.MovementAxis;

                MountTriggers close = MountTrigger;

                float Diference = Vector3.Angle(MountTrigger.Direction, MoveInput);

                foreach (var mt in Montura.MountTriggers)
                {
                    var newDiff = Vector3.Angle(mt.Direction, MoveInput);

                    if (newDiff < Diference)
                    {
                        Diference = newDiff;
                        close     = mt;
                    }
                }

                return(close);

            case DismountType.Random:
                int Randomindex = Random.Range(0, Montura.MountTriggers.Count);
                return(Montura.MountTriggers[Randomindex]);

            default:
                return(MountTrigger);
            }
        }
Exemple #2
0
        public virtual void MountTriggerEnter(Mount mount, MountTriggers mountTrigger)
        {
            Montura      = mount;                                       //Set to Mount on this Rider
            MonturaAI    = Montura.GetComponent <IAIControl>();
            MountTrigger = mountTrigger;                                //Send the side transform to mount
            OnFindMount.Invoke(mount.transform.root.gameObject);        //Invoke Found Animal
            Montura.OnCanBeMounted.Invoke(Montura.CanBeMountedByState); //Invoke Can Be mounted to true ???
            Montura.NearbyRider = true;

            UpdateCanMountDismount();
        }
Exemple #3
0
        public virtual void DismountAnimal()
        {
            if (!CanDismount)
            {
                return;
            }

            Montura.Mounted = Mounted = false;                                  //Unmount the Animal

            MountTriggers MTrigger = GetDismountTrigger();

            Anim.SetInteger(Hash.MountSide, MTrigger.DismountID);    //Update MountSide Parameter In the Animator

            if (Montura.InstantMount)                                //Use for Instant mount
            {
                Anim.Play(Hash.Empty, MountLayerIndex);
                Anim.SetInteger(Hash.MountSide, 0);                          //Update MountSide Parameter In the Animator

                Start_Dismounting();
                End_Dismounting();

                t.position = MTrigger.transform.position + (MTrigger.transform.forward * -0.2f);   //Move the rider directly to the mounttrigger
            }
        }