Ejemplo n.º 1
0
 private void OnEnable()
 {
     if (OnTargetingAngleDetectedEvent == null)
     {
         OnTargetingAngleDetectedEvent = new UnityEventInt();
     }
 }
Ejemplo n.º 2
0
 public static void TryInvoke(this UnityEventInt evt, int value)
 {
     if (evt != null)
     {
         evt.Invoke(value);
     }
 }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 4
0
    public static void TriggerEvent(GameData.Event eventName, int value)
    {
        UnityEventInt thisEvent = null;

        if (Instance.eventDictionaryInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(value);
        }
    }
Ejemplo n.º 5
0
    // 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;
    }
Ejemplo n.º 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());
        }
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        //RegisterSwarms();
        //originSwarm = swarmControllers[0];
        //destinationSwarm = swarmControllers[1];

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

        ReturnAllFlocksToHive();
    }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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;
            }
        }