Example #1
0
    public static void TriggerEvent(GameData.Event eventName, DataEventManager data)
    {
        UnityEventData thisEvent = null;

        if (Instance.eventDictionaryData.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(data);
        }
    }
Example #2
0
    public static void TriggerEvent(GameData.Event eventName, bool active, int secondValue)
    {
        UnityEventBoolInt thisEvent = null;

        if (Instance.eventDictionaryBoolInt.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(active, secondValue);
        }
    }
Example #3
0
    public static void TriggerEvent(GameData.Event eventName, bool value)
    {
        UnityEventBool thisEvent = null;

        if (Instance.eventDictionaryBool.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(value);
        }
    }
Example #4
0
    public static void TriggerEvent(GameData.Event eventName, GameObject obj, int firstValue, int secondValue)
    {
        UnityEventGameObject2Int thisEvent = null;

        if (Instance.eventDictionaryGameObject2Int.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(obj, firstValue, secondValue);
        }
    }
Example #5
0
    /// <summary>
    /// trigger un event
    /// </summary>
    public static void TriggerEvent(GameData.Event eventName)
    {
        if (EventManager.Instance == null)   //au cas ou on a déja supprimé l'eventManager
        {
            return;
        }
        UnityEvent thisEvent = null;

        if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke();
        }
    }
Example #6
0
    public static void StopListening(GameData.Event eventName, UnityAction <DataEventManager> listener)
    {
        if (EventManager.Instance == null)   //au cas ou on a déja supprimé l'eventManager
        {
            return;
        }
        UnityEventData thisEvent = null;

        //si on veut unregister et que la clé existe dans le dico..
        if (Instance.eventDictionaryData.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Example #7
0
    // Update is called once per frame
    void FixedUpdate()
    {
        for (int i = 0; i < data.currTrial.Events.Count; i++)
        {
            GameData.Event currEvent = data.currTrial.Events[i];
            if (currEvent.EventType.ToLower().Equals("sign"))
            {
                // Check if time is matching time, if so,
                // pop the UI graphic.
                if (data.currTrial.Timer.ElapsedMilliseconds >= currEvent.SpawnTime && data.currTrial.Timer.ElapsedMilliseconds <= currEvent.DespawnTime)
                {
                    if (currEvent.SpawnSide.ToLower().Equals("r"))
                    {
                        var       filedata = File.ReadAllBytes(Application.dataPath + "/StreamingAssets/config/images/Sign1.png");
                        Texture2D tex      = new Texture2D(1, 1);
                        tex.LoadImage(filedata);

                        RawImage RightImage = (RawImage)RightSignPanel.GetComponent("RawImage");
                        RightImage.texture = tex;
                        RightImage.enabled = true;
                    }
                    // left side
                    else
                    {
                        var       filedata = File.ReadAllBytes(Application.dataPath + "/StreamingAssets/config/images/Sign2.png");
                        Texture2D tex      = new Texture2D(1, 1);
                        tex.LoadImage(filedata);

                        RawImage RightImage = (RawImage)LeftSignPanel.GetComponent("RawImage");
                        RightImage.texture = tex;
                        RightImage.enabled = true;
                    }
                }

                else
                {
                    if (currEvent.SpawnSide.ToLower().Equals("r"))
                    {
                        RawImage RightImage = (RawImage)RightSignPanel.GetComponent("RawImage");
                        RightImage.enabled = false;
                    }
                    else
                    {
                        RawImage LeftImage = (RawImage)LeftSignPanel.GetComponent("RawImage");
                        LeftImage.enabled = false;
                    }
                }
            }
        }
    }
Example #8
0
    // TODO : refactor.
    private void LoadLanes()
    {
        float ChunkCalculationTime;

        for (int i = 0; i < data.currTrial.Events.Count; i++)
        {
            GameData.Event CurrEvent = data.currTrial.Events[i];
            if (CurrEvent.EventType.ToLower().Equals("lane"))
            {
                if (CurrEvent.DespawnTime == 0f)
                {
                    ChunkCalculationTime = data.currTrial.TimeAllotted;
                }
                else
                {
                    ChunkCalculationTime = CurrEvent.DespawnTime - CurrEvent.SpawnTime;
                }


                if (CurrEvent.SpawnSide.ToLower().Equals("r"))
                {
                    var ChunksRequired = CalculateNumberOfChunksRequired(ChunkCalculationTime, data.GlobalData.MovementSpeed, 100);
                    for (int j = 0; j <= ChunksRequired; j++)
                    {
                        float      SpawnDistance = CalculateLaneSpawnDistance(CurrEvent.SpawnTime, data.GlobalData.MovementSpeed);
                        GameObject LaneInstance  = Instantiate(Resources.Load <GameObject>("prefabs/LaneRight_100m_WP"), new Vector3(RIGHT_LANE_POS_X, RIGHT_LANE_POS_Y, SpawnDistance + (100 * j)), Quaternion.Euler(0, 180, 0));
                        _createdGameObjects.Add(LaneInstance);
                    }
                }
                else
                {
                    var ChunksRequired = CalculateNumberOfChunksRequired(ChunkCalculationTime, data.GlobalData.MovementSpeed, 100);
                    for (int j = 0; j <= ChunksRequired; j++)
                    {
                        float      SpawnDistance = CalculateLaneSpawnDistance(CurrEvent.SpawnTime, data.GlobalData.MovementSpeed);
                        GameObject LaneInstance  = Instantiate(Resources.Load <GameObject>("prefabs/LaneLeft_100m_WP"), new Vector3(LEFT_LANE_POS_X, LEFT_LANE_POS_Y, SpawnDistance + (100 * j)), Quaternion.identity);
                        _createdGameObjects.Add(LaneInstance);
                    }
                }
            }
        }
    }
Example #9
0
    /// <summary>
    /// ajoute un listener ?
    /// we look at the dictionary,
    /// we see if we have already a key value pair for what we are trying to add
    /// if so, we add to it,
    /// if not, we create a new unity event, we add the listener to it,
    /// and we push that into the dictionary as the very first entry
    /// </summary>
    public static void StartListening(GameData.Event eventName, UnityAction listener)
    {
        if (!Instance)
        {
            return;
        }

        UnityEvent thisEvent = null;

        if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new UnityEvent();
            thisEvent.AddListener(listener);
            Instance.eventDictionary.Add(eventName, thisEvent);
        }
    }