Exemplo n.º 1
0
    //start function
    void Start()
    {
        SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(5));
        //FadeOutAnimation = GameObject.Find("FadeOut").GetComponent<StopAnimationScript>();
        FadeInAnimation = GameObject.Find("FadeIn").GetComponent <StopAnimationScript> ();
        fade.SetActive(false);



        newCanvas       = Instantiate(tutorialCanvas, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
        tutorialTimeTxt = GUIText.FindObjectOfType <Text>();

        //if the background music prefab isnt in the scene then it will not try and search for it
        if (GameObject.FindGameObjectWithTag("BGMusic") != null)
        {
            backgroundMusic = GameObject.FindGameObjectWithTag("BGMusic");
            m_musicFadeOut  = backgroundMusic.GetComponent <MusicFadeOut>();
        }
        //initialise timer
        m_gameTimer = (int)gameDuration;

        //floating text manager public static utility class initialisation
        FloatingTextManager.Initialise();

        //set up screen orientation and plant grid
        Screen.orientation = ScreenOrientation.Landscape;

        //get the component stuff from the portait prefabs
        //Player1Stats = Player1.GetComponent<PortaitScript> ();
        //Player2Stats = Player2.GetComponent<PortaitScript> ();
        //Player3Stats = Player3.GetComponent<PortaitScript> ();
        // Player4Stats = Player4.GetComponent<PortaitScript> ();
    }
Exemplo n.º 2
0
 public void SpawnStopAnimation()
 {
     //SET UP DIALOGUE BOX SPAWN POINT TO BE REALITVE TO PLAYERS PORTRAIT POSITION
     stopText = Instantiate(Resources.Load("Minigames/UniversalMinigamePrefabs/StopText")) as GameObject;
     stopText.transform.SetParent(GameObject.Find("MinigameCanvas").transform);
     stopText.transform.localPosition = new Vector3(0, 0, 1.0f);
     stopAnimationScript = stopText.GetComponent <StopAnimationScript> ();
 }
Exemplo n.º 3
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;
        }
    }