Exemple #1
0
 private void OnEnable()
 {
     if (OnTargetingAngleDetectedEvent == null)
     {
         OnTargetingAngleDetectedEvent = new UnityEventInt();
     }
 }
Exemple #2
0
 public static void TryInvoke(this UnityEventInt evt, int value)
 {
     if (evt != null)
     {
         evt.Invoke(value);
     }
 }
Exemple #3
0
    public static void TriggerEvent(string eventName, int param)
    {
        UnityEventInt thisEvent = null;

        if (Instance != null && Instance.eventDictionaryInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(param);
        }
    }
Exemple #4
0
    public static void TriggerEvent(GameData.Event eventName, int value)
    {
        UnityEventInt thisEvent = null;

        if (Instance.eventDictionaryInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(value);
        }
    }
    // Custom Unity Event validation
    public void OnValidate()
    {
        response = Event != null && Event.UnityEventType == typeof(UnityEvent) ? response : null;

        responseGameObject = Event != null && Event.UnityEventType == typeof(UnityEventGameObject) ? responseGameObject : null;
        responseTransform  = Event != null && Event.UnityEventType == typeof(UnityEventTransform) ? responseTransform : null;
        responseInt        = Event != null && Event.UnityEventType == typeof(UnityEventInt) ? responseInt : null;
        responseFloat      = Event != null && Event.UnityEventType == typeof(UnityEventFloat) ? responseFloat : null;
        responseBool       = Event != null && Event.UnityEventType == typeof(UnityEventBool) ? responseBool : null;
        responseString     = Event != null && Event.UnityEventType == typeof(UnityEventString) ? responseString : null;
    }
Exemple #6
0
    public static void TriggerEvent(string eventName, int value)
    {
        Debug.Log("MessageManager tries to trigger " + eventName);
        UnityEventInt thisEvent = null;

        if (instance.eventDictionaryParamInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(value);
            Debug.Log("MessageManager successfully triggers " + eventName + " with value " + value.ToString());
        }
    }
Exemple #7
0
    private void Awake()
    {
        GameManager.Instance.RegisterManager(this);

        GamePaused         = new UnityEvent();
        GameResumed        = new UnityEvent();
        TimeScrolled       = new UnityEventInt();
        EnemyDied          = new UnityEvent();
        EnemyReachedCastle = new UnityEvent();
        StatisticChanged   = new UnityEvent();
        MouseClickOnRoad   = new UnityEventVector3();
    }
Exemple #8
0
        public static void StopListening(string eventName, UnityAction <int> listener)
        {
            eventName = StandardizeString(eventName);

            //if (eventManager == null) return;
            UnityEventInt thisEvent = null;

            if (instance.NameToListenedEventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.RemoveListener(listener);
            }
        }
Exemple #9
0
    public static void StopListening(string eventName, UnityAction <int> listener)
    {
        if (Instance == null)
        {
            return;
        }
        UnityEventInt thisEvent = null;

        if (Instance.eventDictionaryInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Exemple #10
0
    // Use this for initialization
    void Start()
    {
        //RegisterSwarms();
        //originSwarm = swarmControllers[0];
        //destinationSwarm = swarmControllers[1];

        if (OnHomeWorkerCountChange == null)
        {
            OnHomeWorkerCountChange = new UnityEventInt();
        }

        ReturnAllFlocksToHive();
    }
Exemple #11
0
 public VariableIntListenerClass(VariableInt variable)
 {
     if (variable == null)
     {
         Debug.Log("variable is null");
         return;
     }
     this.variable              = variable;
     onVariableChanged          = new UnityEventInt();
     onVariableIncreased        = new UnityEventInt();
     onVariableChangedAboveZero = new UnityEventInt();
     onVariableZero             = new UnityEvent();
     Init();
 }
Exemple #12
0
    public static void StopListening(GameData.Event eventName, UnityAction <int> listener)
    {
        if (EventManager.Instance == null)   //au cas ou on a déja supprimé l'eventManager
        {
            return;
        }
        UnityEventInt thisEvent = null;

        //si on veut unregister et que la clé existe dans le dico..
        if (Instance.eventDictionaryInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Exemple #13
0
    public static void StopListening(string eventName, UnityAction <int> listener)
    {
        if (messageManager == null)
        {
            return;
        }
        UnityEventInt thisEvent = null;

        // Try to get unity event by event name and remove its listener
        if (instance.eventDictionaryParamInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Exemple #14
0
    public static void StartListening(string eventName, UnityAction <int> listener)
    {
        UnityEventInt thisEvent = null;

        if (Instance.eventDictionaryInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new UnityEventInt();
            thisEvent.AddListener(listener);
            Instance.eventDictionaryInt.Add(eventName, thisEvent);
        }
    }
Exemple #15
0
    // Override with parameter <int>
    public static void StartListening(string eventName, UnityAction <int> listener)
    {
        UnityEventInt thisEvent = null;

        Debug.Log("MessageManager adds " + eventName);
        // Try get value a eventName and add listener to it
        if (instance.eventDictionaryParamInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new UnityEventInt();
            thisEvent.AddListener(listener);
            instance.eventDictionaryParamInt.Add(eventName, thisEvent);
        }
    }
Exemple #16
0
        public static void TriggerDataEvent(UnityEventData unityEventData)
        {
            if (unityEventData == null || unityEventData.eventName == "")
            {
                VRsqrUtil.Debug.Log(LogLevel.Error, "TriggerDataEvent: Illegal unityEventData argument");
                return;
            }

            UnityEventInt thisEvent      = null;
            bool          listenerExists = instance.NameToListenedEventDictionary.TryGetValue(unityEventData.eventName, out thisEvent);

            VRsqrUtil.Debug.LogInfo("TriggerDataEvent: eventName = " + unityEventData.eventName + "    listenerExists = " + listenerExists);
            if (unityEventData.presistentData || listenerExists) // there is at least one listerner to this event
            {
                int eventContextInd = GetFreeEventDataInd();
                int dataBufferInd   = eventContextInd % numDataBuffers;
                eventDataBuffers[dataBufferInd] = unityEventData;
                eventDataBuffers[dataBufferInd].eventContextInd = eventContextInd;

                // keep the index of the most recent triggering of this event - to support getting values of past events (e.g. in case of persistent events with no listener)
                //instance.NameToLastEventIndDictionary.Add(unityEventData.eventName.ToLower(), dataBufferInd);
                instance.NameToLastEventIndDictionary[unityEventData.eventName] = dataBufferInd;

                unityEventData.varInd = new Dictionary <string, int>();
                if (unityEventData.eventParams != null)
                {
                    for (int i = 0; i < unityEventData.eventParams.Length; i++)
                    {
                        //unityEventData.varInd.Add(unityEventData.eventParams[i].NameString.ToLower(), i);
                        //unityEventData.varInd[unityEventData.eventParams[i].NameString.ToLower()] = i;
                        unityEventData.eventParams[i].NameString = VRsqr_EventsManager.StandardizeString(unityEventData.eventParams[i].NameString);
                        unityEventData.varInd[unityEventData.eventParams[i].NameString] = i;
                        VRsqrUtil.Debug.Log(LogLevel.Debug, "---------- TriggerDataEvent: NameString = " + unityEventData.eventParams[i].NameString +
                                            " , ValString = " + unityEventData.eventParams[i].ValString +
                                            " , paramObjVal = " + unityEventData.eventParams[i].paramObjVal);
                    }
                }

                if (listenerExists)
                {
                    thisEvent.Invoke(eventContextInd);
                }
            }
        }
Exemple #17
0
 public VariableIntListenerClass(
     VariableInt variable,
     ref UnityEventInt onVariableChanged,
     ref UnityEventInt onVariableIncreased,
     ref UnityEventInt onVariableChangedAboveZero,
     ref UnityEvent onVariableZero)
 {
     if (variable == null)
     {
         Debug.Log("variable is null");
         return;
     }
     this.variable                   = variable;
     this.onVariableChanged          = onVariableChanged;
     this.onVariableIncreased        = onVariableIncreased;
     this.onVariableChangedAboveZero = onVariableChangedAboveZero;
     this.onVariableZero             = onVariableZero;
     Init();
 }
Exemple #18
0
        public static void StartListening(string eventName, UnityAction <int> listener)
        {
            eventName = StandardizeString(eventName);

            VRsqrUtil.Debug.LogInfo("StartListening: eventName = " + eventName);
            UnityEventInt thisEvent = null;

            if (instance.NameToListenedEventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.AddListener(listener);
            }
            else
            {
                thisEvent = new UnityEventInt();
                thisEvent.AddListener(listener);
                //instance.NameToListenedEventDictionary.Add(eventName.ToLower(), thisEvent);
                instance.NameToListenedEventDictionary[eventName] = thisEvent;
            }
        }