public override void DoAction(PlayerCharacter character, Selectable select)
        {
            AnimalRide ride = select.GetComponent <AnimalRide>();

            if (ride != null)
            {
                character.RideAnimal(ride);
            }
        }
 public void RideAnimal(AnimalRide animal)
 {
     if (!is_riding && animal != null)
     {
         is_riding          = true;
         is_action          = true;
         collide.enabled    = false;
         riding_animal      = animal;
         transform.position = animal.GetRideRoot();
         animal.SetRider(this);
     }
 }
 public void StopRide()
 {
     if (is_riding)
     {
         if (riding_animal != null)
         {
             riding_animal.StopRide();
         }
         is_riding       = false;
         is_action       = false;
         collide.enabled = true;
         riding_animal   = null;
     }
 }
예제 #4
0
        public static AnimalRide GetNearest(Vector3 pos, float range = 999f)
        {
            float      min_dist = range;
            AnimalRide nearest  = null;

            foreach (AnimalRide animal in animal_list)
            {
                float dist = (animal.transform.position - pos).magnitude;
                if (dist < min_dist)
                {
                    min_dist = dist;
                    nearest  = animal;
                }
            }
            return(nearest);
        }
        public void RideNearest()
        {
            AnimalRide animal = AnimalRide.GetNearest(transform.position, 2f);

            RideAnimal(animal);
        }
        public override bool CanDoAction(PlayerCharacter character, Selectable select)
        {
            AnimalRide ride = select.GetComponent <AnimalRide>();

            return(ride != null && !ride.IsDead());
        }