public void GoToCountdownScreen()
 {
     _currentPage.Hide();
     _timeOutScreen.Hide();
     _countdownPage.Show();
     _currentPage = _countdownPage;
 }
    /// <summary>
    /// Finds all visible targets and adds them to the visibleTargets list.
    /// </summary>
    void FindVisibleTargets()
    {
        Collider[] targetsInViewRadius = Physics.OverlapSphere(transform.position, viewRadius, targetMask);

        for (int i = 0; i < targetsInViewRadius.Length; i++)
        {
            Transform target  = targetsInViewRadius[i].transform;
            bool      isInFOV = false;

            //check if hideable should be hidden or not
            Vector3 dirToTarget = (target.position - transform.position).normalized;
            if (Vector3.Angle(transform.forward, dirToTarget) < viewAngle / 2)
            {
                float dstToTarget = Vector3.Distance(transform.position, target.position);
                if (!Physics.Raycast(transform.position, dirToTarget, dstToTarget, obstacleMask))
                {
                    isInFOV = true;
                }
            }

            //apply effect to IHideable
            IHideable hideable = target.GetComponent <IHideable>();
            if (hideable != null)
            {
                if (isInFOV)
                {
                    target.GetComponent <IHideable>().OnFOVEnter();
                }
                else
                {
                    target.GetComponent <IHideable>().OnFOVLeave();
                }
            }
        }
    }
Esempio n. 3
0
    void FVT(int i, ref Collider2D[] targetsInViewRadius)
    {
        if (targetsInViewRadius[i] != null)
        {
            Transform target  = targetsInViewRadius[i].transform;
            bool      isInFOV = false;

            //apply effect to IHideable
            IHideable hideable = target.GetComponent <IHideable>();


            //check if hideable should be hidden or not
            Vector3 dirToTarget = (target.position - transform.position).normalized;
            float   dstToTarget = Vector3.Distance(transform.position, target.position);
            if (!Physics2D.Raycast(transform.position, dirToTarget, dstToTarget, obstacleMask))
            {
                isInFOV = true;
            }

            if (hideable != null)
            {
                if (isInFOV)
                {
                    StartCoroutine(hideable.FOVEnterRoutine());
                    //Debug.Log("ENTER");
                }
                else
                {
                    StartCoroutine(hideable.FOVLeaveRoutine());
                }
            }
        }
    }
 public void GoToFinalScoreScreen()
 {
     _currentPage.Hide();
     _timeOutScreen.Hide();
     _finalScoreScreen.Show();
     _currentPage = _finalScoreScreen;
 }
        public void GoTo(int index)
        {
            var previous      = _currentPage;
            int previousIndex = _pageIndex;

            try
            {
                _pageIndex   = index;
                _currentPage = _pages[_pageIndex];
                previous.Hide();
                _currentPage.Show();
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                _pageIndex = previousIndex;
                previous.Show();
                _currentPage = previous;
            }
            if (lastPage)
            {
                ApplicationManager.instance.StartSetup();
            }

            _timeOutScreen.Hide();
            _menuBar.SetState(false);
        }
Esempio n. 6
0
 public static dynamic GetTSObject(IHideable dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
 public void GoToScoreScreen()
 {
     _currentPage.Hide();
     _countdownPage.Hide();
     _timeOutScreen.Hide();
     _scoreScreen.Show();
     _currentPage = _scoreScreen;
 }
Esempio n. 8
0
 public void Hide(bool hide, params object[] args)
 {
     if (!IsOpen)
     {
         return;
     }
     IHideable.HideHelper(content, hide);
     IsHidden = hide;
 }
    /// <summary>
    /// Finds all visible targets and adds them to the visibleTargets list.
    /// </summary>
    void FindVisibleTargets()
    {
        if (!photonView.IsMine)
        {
            return;
        }

        Collider[] targetsInViewRadius = Physics.OverlapSphere(transform.position, viewRadius, targetMask);

        Physics.autoSyncTransforms = false;

        /* check normal field of view */
        for (int i = 0; i < targetsInViewRadius.Length; i++)
        {
            if (!targetsInViewRadius[i].isTrigger)
            {
                Transform target  = targetsInViewRadius[i].transform;
                bool      isInFOV = false;

                //check if hideable should be hidden or not
                Vector3 dirToTarget = (target.position - transform.position).normalized;
                if (Vector3.Angle(transform.forward, dirToTarget) < viewAngle / 2)
                {
                    float dstToTarget = Vector3.Distance(transform.position, target.position);
                    if (!Physics.Raycast(transform.position, dirToTarget, dstToTarget, obstacleMask))
                    {
                        isInFOV = true;
                    }
                }
                else if (hasPeripheralVision)
                {
                    float dstToTarget = Vector3.Distance(transform.position, target.position);
                    // here we have to check the distance to the target since the peripheral vision may have a different radius than the normal field of view
                    if (dstToTarget < viewRadiusPeripheralVision && !Physics.Raycast(transform.position, dirToTarget, dstToTarget, obstacleMask))
                    {
                        isInFOV = true;
                    }
                }

                //apply effect to IHideable
                IHideable hideable = target.GetComponent <IHideable>();
                if (hideable != null)
                {
                    if (isInFOV)
                    {
                        target.GetComponent <IHideable>().OnFOVEnter();
                    }
                    else
                    {
                        target.GetComponent <IHideable>().OnFOVLeave();
                    }
                }
            }
        }

        Physics.autoSyncTransforms = true;
    }
 public void GoToCredits()
 {
     _currentPage.Hide();
     _countdownPage.Hide();
     _timeOutScreen.Hide();
     _currentPage.Hide();
     _copyrightScreen.Show();
     _currentPage = _copyrightScreen;
     _menuBar.SetState(false);
 }
Esempio n. 11
0
        private void SwitchView(IHideable sender, string viewName)
        {
            var nextView = this.GetNextView(viewName);

            if (sender != null && !sender.Equals(nextView))
            {
                sender.Hide();
            }
            nextView.Show();
        }
        public void GoToPage()
        {
            _currentPage.Hide();
            var previous = _currentPage;

            _currentPage = _pages[_pageIndex];
            previous.Hide();
            _currentPage.Show();
            _timeOutScreen.Hide();
        }
Esempio n. 13
0
        public TreyIcon(IHideable window)
        {
            this._icon = new NotifyIcon();
            this._icon.Icon = new System.Drawing.Icon(AllStrings.MainIco);

            this._window = window;

            IsVicible = false;

            _icon.MouseDoubleClick += _icon_MouseDoubleClick;
        }
Esempio n. 14
0
        private void SwitchView <T>(IHideable sender, string viewName, ActionPerformedEventArgs <T> args)
            where T : IViewModel, new()
        {
            this.SwitchView(sender, viewName);

            this.RaiseViewSwitch(args, this.OnViewSwitch, viewName);

            if (sender is IActionPerformer <T> )
            {
                this.CurrentViewName = viewName;
            }
        }
Esempio n. 15
0
 protected void Start()
 {
     //singleton pattern
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Debug.Log(this + " singleton  already created. Exterminating..");
         Destroy(this);
     }
     hideable = GetComponent <IHideable>();
     Hide();
     animator = GetComponent <Animator>();
 }
 private void Update()
 {
     if (_screenMenu.loaded)
     {
         int       nextStyle    = 0;
         IHideable previousPage = _screenMenu.GetPreviousPage();
         IHideable nextPage     = _screenMenu.GetNextPage();
         IHideable currentPage  = _screenMenu.GetCurrentPage();
         _previousButton.SetActive(previousPage != null && currentPage != null && currentPage.HasPrevious());
         _nextButton.SetActive(nextPage != null && currentPage != null && currentPage.HasNext(out nextStyle) && nextStyle == 1);
         _nextButton2.SetActive(nextPage != null && currentPage != null && currentPage.HasNext(out nextStyle) && nextStyle == 2);
         _nextButton3.SetActive(nextPage != null && currentPage != null && currentPage.HasNext(out nextStyle) && nextStyle == 3);
         _text.SetActive(_screenMenu.catchScreen);
         _maskCanvasGroup.interactable   = _open;
         _maskCanvasGroup.blocksRaycasts = _open;
     }
 }
Esempio n. 17
0
    public void DoEnemyConditions(Modes currentMode)
    {
        // 敵人特例,控制模式下的移動
        ihideable = this.gameObject.GetComponent <IHideable>();
        if (ihideable == null)
        {
            return;                    // 不是敵人
        }
        if (currentMode == Modes.Lost)
        {
            previousMode = Modes.Lost;
            ihideable.SwitchLost();
            return;
        }
        if (currentMode == Modes.Found)
        {
            previousMode = Modes.Found;
            ihideable.SwitchFound();
            return;
        }
        if (currentMode == Modes.Normal)
        {
            if (previousMode == Modes.Found)
            {
                ihideable.SwitchFound(); //開關,再呼叫一次回復正常
            }
            if (previousMode == Modes.Lost)
            {
                ihideable.SwitchLost();
            }
            previousMode = Modes.Normal;
        }

        // 很蠢,但可以處理FoundEnemy初始化的問題
        // 一開始就enable=false的物件 ModeObserver就沒有註冊到ModeControl(Subject)
        // 第一次 enable=true -> SwitchFound -> enable=false
        if (IsFirstTime)
        {
            ihideable.SwitchFound();
            IsFirstTime = false;
        }
    }
        private IEnumerator Start()
        {
            loaded = false;
            while (!TextureManager.instance.isLoaded || !AudioManager.instance.isLoaded)
            {
                yield return(null);
            }
            ScreenSettings[] screenSettingsArray = ApplicationManager.instance.menuSettings.pageSettings;

            _menuBar.Show();
            _pages = new IHideable[screenSettingsArray.Length];
            for (int i = 0; i < screenSettingsArray.Length; i++)
            {
                ScreenSettings screenSettings = screenSettingsArray[i];
                switch (screenSettings.GetScreenType())
                {
                case ScreenSettings.ScreenType.ContentPage:
                    _pages[i] = InitContentPage((ContentPageSettings)screenSettings);
                    break;

                case ScreenSettings.ScreenType.TextOnly:
                    _pages[i] = InitTextOnlyPage((TextOnlyPageSettings)screenSettings);
                    break;

                case ScreenSettings.ScreenType.PlayerMode:
                    _pages[i] = InitChoosePlayerPage((PlayerModeSettings)screenSettings);
                    break;

                case ScreenSettings.ScreenType.CatchScreen:
                    _pages[i] = InitCatchScreenPage((CatchScreenSettings)screenSettings);
                    break;

                case ScreenSettings.ScreenType.Survey:
                    _pages[i] = InitSurveyPage((SurveyPageSettings)screenSettings);
                    break;
                }
            }
            _currentPage = _pages[0];
            _currentPage.Show();
            loaded = true;
        }
Esempio n. 19
0
 public void Hide(bool hide, params object[] args)
 {
     IHideable.HideHelper(content, hide);
     IsHidden = hide;
 }
Esempio n. 20
0
    /// <summary>
    /// Finds all visible targets and adds them to the visibleTargets list.
    /// </summary>
    void FindVisibleTargets()
    {
        Collider[] targetsInViewRadius = Physics.OverlapSphere(transform.position, viewRadius + 2, targetMask);

        Physics.autoSyncTransforms = false;

        /* check normal field of view */
        for (int i = 0; i < targetsInViewRadius.Length; i++)
        {
            Transform target       = targetsInViewRadius[i].transform;
            Vector2   targetPos    = new Vector2(target.position.x, target.position.z);
            Vector2   transformPos = new Vector2(transform.position.x, transform.position.z);
            bool      isInFOV      = false;

            //check if hideable should be hidden or not
            Vector2 dirToTarget  = (targetPos - transformPos).normalized;
            Vector3 dirToTarget3 = (target.position - transform.position).normalized;
            if (Vector2.Angle(new Vector2(transform.forward.x, transform.forward.z), dirToTarget) < viewAngle / 2)
            {
                float dstToTarget = Vector3.Distance(transformPos, targetPos);
                if (!Physics.Raycast(transform.position, dirToTarget3, dstToTarget, obstacleMask) && dstToTarget < viewRadius)
                {
                    isInFOV = true;
                }
            }
            else if (hasThirdEye)
            {
                //check if hideable should be hidden or not
                if (Vector2.Angle(new Vector2(-transform.forward.x, -transform.forward.z), dirToTarget) < viewAngleThirdEye / 2)
                {
                    float dstToTarget = Vector3.Distance(transformPos, targetPos);
                    if (!Physics.Raycast(transform.position, dirToTarget3, dstToTarget, obstacleMask) && dstToTarget < viewRadiusThirdEye)
                    {
                        isInFOV = true;
                    }
                }
            }
            else if (hasPeripheralVision)
            {
                float dstToTarget = Vector2.Distance(transformPos, targetPos);
                // here we have to check the distance to the target since the peripheral vision may have a different radius than the normal field of view
                if (dstToTarget < viewRadiusPeripheralVision && !Physics.Raycast(transform.position, dirToTarget3, dstToTarget, obstacleMask))
                {
                    isInFOV = true;
                }
            }


            //apply effect to IHideable
            IHideable hideable = target.GetComponent <IHideable>();
            if (hideable != null)
            {
                if (isInFOV)
                {
                    if (!hideable.isInFov)
                    {
                        target.GetComponent <IHideable>().OnFOVEnter();
                    }
                }
                else
                {
                    if (hideable.isInFov)
                    {
                        target.GetComponent <IHideable>().OnFOVLeave();
                    }
                }
            }
        }

        Physics.autoSyncTransforms = true;
    }
Esempio n. 21
0
        public static void ToggleVisibility(this IHideable hideable)
        {
            Ensure.That(hideable, nameof(hideable)).IsNotNull();

            hideable.Visible = !hideable.Visible;
        }
Esempio n. 22
0
        public static void Hide(this IHideable hideable)
        {
            Ensure.That(hideable, nameof(hideable)).IsNotNull();

            hideable.Visible = false;
        }
Esempio n. 23
0
        public static void Show(this IHideable hideable)
        {
            Ensure.That(hideable, nameof(hideable)).IsNotNull();

            hideable.Visible = true;
        }
Esempio n. 24
0
 public HidebleViews(IHideable hide, IHideable show)
 {
     ToHide = hide;
     ToSHow = show;
 }