// Update is called once per frame void Update() { InteractiveI buff = GetClosestThatCanInteract(movment.instance.gameObject); if (buff != null) { Debug.Log(buff.GetInteractionDecription(), buff.gameObject); } }
public void TrytoInteract(GameObject g) { InteractiveI buff = GetClosestThatCanInteract(g); if (buff != null) { buff.Interact(g); } else { Debug.Log("nie mam jak interaktować"); } }
InteractiveI GetClosestThatCanInteract(GameObject gameObject) { InteractiveI interactiveI = null; float distance = 999999f; foreach (InteractiveI item in listOfInteractive) { if (item.CanInteract() && distance > item.GetDistance(gameObject)) { if (item.GetDistance(gameObject) < item.GetRangeOfInteraction()) { interactiveI = item; distance = item.GetDistance(gameObject); } } } return(interactiveI); }
public static void RemoveInteraction(InteractiveI a) { instance.listOfInteractive.Remove(a); }
public static void AddInteraction(InteractiveI a) { instance.listOfInteractive.Add(a); }