Exemplo n.º 1
0
    protected virtual void OnPuppeteerDeactivate()
    {
        puppetState = PuppetStates.Inactive;
        SetAnimatorControllerActive(false);

        onPuppeteerDeactivate.SafeInvoke();
    }
Exemplo n.º 2
0
        public void Activate(UIPanel panel, UIType type = UIType.NormalView, Action callBack = null)
        {
            //if (mPanelStack.Count > 0 && panel.GetInstanceID() == mPanelStack.Last().mPanel.GetInstanceID())
            //   return; //early exit if trying to activate the same panel again
            //commented since the user should be able to activate the same panel again

            switch (type)
            {
            case UIType.NormalView:
            {
                if (mPanelStack.Count > 0 && mPanelStack.Last().mType != UIType.BaseView)     //excluding the base view
                {
                    mPanelStack.Last().mPanel.DeactivatePanel();
                }

                break;
            }

            case UIType.StackedView:
            {
                break;
            }

            case UIType.BaseView:
            {
                OnLandedOnLastPanel.SafeInvoke();
                LandedOnLastPanel.SafeInvoke();
                break;
            }
            }

            Debug.Log("Activating a " + type + " Panel: " + panel.name);

            //debug purpose
            _currentUI.mPanel = panel;
            _currentUI.mType  = type;

            if (mPanelStack.Contains(new ViewInformation(panel, type)))
            {
                mPanelStack.Remove(new ViewInformation(panel, type));
            }

            mPanelStack.AddLast(new ViewInformation(panel, type));

            panel.ActivatePanel();
            callBack.SafeInvoke();
        }
Exemplo n.º 3
0
        public void PressBackToPause()
        {
            if (CanPause)
            {
                //note: implemented as unity action, connect it on the editor

                OnPause.SafeInvoke();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Starts the stopwatch. Does not reset the current value
        /// </summary>
        public virtual void StartStopwatch()
        {
            if (IsStopwatchRunning)
            {
                return;
            }

            stopwatchCoroutine = StartCoroutine(StopwatchFunctionality());
            OnStopwatchStarted.SafeInvoke();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Stops the timer
        /// </summary>
        public virtual void StopTimer()
        {
            if (!IsTimerRunning)
            {
                return;
            }

            StopCoroutine(timerCoroutine);
            timerCoroutine = null;
            OnTimerStopped.SafeInvoke();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Stops the stopwatchs. Does not reset the current value
        /// </summary>
        public virtual void StopStopwatch()
        {
            if (!IsStopwatchRunning)
            {
                return;
            }

            StopCoroutine(stopwatchCoroutine);
            stopwatchCoroutine = null;

            OnStopwatchStopped.SafeInvoke();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Logic for the timer
        /// </summary>
        /// <param name="Duration">How long the timer should run for</param>
        /// <returns>Enumerator</returns>
        protected virtual IEnumerator TimerFunctionality(float Duration)
        {
            if (UseWaitSecondsRealTime)
            {
                yield return(new WaitForSecondsRealtime(Duration));
            }
            else
            {
                yield return(new WaitForSeconds(Duration));
            }

            OnTimerElapsed.SafeInvoke();
            timerCoroutine = null;
        }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetAxis(AxisName) == 0f)
     {
         OnAxisZeroed.SafeInvoke();
     }
     else if (Input.GetAxis(AxisName) > 0f)
     {
         OnAxisPositive.SafeInvoke();
     }
     else if (Input.GetAxis(AxisName) < 0f)
     {
         OnAxisNegative.SafeInvoke();
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Resets the stopwatch value
        /// </summary>
        /// <param name="StartIfNotRunning">True to start the stopwatch if it isn't currently running</param>
        public virtual void ResetStopwatch(bool StartIfNotRunning = true)
        {
            secondsPassed = 0f;

            if (!IsStopwatchRunning && StartIfNotRunning)
            {
                StartStopwatch();
            }
            else
            {
                OnStopwatchRestarted.SafeInvoke();
            }

            OnIntervalElapsed.SafeInvoke(secondsPassed);
        }
        void Update()
        {
            if (transform.parent.childCount > _oldChildCount)
            {
                SetSiblingIndex();
            }

            if (transform.hasChanged)
            {
                if (EnableEvent)
                {
                    OnTransformChanged.SafeInvoke();
                }
            }
        }
Exemplo n.º 11
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetButtonUp(ButtonName))
            {
                OnButtonPress.SafeInvoke();
            }

            if (Input.GetButtonDown(ButtonName))
            {
                OnButtonDown.SafeInvoke();
            }

            if (Input.GetButton(ButtonName))
            {
                OnButtonHeld.SafeInvoke();
            }
        }
Exemplo n.º 12
0
 void OnEnable()
 {
     if (Toggle)
     {
         Toggle.onValueChanged.AddListener((isOn) =>
         {
             if (isOn)
             {
                 OnToggleOn.SafeInvoke();
             }
             else
             {
                 OnToggleOff.SafeInvoke();
             }
         });
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Starts the timer
        /// </summary>
        /// <param name="ResetIfRunning">True to reset the timer if it's currently running, false to ignore this call</param>
        public virtual void StartTimer(bool ResetIfRunning = false)
        {
            if (IsTimerRunning)
            {
                if (ResetIfRunning)
                {
                    StopTimer();
                }
                else
                {
                    return;
                }
            }

            timerCoroutine = StartCoroutine(TimerFunctionality(Duration));
            OnTimerStarted.SafeInvoke();
        }
Exemplo n.º 14
0
    protected virtual void OnPuppeteerActivate()
    {
        // Wait to set active on next frame, so we don't take in the input for the current frame
        // (e.g. the input for switching to Puppeteer mode) and call PlayerStickerEffect() on same frame.
        StartCoroutine(WaitNextFrameSwitchState());

        IEnumerator WaitNextFrameSwitchState()
        {
            yield return(null);

            puppetState = PuppetStates.Active;

            SetAnimatorControllerActive(true);

            onPuppeteerActivate.SafeInvoke();
        }
    }
Exemplo n.º 15
0
        public virtual void DeactivatePanel(bool ignoreUnityTimeScale = true)
        {
            CacheUiPanels();

            DOTween.Kill(name + "@" + GetInstanceID() + "Activate");

            DeactivateCount++;

            HideAnimation().OnStart(() =>
            {
                DeactivateControl();

                if (!InvokeEventsOnInitialCall && DeactivateCount <= 1)
                {
                    return;
                }

                //system action
                CallBackOnReadyToDeactivate.SafeInvoke();
                //unity action
                OnReadyToDeactivate.SafeInvoke();
            }).OnComplete(() =>
            {
                IsVisible = false;

                if (DisableOnBack)
                {
                    this.Deactivate();
                }

                if (DestroyOnBack)
                {
                    Destroy(gameObject);
                }

                if (!InvokeEventsOnInitialCall && DeactivateCount <= 1)
                {
                    return;
                }

                //system action
                CallBackOnDeactivate.SafeInvoke();
                //unity Action
                OnDeactivate.SafeInvoke();
            }).SetId(name + "@" + GetInstanceID() + "Deactivate").SetUpdate(ignoreUnityTimeScale);
        }
Exemplo n.º 16
0
        public virtual void ActivatePanel(bool ignoreUnityTimeScale = true)
        {
            if (gameObject)
            {
                gameObject.Activate();
            }

            CacheUiPanels();
            DOTween.Kill(name + "@" + GetInstanceID() + "Deactivate");

            ActivateCount++;

            ShowAnimation().OnStart(() =>
            {
                if (!InvokeEventsOnInitialCall && ActivateCount <= 1)
                {
                    return;
                }

                //system Action
                CallBackOnReadyToActivate.SafeInvoke();
                //unity action
                OnReadyToActivate.SafeInvoke();
            })
            .OnComplete(() =>
            {
                IsVisible = true;
                ActivateControl();

                if (!InvokeEventsOnInitialCall && ActivateCount <= 1)
                {
                    return;
                }

                //system Action
                CallBackOnActivate.SafeInvoke();
                //unity action
                OnActivate.SafeInvoke();
            }).SetId(name + "@" + GetInstanceID() + "Activate").SetUpdate(ignoreUnityTimeScale);
        }
Exemplo n.º 17
0
        protected override void OnLevelLoaded(Scene scene)
        {
            base.OnLevelLoaded(scene);

            _canvas = GetComponent <Canvas>();

            if (_canvas)
            {
                _canvas.worldCamera = Camera.main;
            }

            if (ActivateInScenes != null && ActivateInScenes.Any() && ActivateInScenes.Contains(x => x.GetDescription().Equals(scene.name)))
            {
                gameObject.Activate();

                //refresh contents
                OnActivated.SafeInvoke();
                OnActivatedEvent.SafeInvoke();
            }
            else
            {
                gameObject.Deactivate();
            }
        }
Exemplo n.º 18
0
        public void Back()
        {
            _lastClosedPanel = null;

            if (mPanelStack.Count <= 0)
            {
                PressedBackOnLastPanel.SafeInvoke();
                OnPressBackOnLastPanel.SafeInvoke();
                return;
            }

            var panelInfo = mPanelStack.Last();

            //only process back if the gameObject is active
            if (!panelInfo.mPanel.isActiveAndEnabled)
            {
                return;
            }

            switch (panelInfo.mType)
            {
            case UIType.NormalView:
            {
                Debug.Log("Deactivated A NormalView Panel: " + mPanelStack.Last().mPanel.name);
                mPanelStack.Last().mPanel.DeactivatePanel();
                _lastClosedPanel = mPanelStack.Last();
                mPanelStack.RemoveLast();
                if (mPanelStack.Count > 0)
                {
                    var peekPanel = mPanelStack.Last();     //.mPanel.ActivatePanel();
                    peekPanel.mPanel.ActivatePanel();

                    if (peekPanel.mType == UIType.BaseView && mPanelStack.Count == 1)
                    {
                        OnLandedOnLastPanel.SafeInvoke();
                        LandedOnLastPanel.SafeInvoke();
                    }

                    //debug purpose
                    _currentUI.mPanel = peekPanel.mPanel;
                    _currentUI.mType  = peekPanel.mType;
                }
                else
                {
                    //debug purpose
                    _currentUI.mPanel = null;
                    _currentUI.mType  = 0;
                }


                break;
            }

            case UIType.StackedView:
            {
                Debug.Log("Deactivated a StackedView Panel: " + mPanelStack.Last().mPanel.name);
                mPanelStack.Last().mPanel.DeactivatePanel();
                _lastClosedPanel = mPanelStack.Last();
                mPanelStack.RemoveLast();

                if (mPanelStack.Count == 1)
                {
                    OnLandedOnLastPanel.SafeInvoke();
                    LandedOnLastPanel.SafeInvoke();
                }

                //debug purpose
                var peekPanel = mPanelStack.Last();

                _currentUI.mPanel = peekPanel.mPanel;
                _currentUI.mType  = peekPanel.mType;

                break;
            }

            case UIType.BaseView:
            {
                Debug.Log("Landed Base View");
                ShowBaseView();

                PressedBackOnLastPanel.SafeInvoke();
                OnPressBackOnLastPanel.SafeInvoke();
                break;
            }
            }

            OnPressBack.SafeInvoke();
            PressBack.SafeInvoke();
        }
 public virtual void Interact()
 {
     InteractionResponse.SafeInvoke();
 }
Exemplo n.º 20
0
 /// <summary>
 /// Handles invoking the collision response for children
 /// </summary>
 protected virtual void InvokeResponse()
 {
     CollisionResponse.SafeInvoke();
 }
 private void OnDisable()
 {
     uEventOnDisable.SafeInvoke();
 }
Exemplo n.º 22
0
 protected override void OnDeactivate()
 {
     DeactivationResponse.SafeInvoke();
 }