Beispiel #1
0
    protected override void OnFirstShow()
    {
        _disableOnHide = false;

        _menuInOutAnimation = gameObject.AddComponent <MenuAnimation>();
        _menuInOutAnimation.TransitionOutFinished += InOutAnimation_Finished;

        _menuTransitionAnimation = gameObject.AddComponent <MenuTransitionAnimation>();

        CyclicalList         = new CyclicalList <MenuBase>(_menus);
        CyclicalList.Wrapped = true;
        CyclicalList.Moved  += Menu_Moved;

        // Menu input.
        _menuInput = new MenuInput(this);
        _menuInput.InputEnabled = true;

        // Make sure all menus are hidden by default and set the current menu.
        for (int i = 0; i < _menus.Count; i++)
        {
            // Add a button for each menu.
            _menuButtons.AddButton(_menus[i], _menus[i].name);

            if (i == 0)
            {
                CurrentMenu = _menus[i];
            }

            _menus[i].gameObject.SetActive(false);
        }

        _menuButtons.ButtonPressed += MenuButton_OnPressed;
    }
Beispiel #2
0
    public void GoToMenu(MenuTypes pMenu, MenuAnimation pAnimation = null)
    {
        if (pAnimation == null)
        {
            pAnimation = _defaultAnimation;
        }

        MenuBehaviour targetMenu = null;

        switch (pMenu)
        {
        case MenuTypes.STARTINGMENU:
            targetMenu = _startingMenu;
            break;

        case MenuTypes.MAINMENU:
            targetMenu = _mainMenu;
            GameManager.Instance.PlayLocationAnimation();
            break;

        case MenuTypes.PRIESTDECISIONMENU:
            targetMenu = _priestDecisionMenu;
            break;

        case MenuTypes.FINALLETTERMENU:
            targetMenu = _finalLetterMenu;
            break;

        case MenuTypes.RESULTSCREEN:
            targetMenu = _resultScreen;
            break;
        }

        AnimateMenu(targetMenu, pAnimation);
    }
Beispiel #3
0
 private void SetEase(Tween tween, MenuAnimation pAnimation)
 {
     if (pAnimation.ease != Ease.Unset)
     {
         tween.SetEase(pAnimation.ease);
     }
     else
     {
         tween.SetEase(pAnimation.customCurve);
     }
 }
Beispiel #4
0
    public void Back()
    {
        // If only one item is in the stack, go back to the root
        if (_menuStack.Count == 0)
        {
            return;
        }

        MenuAnimation lastAnimation = _animationStack.Peek();
        MenuBehaviour lastMenu      = LastMenu;

        // Invert last animation direction, in case it has one
        MenuAnimation invertedAnimation = new MenuAnimation();

        switch (lastAnimation.direction)
        {
        case Direction.UP:
            invertedAnimation.direction = Direction.DOWN;
            break;

        case Direction.DOWN:
            invertedAnimation.direction = Direction.UP;
            break;

        case Direction.RIGHT:
            invertedAnimation.direction = Direction.LEFT;
            break;

        case Direction.LEFT:
            invertedAnimation.direction = Direction.RIGHT;
            break;

        default:
            break;
        }

        // Move back the last menu and its animation
        lastMenu.HideMenu(invertedAnimation);
        _menuStack.Pop();
        _animationStack.Pop();

        // Show the menu before that, in case it was slid back
        MenuBehaviour newMenu = LastMenu;

        newMenu.ShowMenu(invertedAnimation, lastMenu);

        if (newMenu == _startingMenu)
        {
            NewMenuRoot(newMenu);
        }
    }
Beispiel #5
0
    public void GoToMenu(MenuBehaviour pTargetMenu, MenuAnimation pAnimation = null)
    {
        if (pAnimation == null)
        {
            pAnimation = _defaultAnimation;
        }

        if (!pTargetMenu.gameObject.activeSelf)
        {
            pTargetMenu.gameObject.SetActive(true);
        }

        AnimateMenu(pTargetMenu, pAnimation);
    }
Beispiel #6
0
    private void OnTriggerExit(Collider collision)
    {
        Destroy(ship);

        Destroy(camera.GetComponent <CameraSmoothing>());
        MenuAnimation ma = camera.AddComponent <MenuAnimation>();

        ma.obstacleAmount = 10;
        ma.obstacle       = obstacle;
        triggered         = true;

        GameObject      obj = Instantiate(finishedLevelUI);
        FinishedLevelUI flu = obj.GetComponent <FinishedLevelUI>();

        flu.nextLevel = nextLevel;
    }
Beispiel #7
0
    private void AnimateMenu(MenuBehaviour pTargetMenu, MenuAnimation pAnimation = null)
    {
        switch (pAnimation.animation)
        {
        case AnimationOption.INSTANT:
            if (LastMenu != null)
            {
                LastMenu.gameObject.SetActive(false);
            }

            pTargetMenu.gameObject.SetActive(true);
            break;

        case AnimationOption.FADEIN:
            pTargetMenu.FadeMenu(pAnimation, pAnimation.stackOptions.HasFlag(StackOptions.OVERLAY) ? null : LastMenu, true);
            break;

        case AnimationOption.FADEOUT:
            pTargetMenu.FadeMenu(pAnimation, pAnimation.stackOptions.HasFlag(StackOptions.OVERLAY) ? null : LastMenu, false);
            break;

        case AnimationOption.ANIMATE:
            pTargetMenu.ShowMenu(pAnimation, LastMenu);
            break;

        case AnimationOption.DISMISS:
            pTargetMenu.HideMenu(pAnimation);
            break;
        }

        if (pAnimation.stackOptions.HasFlag(StackOptions.PUSHTOSTACK))
        {
            _menuStack.Push(pTargetMenu);
            _animationStack.Push(pAnimation);
        }

        if (pTargetMenu == _startingMenu || pAnimation.stackOptions.HasFlag(StackOptions.CLEARSTACK))
        {
            NewMenuRoot(pTargetMenu);
        }
    }
Beispiel #8
0
 private void btnMenu_Click_1(object sender, EventArgs e)
 {
     if (Panelmenu.Width == 50)
     {
         PanelNew.Width    = 1;
         Panelmenu.Visible = false;
         lblTitle.Visible  = true;
         Panelmenu.Width   = 218;
         // AddNewAnimation.ShowSync(Panelmenu);
         MenuAnimation.ShowSync(label);
     }
     else
     {
         PanelNew.Width   = 1;
         lblTitle.Visible = false;
         MenuAnimation.HideSync(label);
         Panelmenu.Visible = false;
         Panelmenu.Width   = 50;
         // AddNewAnimation.ShowSync(Panelmenu);
     }
 }
Beispiel #9
0
    public void ShowMenu(MenuAnimation pAnimation, MenuBehaviour pLastMenu)
    {
        // Enable GameObject
        gameObject.SetActive(true);

        // In case pLastMenu has an active tween, kill it. Elsewise place it out of frame.
        pLastMenu.activeTween.Kill();
        _canvasRect.localPosition = -GetAnimationVector(pAnimation.direction);

        // Kill any previous animations on object
        activeTween.Kill();
        activeTween = _canvasRect.DOLocalMove(Vector2.zero, pAnimation.easeDuration).OnComplete(() =>
        {
            if (pLastMenu != null && !pAnimation.stackOptions.HasFlag(StackOptions.OVERLAY))
            {
                pLastMenu.gameObject.SetActive(false);
            }
        });

        // Apply DOTween Ease or custom Curve
        SetEase(activeTween, pAnimation);
    }
    void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs args)
    {
        foreach (var trackedImage in args.added)
        {
            GetData(trackedImage.referenceImage.name);
        }

        foreach (var trackedImage in args.updated)
        {
            // if an image is being properly tracked
            if (trackedImage.trackingState == TrackingState.Tracking)
            {
                // set prefab corresponding to image as active
                spawnablePrefabs[trackedImage.referenceImage.name].SetActive(true);
                spawnablePrefabs[trackedImage.referenceImage.name].transform.position = trackedImage.transform.position;
                menuAnimation = GameObject.FindWithTag("TopBoxTag").GetComponent <MenuAnimation>();
                menuAnimation.StartAnimation();

                currImageText.text = "Tracking: " + trackedImage.referenceImage.name;

                //GetData(trackedImage.referenceImage.name);
            }
            else
            {
                spawnablePrefabs[trackedImage.referenceImage.name].SetActive(false);
                currImageText.text = "Tracking: none";

                //dealText.text = "";

                /*
                 * foreach (GameObject go in spawnablePrefabs.Values) {
                 *  // otherwise, set all prefabs as inactive
                 *
                 *  go.SetActive(false);
                 *  currImageText.text = "Tracking: none";
                 * }*/
            }
        }
    }
Beispiel #11
0
    public void FadeMenu(MenuAnimation pAnimation, MenuBehaviour pLastMenu, bool pFadeIn)
    {
        // In case pLastMenu has an active tween, kill it
        if (pLastMenu != null && pLastMenu.activeTween != null)
        {
            pLastMenu.activeTween.Kill();
        }

        // Kill any previous animations on object
        activeTween.Kill();

        // Enable GameObject
        gameObject.SetActive(true);

        // Check if alpha if 1, in case set it to 0;
        if (pFadeIn)
        {
            if (_canvasGroup.alpha > 0)
            {
                _canvasGroup.alpha = 0;
            }
        }

        activeTween = _canvasGroup.DOFade(pFadeIn ? 1 : 0, pAnimation.easeDuration).OnComplete(() =>
        {
            if (pLastMenu != null)
            {
                pLastMenu.gameObject.SetActive(false);
            }
            if (!pFadeIn)
            {
                gameObject.SetActive(false);
            }
        });

        // Apply DOTween Ease or custom Curve
        SetEase(activeTween, pAnimation);
    }
Beispiel #12
0
 protected virtual void Start()
 {
     animation = GetComponent <MenuAnimation>();
     gameObject.SetActive(false);
 }
Beispiel #13
0
 public Tween HideMenu(MenuAnimation pAnimation)
 {
     // Move outside of frame
     return(_canvasRect.DOLocalMove(GetAnimationVector(pAnimation.direction), pAnimation.easeDuration)
            .SetEase(pAnimation.ease).OnComplete(() => this.gameObject.SetActive(false)));
 }