예제 #1
0
    public void Setup(string _name = "")
    {
        if (!string.IsNullOrEmpty(_name))
        {
            mapName = _name;
        }

        editorOpen = false;
        prevState  = false;

        button = null;
        axis1D = null;
        axis2D = null;


        axisType = AxisType.Button;

        typeButton = InputTypeButton.ThumbClick;
        type1D     = InputTypeAxis1D.Trigger;
        type2D     = InputTypeAxis2D.Thumb2D;

        Activated   = new UnityEventVoid();
        Deactivated = new UnityEventVoid();

        UpdateBool = new UnityEventButton();
        Update1D   = new UnityEventFloat();

        Moved2D  = new UnityEventAxis2D();
        Moved2DX = new UnityEventFloat();
        Moved2DY = new UnityEventFloat();
    }
예제 #2
0
 public static void TryInvoke(this UnityEventFloat evt, float value)
 {
     if (evt != null)
     {
         evt.Invoke(value);
     }
 }
예제 #3
0
            public string GetDelegateText(UnityEventFloat ue, Func <float, bool> a)
            {
                StringBuilder text = new StringBuilder();

                if (ue != null)
                {
                    for (int i = 0; i < ue.GetPersistentEventCount(); ++i)
                    {
                        if (text.Length > 0)
                        {
                            text.Append("\n");
                        }
                        UnityEngine.Object obj = ue.GetPersistentTarget(i);
                        string             t   = obj != null ? obj.name : "<???>";
                        text.Append(t).Append(".").Append(KBind.EventSet.FilterMethodName(ue.GetPersistentMethodName(i)));
                    }
                }
                if (a != null)
                {
                    Delegate[] delegates = a.GetInvocationList();
                    for (int i = 0; i < delegates.Length; ++i)
                    {
                        if (text.Length > 0)
                        {
                            text.Append("\n");
                        }
                        text.Append(delegates[i].Target).Append(".").Append(delegates[i].Method.Name);
                    }
                }
                return(text.ToString());
            }
예제 #4
0
 public void DeserializeEvents()
 {
     if (!string.IsNullOrEmpty(json_onEnergyChanged))
     {
         OnEnergyChanged = JsonUtility.FromJson <UnityEventFloat>(json_onEnergyChanged);
         AssignTargets(OnEnergyChanged, targets_onEnergyChanged);
     }
 }
예제 #5
0
    public static void TriggerEvent(string eventName, float param)
    {
        UnityEventFloat thisEvent = null;

        if (Instance != null && Instance.eventDictionaryFloat.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(param);
        }
    }
예제 #6
0
    public static void TriggerEvent(string eventName, float value)
    {
        UnityEventFloat thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(value);
        }
    }
예제 #7
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;
    }
예제 #8
0
    void Start()
    {
        moduleCosts = BalanceTweaks.GlobalInstance.moduleCosts;

        NextTier = 1;

        CheckNextThreshold();
        upgradeAvailable          = false;
        upgradeTierAvailableEvent = playerM.eventManager.GetEvent(PlayerEvents.UpgradeAvailable);
        upgradeAppliedEvent       = playerM.eventManager.GetEvent(PlayerEvents.UpgradeApplied);

        playerM.eventManager.GetEvent(PlayerEvents.EnergyChanged).AddListener(EnergyChangeEvent);
    }
예제 #9
0
    private void Start()
    {
        EventManager eventM = playerM.eventManager;

        wasHitEvent = eventM.GetEvent(PlayerEvents.WasHit);

        eventM.GetEvent(PlayerEvents.WasKilled).AddListener((f) => {
            if (lastAttacker != null)
            {
                lastAttacker.eventManager.GetEvent(PlayerEvents.KilledEnemy).Invoke(playerM.playerNum);
            }
        });
    }
예제 #10
0
    public static void StopListening(string eventName, UnityAction <float> listener)
    {
        if (eventManager == null)
        {
            return;
        }
        UnityEventFloat thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
예제 #11
0
    public UnityEventFloat GetEvent(string name)
    {
        UnityEventFloat e;

        _events.TryGetValue(name, out e);

        if (e == null)
        {
            e = new UnityEventFloat();
            _events.Add(name, e);
        }

        return(e);
    }
예제 #12
0
    void Start()
    {
        if (TankTweaksProp == null)
        {
            TankTweaksProp = BalanceTweaks.GlobalInstance.medTank;
        }

        eventM    = playerM.eventManager;
        moveEvent = eventM.GetEvent(PlayerEvents.Move);

        MoveInput = Vector2.zero;

        rb = this.GetComponent <Rigidbody2D>();
    }
예제 #13
0
    public static void StartListening(string eventName, UnityAction <float> listener)
    {
        UnityEventFloat thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new UnityEventFloat();
            thisEvent.AddListener(listener);
            instance.eventDictionary.Add(eventName, thisEvent);
        }
    }
예제 #14
0
    void Start()
    {
        EventManager eventM       = playerM.eventManager;
        HealthTweaks healthTweaks = BalanceTweaks.GlobalInstance.health;

        Init(eventM.GetEvent(PlayerEvents.HealthChanged), healthTweaks.medHullHealth);
        SetStatValue(healthTweaks.medHullHealth);

        wasKilledEvent = eventM.GetEvent(PlayerEvents.WasKilled);
        lostEvent      = eventM.GetEvent(PlayerEvents.Lost);

        spawnPoint = playerM.tankObj.transform.position;
        lives      = healthTweaks.lives;
        eventM.GetEvent(PlayerEvents.WasHit).AddListener(WasHitEvent);
    }
예제 #15
0
    public void AddListenerToADLRunStatEvent(string eventKey, UnityAction <float> listener)
    {
        UnityEventFloat anADLRunStatEvent;

        if (EventKeyToADLRunStatEvents.TryGetValue(eventKey, out anADLRunStatEvent))
        {
            anADLRunStatEvent.AddListener(listener);
        }
        else
        {
            anADLRunStatEvent = new UnityEventFloat();
            anADLRunStatEvent.AddListener(listener);
            EventKeyToADLRunStatEvents.Add(eventKey, anADLRunStatEvent);
        }
    }
예제 #16
0
    public void LoadSceneAsync(int sceneBuildIndex, LoadSceneMode loadSceneMode = LoadSceneMode.Single, UnityEventFloat onLoadingSceneAsync = null)
    {
        if (this._loadSceneAsyncProcess != null)
        {
            this.StopCoroutine(this._loadSceneAsyncProcess);
        }

        this._loadSceneAsyncProcess = this.StartCoroutine(this.LoadSceneAsyncProcess(sceneBuildIndex, loadSceneMode, onLoadingSceneAsync));
    }
예제 #17
0
    private IEnumerator LoadSceneAsyncProcess(int sceneBuildIndex, LoadSceneMode loadSceneMode, UnityEventFloat onLoadingSceneAsync)
    {
        AsyncOperation sceneLoadingAsyncOperation = SceneManager.LoadSceneAsync(sceneBuildIndex, loadSceneMode);

        while (!sceneLoadingAsyncOperation.isDone)
        {
            this._onLoadingSceneAsync.Invoke(sceneLoadingAsyncOperation.progress);
            onLoadingSceneAsync?.Invoke(sceneLoadingAsyncOperation.progress);

            yield return(null);
        }
    }