/// <summary>
    /// When we want to begin the rounds of play we call this.
    /// </summary>
    /// <returns>An enumerator used to delay in Coroutines</returns>
    public IEnumerator StartRound()
    {
        if (!isDiffSetup) //difficulty was not setup so we need to make our own
        {                 //use default setup in editor
            Debug.Log("No difficulty recieved. Setting default.");
            isDiffSetup = true;
            setupDifficulty();
        }

        //get our local user id and store it
        //we do this here since we are assured the IDs have been set
        localUserId = CustomMessages.Instance.localUserID;
        //Debug.Log(CustomMessages.Instance.localUserID);

        string msg = SwitchPlayers();

        yield return(new WaitForSeconds(setupTime));

        tiScript.timeLeft = roundTime;


        tScript.ChangeText(msg);
        yield return(new WaitForSeconds(waitTime));

        if (currentPlayer == localUserId)
        {
            enableMaze();
        }
        else
        {
            disableMaze();
        }

        tiScript.isTimerStart = true;
    }
    //methods


    /// <summary>
    ///Use this for initialization
    /// </summary>
    void Start()
    {
        startMenu();
        //setupDifficulty(); //while testing


        // Setup a keyword recognizer to enable resetting the game.
        List <string> keywords = new List <string>();

        keywords.Add("Restart");
        //  keywords.Add("Easy Mode");
        //  keywords.Add("Medium Mode");
        //  keywords.Add("Hard Mode");
        keywordRecognizer = new KeywordRecognizer(keywords.ToArray());
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();

        //multiplayer
        //setup our message handlers
        //then setup methods to handle getting those messages
        CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.Difficulty] = this.setDifficulty;
        CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.GoalState]  = this.OnGoalStateRecieved;
        CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.ResetGame]  = this.OnReset;

        tScript  = GameObject.Find("UIManager").GetComponent <TextEdit>();
        tiScript = GetComponent <Timer>();


        tScript.ChangeText("Setting up Anchor");
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Update is called once per frame
    /// </summary>
    void Update()
    {
        if (isTimerStart)
        {
            //when the round starts allow the ball to move based on the maze we are playing
            switch (GameObject.Find("GameController").GetComponent <GameController>().difficulty)
            {
            default:
                bMaze1.enabled = false;
                break;

            case 2:
                bMaze2.enabled = false;
                break;

            case 3:
                bMaze2.enabled = false;
                break;
            }

            timeLeft -= Time.deltaTime;

            if (timeLeft > 0)
            {
                tScript.ChangeText("" + (int)timeLeft);
            }
            else
            {
                tScript.ChangeText("Round Over");
                isTimerStart = false;
                if (GameObject.Find("GameController").GetComponent <GameController>().NextRound())
                {
                    StartCoroutine(GameObject.Find("GameController").GetComponent <GameController>().StartRound());
                }
                else
                {
                    AppStateManager.Instance.CurrentAppState = AppStateManager.AppState.EndGame;
                }
            }
        }
    }