public bool Drink(IDrinkable drinkable) { if (IsInReach(drinkable)) { drinkable.Drink().ApplyOn(transform.parent.gameObject); return(true); } return(false); }
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); }
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); } }
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); }
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>(); } } }
private bool IsInReach(IDrinkable eatable) { return(IsInReach(eatable, maxDrinkDistance)); }
public void ChangeFluid(IDrinkable type) { fluidType = type; }
public FluidContainer(IDrinkable fluidType, int max) : base(max) { this.fluidType = fluidType; }
public bool Drink(IDrinkable drinkable) { return(feeder.Drink(drinkable)); }
public DrinkAction(Actor actor, IDrinkable item) : base(actor) { this.item = item; }