예제 #1
0
 private void Start()
 {
     manager    = GameObject.FindWithTag("TileManager").GetComponent <ConveyorManager>();
     sr         = GetComponent <SpriteRenderer>();
     mb         = GameObject.FindObjectOfType <MenuBehaviour>();
     startColor = sr.color;
 }
예제 #2
0
    private void NewMenuRoot(MenuBehaviour pTargetRoot)
    {
        _rootMenu = pTargetRoot;

        _menuStack.Clear();
        _animationStack.Clear();
    }
예제 #3
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);
    }
예제 #4
0
    protected bool isExternal; //is it called from outside of the MenuBehaviour

    public MenuBehaviourCommand(MenuBehaviour menuBehaviour, Type type, bool isExternal = false)
    {
        this.menuBehaviour = menuBehaviour;
        this.type          = type;
        this.isExternal    = isExternal;

        //Debug.Log("Creating command " + type.ToString());
    }
    void CardComparison(List <int> cardsToCheck)
    {
        Card.FROZEN = true; //Tell cards to stop responding

        int state = 0;

        if (cards[cardsToCheck[0]].GetComponent <Card>().cardValue == cards[cardsToCheck[1]].GetComponent <Card>().cardValue) //If the cards are a match

        {
            state = 2;
            _pairs--;   //Subtract the number of pairs left
            matchText.text = "Number of Matches: " + _pairs;

            if (_pairs == 0)  //Win (no pairs left)
            {
                winSource.PlayOneShot(winSound);
                if (Users.CurrentUser == null)
                {
                    MenuBehaviour.logs.Add(new GameLog("admin", System.DateTime.Now.ToString(), _score.ToString(), "n/a"));
                }
                else
                {
                    MenuBehaviour.logs.Add(new GameLog(Users.CurrentUser.username, System.DateTime.Now.ToString(), _score.ToString(), "n/a"));
                }
                Debug.Log("Added to logs");
                MenuBehaviour.SaveGameData();
                StartCoroutine(GameOverPause(4));
            }
            else   //If not a win
            {
                matchSource.PlayOneShot(matchSound);
            }
            StartCoroutine(MatchPause(2, cards[cardsToCheck[0]], cards[cardsToCheck[1]]));  //Delay for 2 seconds, then delete the matched cards
        }
        else
        {
            //Mismatch
            _score        -= 40;
            scoreText.text = "Score: " + _score;
            if (_score <= 0)    //LOSE
            {
                timeText.text = "Ellapsed Time: " + (Time.time - fire_start_time);
                FreezeAllCards();
                gameOverText.text = "GAME OVER";
                loseSource.PlayOneShot(loseSound);
                StartCoroutine(GameOverPause(4));
            }
            else   //Mismatch but not lose
            {
                mismatchSource.PlayOneShot(mismatchSound);
            }
        }
        for (int i = 0; i < cardsToCheck.Count; i++)    //Update the states of the cards (if they're being checked or not)
        {
            cards[cardsToCheck[i]].GetComponent <Card>().state = state;
            cards[cardsToCheck[i]].GetComponent <Card>().falseCheck();
        }
    }
예제 #6
0
    void _DrawArray(SerializedProperty pArray)
    {
        GUILayout.Label("Menu interactions", EditorStyles.boldLabel); //3
        for (int i = 0; i < pArray.arraySize; i++)
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            SerializedProperty animation = pArray.GetArrayElementAtIndex(i);

            UnityEngine.Object canvasGroup     = animation.FindPropertyRelative("menu").objectReferenceValue;
            AnimationOption    animationOption = (AnimationOption)animation.FindPropertyRelative("animation").enumValueIndex;
            SerializedProperty swipeDetection  = animation.FindPropertyRelative("swipeDetection");
            Ease ease = (Ease)animation.FindPropertyRelative("ease").enumValueIndex;
            GUILayout.Label("Destination settings", EditorStyles.miniBoldLabel);
            EditorGUILayout.PropertyField(animation.FindPropertyRelative("menu"));

            if (canvasGroup == null)
            {
                if (GUILayout.Button("Remove menu interaction", EditorStyles.toolbarButton))
                {
                    MenuBehaviour menu = (MenuBehaviour)target;
                    menu.animations.RemoveAt(i);
                }
                EditorGUILayout.EndVertical();
                continue;
            }

            EditorGUILayout.PropertyField(animation.FindPropertyRelative("stackOptions"));

            GUILayout.Label("Animation settings", EditorStyles.miniBoldLabel);
            EditorGUILayout.PropertyField(animation.FindPropertyRelative("animation"));
            if (animationOption != AnimationOption.INSTANT)
            {
                EditorGUILayout.PropertyField(animation.FindPropertyRelative("ease"));
                EditorGUILayout.PropertyField(animation.FindPropertyRelative("customCurve"));
                EditorGUILayout.PropertyField(animation.FindPropertyRelative("easeDuration"));
                if (animationOption != AnimationOption.FADEIN)
                {
                    EditorGUILayout.PropertyField(animation.FindPropertyRelative("direction"));
                }
            }

            GUILayout.Label("Animation triggers", EditorStyles.miniBoldLabel);
            EditorGUILayout.PropertyField(animation.FindPropertyRelative("triggerButton"));
            EditorGUILayout.PropertyField(animation.FindPropertyRelative("swipeDetection"));


            GUILayout.Space(5f);
            if (GUILayout.Button("Remove menu interaction", EditorStyles.toolbarButton))
            {
                MenuBehaviour menu = (MenuBehaviour)target;
                menu.animations.RemoveAt(i);
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(25f);
        }
    }
예제 #7
0
 /// <summary>
 /// Gets reference to MenuBehaviour
 /// </summary>
 private void GetMenuBehaviour()
 {
     if (!menuBehaviour)
     {
         menuBehaviour = MenuBehaviour.menuBehaviour;
     }
     else
     {
         Debug.LogError("Can't find MenuBehaviour");
     }
 }
예제 #8
0
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable <MenuBehaviour> .Create(graph, template);

        MenuBehaviour clone = playable.GetBehaviour();

        clone.mainTrans   = mainTrans.Resolve(graph.GetResolver());
        clone.playTrans   = playTrans.Resolve(graph.GetResolver());
        clone.optionTrans = optionTrans.Resolve(graph.GetResolver());
        return(playable);
    }
예제 #9
0
파일: GC.cs 프로젝트: meatz89/CyberWarfare
    // Use this for initialization
    void Start()
    {
        ScriptPlayer = Player.GetComponent<PlayerBehaviour>();

        var menu = GameObject.Find("Menu");
        MenuScript = menu.GetComponent<MenuBehaviour>();

        StartStage1();

        Instance = this;

    }
예제 #10
0
 /// <summary>
 /// Holds the object in every scene.
 /// </summary>
 private void HoldInEveryScene()
 {
     if (menuBehaviour == null)
     {
         DontDestroyOnLoad(gameObject);
         menuBehaviour = this;
     }
     else if (menuBehaviour != this)
     {
         Destroy(gameObject);
         DestroyStartMenu();
     }
 }
예제 #11
0
    // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        int inputCount = playable.GetInputCount();

        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            ScriptPlayable <MenuBehaviour> inputPlayable = (ScriptPlayable <MenuBehaviour>)playable.GetInput(i);
            MenuBehaviour input = inputPlayable.GetBehaviour();

            // Use the above variables to process each frame of this playable.
        }
    }
예제 #12
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);
        }
    }
예제 #13
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);
    }
예제 #14
0
	void Start()
	{
		//debug
	//	Network.InitializeServer(200,8081,true);
		cubesList = new GameObject[cubeNumber];
		for(int i= 0; i<cubeNumber; ++i)
		{
			cubesList[i] = GameObject.Find("Cube_"+i);
		}
		stuartObj = GameObject.Find("Stuart");
		targetObj = GameObject.Find ("Target");

		soundManager = new SoundManager();

		if(!Network.isServer) menuGui = GameObject.Find("UICamera").GetComponent<MenuBehaviour>();
	}
예제 #15
0
    void Start()
    {
        //debug
        //	Network.InitializeServer(200,8081,true);
        cubesList = new GameObject[cubeNumber];
        for (int i = 0; i < cubeNumber; ++i)
        {
            cubesList[i] = GameObject.Find("Cube_" + i);
        }
        stuartObj = GameObject.Find("Stuart");
        targetObj = GameObject.Find("Target");

        soundManager = new SoundManager();

        if (!Network.isServer)
        {
            menuGui = GameObject.Find("UICamera").GetComponent <MenuBehaviour>();
        }
    }
예제 #16
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();


        //EditorGUILayout.PropertyField(serializedObject.FindProperty("_animations"), true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("_canvasScaler"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("_canvasGroup"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("_canvasRect"));
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
        _DrawArray(serializedObject.FindProperty("animations"));
        if (GUILayout.Button("Add menu interaction"))
        {
            MenuBehaviour menu = (MenuBehaviour)target;
            menu.animations.Add(new MenuAnimation());
        }
        EditorGUILayout.EndVertical();
        serializedObject.ApplyModifiedProperties();
    }
예제 #17
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);
        }
    }
예제 #18
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);
    }
예제 #19
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Finish")
        {
            DataCollector inst = DataCollector.getInstance();
            inst.endLevel(false);

            if (SceneManager.GetActiveScene().name == "Level10")
            {
                SceneManager.LoadScene("PostGameScene");
                return;
            }
            MenuBehaviour menuScript = GameObject.FindWithTag("UIBehaviour").GetComponent <MenuBehaviour>();
            menuScript.SaveProgress();
            SceneManager.LoadScene("WinState");
        }

        if (col.tag == "FallingTrigger")
        {
            col.GetComponentInParent <Rigidbody2D>().isKinematic = false;
        }
    }
예제 #20
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);
    }
예제 #21
0
    public void ShowPopup(string pPopupHeader, string pPopupBody, string pButtonText, Action pAction)
    {
        // Instantiate menu if _popupObject is non existent in scene
        if (_popupScript == null || _popupMenu == null)
        {
            // Instantiate the GameObject
            _popupMenu = Instantiate(_popupPrefab).GetComponent <MenuBehaviour>();
            // Get popup script
            _popupScript = _popupMenu.GetComponentInChildren <Popup>();
        }


        // Show the popup menu
        _popupMenu.FadeMenu(_popupAnimation, null, true);
        _InsidePopup = true;

        // Set text to popup
        _popupScript.buttonText.text  = pButtonText;
        _popupScript.popupHeader.text = pPopupHeader;
        _popupScript.popupBody.text   = pPopupBody;

        // Clear all previously used actions
        _popupScript.button.onClick.RemoveAllListeners();

        // Add action to button onClick, also add the hiding of the menu
        _popupScript.button.onClick.AddListener(() =>
        {
            // Fade out Menu
            _popupMenu.FadeMenu(_popupAnimation, null, false);
            _InsidePopup = false;
        });
        if (pAction != null)
        {
            _popupScript.button.onClick.AddListener(() => pAction());
        }
    }
예제 #22
0
 public void SetMenuBehaviour(MenuBehaviour menuBehaviour)
 {
     _menuBehaviour = menuBehaviour;
 }
예제 #23
0
 void Start()
 {
     menu_properties = menu.GetComponent <MenuBehaviour>();
     menu.SetActive(false);
 }
 void Start()
 {
     menuScript = GameObject.FindObjectOfType <MenuBehaviour>();
 }