Пример #1
0
    private void Start()
    {
        InteractableEvent inter = GetComponent <InteractableEvent>();

        inter.interactEvent.AddListener(onInteraction);
        inter.msg = "Pickup dropable";
    }
Пример #2
0
    // 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();
    }
Пример #3
0
        /// <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
            }
        }
Пример #4
0
        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
        }
Пример #5
0
    /// <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);
    }
Пример #7
0
    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();
 }
Пример #9
0
 protected void SetupEventOptions()
 {
     InteractableEvent.EventLists lists = InteractableEvent.GetEventTypes();
     eventTypes   = lists.EventTypes.ToArray();
     eventOptions = lists.EventNames.ToArray();
 }
Пример #10
0
 public void AddEvent(InteractableEvent e)
 {
     events.Add(e);
 }
Пример #11
0
 public void AddSequentialEvent(InteractableEvent e)
 {
     sequentialEvents.Enqueue(e);
 }
Пример #12
0
 private void Awake()
 {
     OnStartInteraction += SetCurrentInteractive;
     OnEndInteraction   += RemoveCurrentInteractive;
 }
Пример #13
0
    public void Interact(EInteractType interactType)
    {
        var ev = new InteractableEvent(this, currentInteractable, interactType);

        currentInteractable.onInteract.Invoke(ev);
    }