Example #1
0
 public void TriggerHidden()
 {
     Debug.Log("Triggering hidden dialogue");
     if (hiddenTriggerOptionalEventOnEnd.GetPersistentEventCount() >= 1)
     {
         SingletonDialogueController.instance.BindEventToDialogueComplete(hiddenTriggerOptionalEventOnEnd);
     }
     SingletonDialogueController.instance.StartDialogue(hiddenDialogue);
 }
 public void Drop()
 {
     drop.Invoke();
     if (drop.GetPersistentEventCount() == 0)
     {
         DefaultDrop();
     }
     parent = null;
 }
Example #3
0
        /// <summary>
        /// Function called by Action scriptable object when the action is raised
        /// </summary>
        public void OnActionRaised()
        {
            if (_Response.GetPersistentEventCount() == 0)
            {
                Logger.Log(Logger.Type.Warning, "_Response doesn't have any listener...", this);
            }

            _Response?.Invoke();
        }
 public void Drop()
 {
     drop.Invoke();
     if (drop.GetPersistentEventCount() == 0) // Checks how many listeners you've added -- if zero, runs the default
     {
         DefaultDrop();
     }
     parent = null;
 }
Example #5
0
 public void Trigger()
 {
     Debug.Log("Triggering normal dialogue");
     if (triggerOptionalEventsOnEnd.GetPersistentEventCount() >= 1)
     {
         SingletonDialogueController.instance.BindEventToDialogueComplete(triggerOptionalEventsOnEnd);
     }
     SingletonDialogueController.instance.StartDialogue(dialogue);
 }
Example #6
0
 public void Drop()
 {
     DropEvent.Invoke();
     if (DropEvent.GetPersistentEventCount() == 0)
     {
         DefaultDrop();
     }
     ActiveHand = null;
 }
    public void EventRaised()
    {
        // default/generic
        if (response.GetPersistentEventCount() >= 1) // always check if at least 1 object is listening for the event
        {
            response.Invoke();
        }

        // string
        if (responseForSentString.GetPersistentEventCount() >= 1)
        {
            responseForSentString.Invoke(gameEvent.sentString);
        }

        // int
        if (responseForSentInt.GetPersistentEventCount() >= 1)
        {
            responseForSentInt.Invoke(gameEvent.sentInt);
        }

        // float
        if (responseForSentFloat.GetPersistentEventCount() >= 1)
        {
            responseForSentFloat.Invoke(gameEvent.sentFloat);
        }

        // bool
        if (responseForSentBool.GetPersistentEventCount() >= 1)
        {
            responseForSentBool.Invoke(gameEvent.sentBool);
        }

        // Vector2
        if (responseForSentVector2.GetPersistentEventCount() >= 1)
        {
            responseForSentVector2.Invoke(gameEvent.sentVector2);
        }

        // Vector3
        if (responseForSentVector3.GetPersistentEventCount() >= 1)
        {
            responseForSentVector3.Invoke(gameEvent.sentVector3);
        }

        // GameObject
        if (responseWithGameObject.GetPersistentEventCount() >= 1)
        {
            responseWithGameObject.Invoke(gameEvent.sentGameObject);
        }

        // AttackEvent
        if (responseWithAttackEvent.GetPersistentEventCount() >= 1)
        {
            responseWithAttackEvent.Invoke(gameEvent.sentAttackEvent);
        }
    }
Example #8
0
 public virtual void Played()
 {
     Debug.Log("play " + gameObject.name);
     if (played.GetPersistentEventCount() > 0)
     {
         //trigger additional effect if there is any
         played.Invoke();
     }
     AfterPlayed();
 }
Example #9
0
    public void PickUp()
    {
        pickUp.Invoke();

        if (pickUp.GetPersistentEventCount() == 0)
        {
            DefaultPickUp();
        }
        parent.controller.TriggerHapticPulse(3999);
    }
Example #10
0
 private void Update()
 {
     if (m_CanExecuteButtons)
     {
         if (OnButtonPress.GetPersistentEventCount() > 0 && PlayerInput.Instance.Interact.Down)
         {
             OnButtonPress.Invoke();
         }
     }
 }
Example #11
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        occupants.Add(collision);

        // First Occupant Trigger
        if (occupants.Count == 1 && ZoneIsOccupied.GetPersistentEventCount() != 0)
        {
            ZoneIsOccupied.Invoke();
        }
    }
Example #12
0
 static public bool HasEvent(this UnityEvent evt)
 {
     if (evt != null && evt.GetPersistentEventCount() > 0 && !string.IsNullOrEmpty(evt.GetPersistentMethodName(0)))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #13
0
 public override void InEditorUpdate(GameObject go)
 {
     for (int i = 0; i < action.GetPersistentEventCount(); i++)
     {
         GameObject ob = action.GetPersistentTarget(i) as GameObject;
         if (go && ob)
         {
             Debug.DrawLine(go.transform.position, ob.transform.position, Color.green);
         }
     }
 }
Example #14
0
 public static bool EventContainsPersistentListener <T0, T1, T2, T3>(UnityEvent <T0, T1, T2, T3> unityEvent, UnityAction <T0, T1, T2, T3> listener)
 {
     for (int i = unityEvent.GetPersistentEventCount() - 1; i >= 0; i--)
     {
         if (unityEvent.GetPersistentMethodName(i).Equals(listener.Method.Name) && unityEvent.GetPersistentTarget(i).Equals(listener.Target))
         {
             return(true);
         }
     }
     return(false);
 }
 public override void Cleared()
 {
     Score.Points        += bonusPoints;
     Timer.timeRemaining += bonusTime;
     BonusDisplay.ShowBonus(ScoreTypes.ClearedArea, "Cleared " + areaName, bonusPoints);
     if (OnComplete.GetPersistentEventCount() > 0)
     {
         OnComplete.Invoke();
     }
     Notifications.SendNotification(notif);
 }
Example #16
0
    void ShowAllMethodsOfEvent <T>(UnityEvent <T> e)
    {
        var color = GUI.color;

        for (var i = 0; i < e.GetPersistentEventCount(); i++)
        {
            GUI.color = i % 2 == 0 ? Color.cyan : Color.yellow;
            GUILayout.Label(e.GetPersistentTarget(i).ToString() + "\n." + e.GetPersistentMethodName(i));
        }
        GUI.color = color;
    }
Example #17
0
 private void OnClick()
 {
     if (Execute.GetPersistentEventCount() > 0)
     {
         Execute.Invoke();
     }
     else
     {
         UIManager.Instance.OnBack();
     }
 }
Example #18
0
 public static bool EventHasTarget(UnityEvent e)
 {
     for (int i = 0; i < e.GetPersistentEventCount(); i++)
     {
         if (e.GetPersistentTarget(i) != null)
         {
             return(true);
         }
     }
     return(false);
 }
        public static void UnityEventField(UnityEvent unityEvent, SerializedProperty serializedEvent)
        {
            var lastRect = GUILayoutUtility.GetLastRect();
            lastRect.y += 20;
            
            EditorGUI.PropertyField(lastRect, serializedEvent, true);

            GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none,
                GUILayout.Height(90 +
                                 Mathf.Max(0, unityEvent.GetPersistentEventCount() - 1) * 42.5f));
        }
Example #20
0
 public void CloseRadioMessage()
 {
     IsTrue = false;
     DuiHuaKuang.SetActive(false);
     timecount = 0;
     if (nextMessage.GetPersistentEventCount() != 0)
     {
         nextMessage.Invoke();
     }
     AudioController.Instance.TryPlayAudio(AudioType.标点击对话);
 }
Example #21
0
 void Die()
 {
     if (onDeath.GetPersistentEventCount() > 0)
     {
         onDeath.Invoke();
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
Example #22
0
    public void PrintButtonListeners()
    {
        UnityEvent buttonEvent           = button.onClick;
        int        totalRegisteredEvents = buttonEvent.GetPersistentEventCount();

        for (int i = 0; i < totalRegisteredEvents; ++i)
        {
            Debug.Log("Component: " + buttonEvent.GetPersistentTarget(i));
            Debug.Log("Method Name: " + buttonEvent.GetPersistentMethodName(i));
        }
    }
        public static void CopyEventData(UnityEvent source, UnityEvent target)
        {
            int listeners = source.GetPersistentEventCount();

            for (int i = 0; i < listeners; i++)
            {
                System.Reflection.MethodInfo info = UnityEventBase.GetValidMethodInfo(source.GetPersistentTarget(i), source.GetPersistentMethodName(i), new Type[] { typeof(float) });
                UnityAction execute = () => info.Invoke(source.GetPersistentTarget(i), new object[] { 180f });
                target.AddListener(execute);
            }
        }
Example #24
0
 static bool HasCall <T>(this UnityEvent <T> @event, UnityEngine.Object caller, string methodName)
 {
     for (int i = 0; i < @event.GetPersistentEventCount(); i++)
     {
         if (@event.GetPersistentTarget(i) == caller && @event.GetPersistentMethodName(i) == methodName)
         {
             return(true);
         }
     }
     return(false);
 }
Example #25
0
 protected static void AddEvent(UnityEvent <T> unityEvent, ref int index, UnityAction <T> unityAction)
 {
     if (index == -1)
     {
         UnityEventTools.AddPersistentListener(unityEvent, unityAction);
         index = unityEvent.GetPersistentEventCount() - 1;
     }
     else
     {
         UnityEventTools.RegisterPersistentListener(unityEvent, index, unityAction);
     }
 }
Example #26
0
 private void OnDrawGizmos()
 {
     if (debugOn)
     {
         Vector2 thisPos = transform.position;
         for (int i = 0; i < OnPressed.GetPersistentEventCount(); i++)
         {
             GameObject targetObject = OnPressed.GetPersistentTarget(i) as GameObject;
             Debug.DrawLine(thisPos, targetObject.transform.position, debugColor_link);
         }
     }
 }
Example #27
0
 public static bool IfNotAlready <T>(UnityEvent <T> @event, UnityEngine.Object target, UnityAction <T> action)
 {
     for (int i = 0; i < @event.GetPersistentEventCount(); ++i)
     {
         if (@event.GetPersistentTarget(i) == target && @event.GetPersistentMethodName(i) == action.Method.Name)
         {
             return(false);
         }
     }
     On(@event, target, action);
     return(true);
 }
Example #28
0
    /// <summary>
    /// Same as CheckUnityEventAction but allows to specify passing a param
    /// through the Event.
    /// </summary>
    public static bool CheckUnityEvent <T>(this UnityEvent <T> unityEvent)
    {
        for (int i = 0; i < unityEvent.GetPersistentEventCount(); i++)
        {
            if (unityEvent.GetPersistentTarget(i) != null)
            {
                return(true);
            }
        }

        return(false);
    }
Example #29
0
    private void UpdateResponsesCallState()
    {
        for (int i = 0; i < response.GetPersistentEventCount(); i++)
        {
            response.SetPersistentListenerState(i, enableInEditor ? UnityEventCallState.EditorAndRuntime : UnityEventCallState.RuntimeOnly);
        }

        for (int i = 0; i < responseWithData.GetPersistentEventCount(); i++)
        {
            responseWithData.SetPersistentListenerState(i, enableInEditor ? UnityEventCallState.EditorAndRuntime : UnityEventCallState.RuntimeOnly);
        }
    }
Example #30
0
        public static void AddPersistentListener <T0, T1, T2, T3>(this UnityEvent <T0, T1, T2, T3> e, UnityAction <T0, T1, T2, T3> action)
        {
            object persistentCallsObject = null;

            if (!UnityEventReflection.TryAccessPersistentCalls(e, ref persistentCallsObject))
            {
                return;
            }
            int index = e.GetPersistentEventCount();

            UnityEventReflection.AddPersistentListner(persistentCallsObject, index, action.Target as UnityEngine.Object, action.Method);
        }