コード例 #1
0
        /// <summary>
        /// Is current time within the defined time frame
        /// </summary>
        /// <returns><c>true</c>, if current time is within absolute defined time, <c>false</c> otherwise.</returns>
        private bool IsWithinTimeFrame()
        {
            if (ActivateOnDependencyMap.AreDependenciesSatisfied)
            {
                // if time is beyond the specified wait time
                if (delayed && Time.time >= startTime + delayDuration || !delayed)
                {
                    // if it never expires OR expires and below ending time frame
                    if (!expires || (expires && Time.time < startTime + delayDuration + activeDuration))
                    {
                        // notify manager
                        SetTriggerState(Gaze_TriggerState.ACTIVE);
                        canBeTriggered = true;

                        // trigger if auto-trigger is set to START
                        if (GetAutoTriggerMode().Equals(Gaze_AutoTriggerMode.START))
                        {
                            TriggerCount++;
                            canBeTriggered = false;
                            Gaze_EventManager.FireTriggerEvent(new Gaze_TriggerEventArgs(gameObject, Time.time, true, false, TriggerCount, GetAutoTriggerMode(), GetReloadMode(), reloadMaxRepetitions));

                            // check if reload needed
                            if (reload)
                            {
                                ScheduleAutoReload();
                            }
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #2
0
        public void Validate()
        {
            ++TriggerCount;

            // notify manager
            Gaze_EventManager.FireTriggerEvent(new Gaze_TriggerEventArgs(gameObject, Time.time, true, false, TriggerCount, GetAutoTriggerMode(), GetReloadMode(), reloadMaxRepetitions));
        }
コード例 #3
0
        private void HandleReload()
        {
            if (reload)
            {
                // reload if necessary
                if (Time.time > nextReloadTime && reloadScheduled)
                {
                    Reload();

                    // notify manager
                    Gaze_EventManager.FireTriggerEvent(new Gaze_TriggerEventArgs(gameObject, Time.time, false, true, reloadCount, GetAutoTriggerMode(), GetReloadMode(), reloadMaxRepetitions));
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Is Current time after the time frame.
        /// </summary>
        /// <returns><c>true</c>, if current time is after defined time frame, <c>false</c> otherwise.</returns>
        private bool IsAfterTimeFrame()
        {
            // if it expires
            if (expires)
            {
                // set delay duration
                delayDuration = delayed ? delayDuration : 0;

                // check if we're over the time limit
                if (Time.time >= startTime + delayDuration + activeDuration)
                {
                    // trigger if auto-trigger is set to END
                    // FIX GAZE-193 GazeSDK_v0.5.6 : and if canBeTriggered
                    if (GetAutoTriggerMode().Equals(Gaze_AutoTriggerMode.END) && canBeTriggered)
                    {
                        TriggerCount++;
                        Gaze_EventManager.FireTriggerEvent(new Gaze_TriggerEventArgs(gameObject, Time.time, true, false, TriggerCount, GetAutoTriggerMode(), GetReloadMode(), reloadMaxRepetitions));
                    }

                    canBeTriggered = false;

                    // notify manager
                    SetTriggerState(Gaze_TriggerState.AFTER);

                    return(true);
                }
            }

            // if deactivated by dependencies
            if (!ActivateOnDependencyMap.AreDependenciesSatisfied)
            {
                canBeTriggered = false;

                // notify manager
                SetTriggerState(Gaze_TriggerState.AFTER);

                return(true);
            }
            return(false);
        }
コード例 #5
0
        void Start()
        {
            SetDelayRandom();
            SetExpireRandom();
            focusInProgress = false;
            focusComplete   = focusDuration <= 0 ? true : false;
            ActivateOnDependencyMap.AreDependenciesSatisfied = dependent ? false : true;
            startTime   = Time.time;
            reloadCount = 0;

            // notify we're before the activity window time
            SetTriggerState(Gaze_TriggerState.BEFORE, true);

            Gaze_EventManager.FireTriggerEvent(new Gaze_TriggerEventArgs(gameObject, Time.time, false, false, -1, GetAutoTriggerMode(), GetReloadMode(), reloadMaxRepetitions));

            // check loss speed is valid if used
            FocusLossSpeed = (GetFocusLossMode() == Gaze_FocusLossMode.FADE && FocusLossSpeed > 0) ? FocusLossSpeed : 1f;

            CheckReloadParams();

            collidingProximities = new List <GameObject>();
        }
コード例 #6
0
        private void UpdateFocus()
        {
            // if focus is not complete
            if (!focusComplete || focusDuration <= 0f)
            {
                // set the flag
                focusInProgress = true;

                // update focus time
                focusTotalTime += Time.deltaTime;

                if (m_ProgressIndicator != null)
                {
                    m_ProgressIndicator.Show();
                    m_ProgressIndicator.UpdateProgress(focusTotalTime / focusDuration);
                }

                // set focused flag if focus time overpassed
                if (focusTotalTime >= focusDuration)
                {
                    focusComplete   = true;
                    focusInProgress = false;
                    canBeTriggered  = false;
                    TriggerCount++;

                    // notify manager
                    Gaze_EventManager.FireTriggerEvent(new Gaze_TriggerEventArgs(gameObject, Time.time, true, false, TriggerCount, GetAutoTriggerMode(), GetReloadMode(), reloadMaxRepetitions));
                    //Debug.Log(name + " Is triggered!!!");

                    // check if reload needed
                    if (reload)
                    {
                        ScheduleAutoReload();
                    }
                    return;
                }
            }
        }