private void Start() { InteractableEvent inter = GetComponent <InteractableEvent>(); inter.interactEvent.AddListener(onInteraction); inter.msg = "Pickup dropable"; }
// Use this for initialization public void Start() { Debug.Log("START"); if (transform.childCount > 0) { ui = transform.Find(UIprefab.name); if (ui != null) { ui.gameObject.SetActive(true); bigPanel = ui.Find("BigPanel").gameObject; rightPanel = ui.Find("RightPanel").gameObject; leftPanel = ui.Find("LeftPanel").gameObject; } } em = new EventManager(); System.Func <bool> cond = delegate { Debug.Log("CHECKKINGG!!"); return(true); }; System.Func <bool> action = delegate { Debug.Log("WORKING!!!"); return(true); }; InteractableEvent ie = new InteractableEvent(cond, action); em.AddEvent(ie); CloseUI(); }
/// <summary> /// Creates the event receiver instances from the Events list /// </summary> protected virtual void SetupEvents() { InteractableEvent.EventLists lists = InteractableEvent.GetEventTypes(); for (int i = 0; i < Events.Count; i++) { Events[i].Receiver = InteractableEvent.GetReceiver(Events[i], lists); Events[i].Receiver.Host = this; //Events[i].Settings = InteractableEvent.GetSettings(Events[i].Receiver); // apply settings } }
public void Interact(Entity interactor = null) { // Invoke an interact event InteractableEvent e = new InteractableEvent { entity = interactor, interactable = this, transform = this.transform }; OnInteractEvent?.Invoke(this, e); if (e.cancel == true) { return; } // return if the event has been cancelled by any subscriber }
/// <summary> /// Called before game start /// </summary> private void Awake() { ItemPickupEvent = new ItemEvent(); ItemPickupEvent.AddListener(Ping); ItemDroppedEvent = new ItemEvent(); ItemDroppedEvent.AddListener(Ping); DialogOpenEvent = new DialogEvent(); DialogOpenEvent.AddListener(Ping); DialogOptionSelectedEvent = new DialogOptionEvent(); DialogOptionSelectedEvent.AddListener(Ping); CharacterDeathEvent = new CharacterEvent(); CharacterDeathEvent.AddListener(Ping); InteractableActivatedEvent = new InteractableEvent(); }
private void OnInteract(object sender, InteractableEvent e) { if (dropPrefab != null) { Instantiate(dropPrefab, transform.position, transform.rotation); } if (drop != null) { int amount = amountRange.RandomValue(); for (int i = 0; i < amount; i++) { GameMaster.DropItemNaturally(transform.position, drop); } } Destroy(this.gameObject); }
public void OnInteract(InteractableEvent ev) { switch (ev.interactType) { case EInteractType.Open: if (isOpen == true) { return; } Open(); break; case EInteractType.Close: if (isOpen == false) { return; } Close(); break; case EInteractType.Toggle: if (isOpen) { Close(); } else { Open(); } break; default: break; } }
protected void SetupEventOptions() { eventOptions = InteractableEvent.GetEventTypes(); }
protected void SetupEventOptions() { InteractableEvent.EventLists lists = InteractableEvent.GetEventTypes(); eventTypes = lists.EventTypes.ToArray(); eventOptions = lists.EventNames.ToArray(); }
public void AddEvent(InteractableEvent e) { events.Add(e); }
public void AddSequentialEvent(InteractableEvent e) { sequentialEvents.Enqueue(e); }
private void Awake() { OnStartInteraction += SetCurrentInteractive; OnEndInteraction += RemoveCurrentInteractive; }
public void Interact(EInteractType interactType) { var ev = new InteractableEvent(this, currentInteractable, interactType); currentInteractable.onInteract.Invoke(ev); }