Esempio n. 1
0
        public bool Drink(IDrinkable drinkable)
        {
            if (IsInReach(drinkable))
            {
                drinkable.Drink().ApplyOn(transform.parent.gameObject);
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public void UseItem(IDrinkable itemToUse)
        {
            string info = "";

            if (this.Health + itemToUse.HealthRestorationPower > this.MaxHealth)
            {
                info        = "You drinked " + itemToUse.Name + " and restore " + (this.MaxHealth - this.Health) + " health";
                this.Health = this.MaxHealth;
            }
            else
            {
                info         = "You drinked " + itemToUse.Name + " and restore " + itemToUse.HealthRestorationPower + " health";
                this.Health += itemToUse.HealthRestorationPower;
            }
            InfoPanel.AddInfo(info);
        }
Esempio n. 3
0
    private void OnTriggerExit(Collider other)
    {
        if (other.CompareTag("Hydrator"))
        {
            drinkRef = null;
        }
        if (other.CompareTag("Feeder"))
        {
            foodRef = null;
        }

        if (other.GetComponents <IInteractable>().Length > 0)
        {
            InteractionText.gameObject.SetActive(false);
        }
    }
Esempio n. 4
0
        public IDrinkable GetNearestDrinkable()
        {
            IDrinkable drinkable = null;

            foreach (var sensedObject in Sensor.SensedObjects)
            {
                var sensedDrinkable = sensedObject.GetComponent <IDrinkable>();
                if (sensedDrinkable != null)
                {
                    if (drinkable == null || MathExtensions.SquareDistanceBetween(Position, sensedDrinkable.Position) < MathExtensions.SquareDistanceBetween(Position, drinkable.Position))
                    {
                        drinkable = sensedDrinkable;
                    }
                }
            }
            return(drinkable);
        }
Esempio n. 5
0
    private void OnTriggerEnter(Collider other)
    {
        var interact = other.GetComponent <IInteractable>();

        if (interact != null)
        {
            InteractionText.gameObject.SetActive(true);
            InteractionText.text = interact.GetInteractionText();
        }
        if (other.CompareTag("Hydrator"))
        {
            if (drinkRef == null)
            {
                drinkRef = other.GetComponent <IDrinkable>();
            }
        }
        if (other.CompareTag("Feeder"))
        {
            if (foodRef == null)
            {
                foodRef = other.GetComponent <IEatable>();
            }
        }
    }
Esempio n. 6
0
 private bool IsInReach(IDrinkable eatable)
 {
     return(IsInReach(eatable, maxDrinkDistance));
 }
Esempio n. 7
0
 public void ChangeFluid(IDrinkable type)
 {
     fluidType = type;
 }
Esempio n. 8
0
 public FluidContainer(IDrinkable fluidType, int max) : base(max)
 {
     this.fluidType = fluidType;
 }
Esempio n. 9
0
 public bool Drink(IDrinkable drinkable)
 {
     return(feeder.Drink(drinkable));
 }
Esempio n. 10
0
 public DrinkAction(Actor actor, IDrinkable item)
     : base(actor)
 {
     this.item = item;
 }