Exemplo n.º 1
0
    /*IEnumerator WaitForTenSeconds() {
     *      Debug.Log("In the CoRoutine");
     *      yield return new WaitForSeconds(10);
     *      Debug.Log("Ten Seconds Over");
     *      if ((mReconstructionBehaviour != null) && (mReconstructionBehaviour.Reconstruction != null))
     *      {
     *              Debug.Log("Stopping the reconstruction");
     *              mReconstructionBehaviour.Reconstruction.Stop();
     *      }
     * }*/

    void stopReconstruction()
    {
        if ((mReconstructionBehaviour != null) && (mReconstructionBehaviour.Reconstruction != null))
        {
            Debug.Log("Stopping the reconstruction");
            mReconstructionBehaviour.Reconstruction.Stop();
        }

        topPanel.SetActive(!topPanel.activeInHierarchy);
        //menuButton.SetActive (!menuButton.activeInHierarchy);

        Animator meshToClearAnimator = this.GetComponentInChildren <Animator> ();

        meshToClearAnimator.Play("FadeMeshToClear");

        greenKart.SetActive(true);
        //newCar.SetActive(true);

        CountDownScript countDown = GameObject.FindObjectOfType <CountDownScript> ();

        //countDown.timeLeft = 60.0f;
        countDown.timeLeft  = GameObject.FindObjectOfType <TimeBetweenScenes>().TimeForRound;
        countDown.runScript = true;

        CoinSpawningSystem css = GameObject.FindObjectOfType <CoinSpawningSystem> ();

        css.setCoinSpawnEnabled(true);

        //GameObject.Find ("GoButton").SetActive (false);

        goButton.SetActive(!goButton.activeInHierarchy);
        resetButton.SetActive(!resetButton.activeInHierarchy);

        bottomPanel.SetActive(true);
    }
Exemplo n.º 2
0
 //Methods
 private void Start()
 {
     randomText = gameObject.AddComponent <RandomText>();
     SetUpDefaultUpgrades();
     if (Application.isPlaying)
     {
         countDownScript = GameObject.Find("CountDownText").GetComponent <CountDownScript>();
     }
 }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     Time                = CountDownScript.getTotalTime();
     min                 = (int)Time / 60;
     sec                 = (int)Time % 60;
     milsec              = (int)((Time - (int)Time) * 100);
     this.TargetTxt      = this.GetComponent <Text>();
     this.TargetTxt.text = min.ToString() + "." + sec.ToString() + "." + milsec.ToString();
 }
Exemplo n.º 4
0
 private void ConfigureComponents()
 {
     boardManager     = this.gameObject.GetComponent <boardManager>();
     inputManager     = this.gameObject.AddComponent <inputManager>();
     animationManager = this.gameObject.AddComponent <animationManager>();
     animationManager.GemFallingSpeed = boardManager.board.gemFallingSpeed;
     inputManager.AnimationManager    = animationManager;
     countDownScript = GameObject.FindGameObjectWithTag("CountDownText").GetComponent <CountDownScript>();
 }
Exemplo n.º 5
0
 void SetCountText()
 {
     countText.text = "Count: " + count.ToString();
     if (count == 0)
     {
         ChangePlayer();
         countDownscript = gameObject.GetComponent<CountDownScript>();
         countDownscript.Awake();
     }
 }
Exemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     camScript       = mainCamera.GetComponent <CameraScript>();
     player1Script   = player1.GetComponent <Player1MovementScript>();
     player2Script   = player2.GetComponent <Player2MovementScript>();
     player1Renderer = player1.GetComponentInChildren <SpriteRenderer>();
     player2Renderer = player2.GetComponentInChildren <SpriteRenderer>();
     player1Anim     = player1.GetComponentInChildren <Animator>();
     player2Anim     = player2.GetComponentInChildren <Animator>();
     player1Color    = player1Renderer.color;
     player2Color    = player2Renderer.color;
     player1Life     = player1.GetComponent <LifeScript>();
     player2Life     = player2.GetComponent <LifeScript>();
     countScript     = countDown.GetComponent <CountDownScript>();
     countScript.startCountDown();
     audioSource = GetComponent <AudioSource>();
     audioSource.Play();
 }
Exemplo n.º 7
0
    // Handler for when the user clicks "Go!" to start the game. Ends construction of the ground mesh
    public void stopReconstruction()
    {
        if ((mReconstructionBehaviour != null) && (mReconstructionBehaviour.Reconstruction != null))
        {
            Debug.Log("Stopping the reconstruction");
            mReconstructionBehaviour.Reconstruction.Stop();
        }

        // Activate the top panel for in-game play
        topPanel.SetActive(!topPanel.activeInHierarchy);

        // Fades mesh to clear
        Animator meshToClearAnimator = this.GetComponentInChildren <Animator> ();

        meshToClearAnimator.Play("FadeMeshToClear");

        // Player appears on the screen
        greenKart.SetActive(true);

        // Sets the timer for the round
        CountDownScript countDown    = GameObject.FindObjectOfType <CountDownScript> ();
        float           timeForRound = 30f;

        if (GameObject.FindObjectOfType <TimeBetweenScenes> () != null)
        {
            timeForRound = GameObject.FindObjectOfType <TimeBetweenScenes> ().TimeForRound;
        }
        countDown.timeLeft  = timeForRound;
        countDown.runScript = true;

        // Starts spawning coins
        CoinSpawningSystem css = GameObject.FindObjectOfType <CoinSpawningSystem> ();

        css.setCoinSpawnEnabled(true);

        // Set necessary panels active or inactive
        goButton.SetActive(false);
        resetButton.SetActive(false);
        controls.SetActive(true);

        // Play the in game music
        GameObject.FindObjectOfType <SoundController>().playInGameMusic();
    }
Exemplo n.º 8
0
    void startMatch()
    {
        // Sets the timer for the round
        CountDownScript countDown    = GameObject.FindObjectOfType <CountDownScript> ();
        float           timeForRound = 30f;

        if (GameObject.FindObjectOfType <TimeBetweenScenes> () != null)
        {
            timeForRound = GameObject.FindObjectOfType <TimeBetweenScenes> ().TimeForRound;
        }
        countDown.timeLeft  = timeForRound;
        countDown.runScript = true;

        // Starts spawning coins
        CoinSpawningSystem css = GameObject.FindObjectOfType <CoinSpawningSystem> ();

        css.setCoinSpawnEnabled(true);

        // Play the in game music
        GameObject.FindObjectOfType <SoundController>().playInGameMusic();
    }
Exemplo n.º 9
0
    //update function
    void Update()
    {
        //for every game state
        switch (m_gameState)
        {
        //start state for the tutorial scene
        case GameState.start:
            DisplayTutorial();
            break;

        //transition between overworld and minigame
        case GameState.transition:

            //fade in animation
            if (FadeInAnimation.AnimationEnded())
            {
                //Display tutorial
                //  if (!bTutorialCanvasInstantiated)
                //  {
                //      InstantiateTutorialCanvasOnce();
                //      Destroy(m_tutorialCanvas);
                //  }

                if (!bMoleAnimationInstantiated)
                {
                    //Instantiate mole plane animation
                    MolePlaneAnim = Instantiate(Resources.Load("Minigames/PlantMinigame/Prefabs/MolePlane")) as GameObject;
                    MoleAnimation = MolePlaneAnim.GetComponent <StopAnimationScript>();
                    bMoleAnimationInstantiated = true;

                    //get all portrait script objects
                    m_portraits = GameObject.FindGameObjectsWithTag("Portrait");

                    //for every object found
                    for (int i = 0; i < m_portraits.Length; i++)
                    {
                        //get the portrait script inside it
                        m_portraitScripts.Add(m_portraits [i].GetComponent <PortaitScript> ());
                        //check if the player is the local player, if it is, contain it in localplayerportrait
                        if (m_portraitScripts [i].IsLocalPlayerPortrait())
                        {
                            LocalPlayerPortrait = m_portraitScripts [i];
                        }
                    }
                }


                if (MoleAnimation.AnimationEnded())
                {
                    //Instantiate countdown text for countdown phase
                    GameObject countDownObject = Instantiate(Resources.Load("Minigames/UniversalMinigamePrefabs/CountDownText")) as GameObject;
                    countDownObject.transform.SetParent(GameObject.Find("MinigameCanvas").transform);
                    countDownObject.transform.localPosition = new Vector3(0.0f, 0.0f, 1.0f);
                    countDownScript = GameObject.Find("CountDownText(Clone)").GetComponent <CountDownScript>();
                    m_gameState     = GameState.countdown;
                }
            }
            //Transition period between overworld and minigame before game countdown
            //Possible tutorial page
            //wait for everyone to be connected and synced
            break;

        //countdown before game begins
        case GameState.countdown:
            //if the countdown animation ended
            if (countDownScript.AnimationEnded())
            {
                //start game and switch gamestate
                Destroy(MolePlaneAnim);
                m_gameState = GameState.playing;
            }


            break;

        //playing the game
        case GameState.playing:

            //if the garden hasn't been generated yet
            if (!m_gridGenerated)
            {
                //generate it only once
                pGrid.CreateGrid(width, height);
                m_gridGenerated = true;
            }
            //if the game hasn't ended
            if (!GameEnded())
            {
                //update game logic
                CountDown();
                if (bSwipeLockout == false)
                {
                    SwipeLine();
                    OnTileClick();
                }
                else
                {
                    LockOutTimer();
                }
            }
            //if the game HAS ended
            else if (GameEnded())
            {
                // if stop animation hasn't been instantiated
                if (!StopAnimInstantiated)
                {
                    //instantiate only once
                    SpawnStopAnimation();
                    StopAnimInstantiated = true;
                    //if it has been instantiated
                }
                else if (StopAnimInstantiated)
                {
                    //check if it has finished animating, if it has
                    if (stopAnimationScript.AnimationEnded())
                    {
                        //Kill plants in the scene, end the minigame
                        if (pGrid.KillGame())
                        {
                            //if the fade out animation hasn't been instantiated
                            if (!bFadeOutAnimationInstantiated)
                            {
                                //instantiate it
                                GameObject FadeOutObj = Instantiate(Resources.Load("Minigames/UniversalMinigamePrefabs/FadeOut")) as GameObject;
                                FadeOutObj.transform.SetParent(GameObject.Find("MinigameCanvas").transform);
                                FadeOutObj.transform.localScale = new Vector3(100, 100, 100);
                                FadeOutAnimation = FadeOutObj.GetComponent <StopAnimationScript>();
                                bFadeOutAnimationInstantiated = true;
                            }
                            //if the fade out animation hasn't finished yet
                            if (FadeOutAnimation.AnimationEnded())
                            {
                                Debug.Log("Hello puny animals");
                                m_gameState = GameState.counting;
                            }
                        }
                    }
                }
            }
            break;

        //game is counting score and return to overworld
        case GameState.counting:
            ////if the game over canvas has not been instantiated yet
            if (GameOverCanvas == null)
            {
                //Instantiate the game over canvas
                GameOverCanvas = Instantiate(Resources.Load("Minigames/UniversalMinigamePrefabs/GameOverCanvas")) as GameObject;
            }

            //fade out
            //m_musicFadeOut.FadeOut();
            //INSERT CULL BACKGROUND MUSIC HERE


            //CustomLobby.local.EndMiniGame();

            break;
        }
    }