Пример #1
0
    private void CheckIfGameHasStarted()
    {
        bool touchedScreen     = (MobileInputs.Instance.IsTap);
        bool gameHasNotStarted = (!_hasGameStarted);

        if (touchedScreen && gameHasNotStarted)
        {
            Camera.main.fieldOfView = 122.2f;
            _hasGameStarted         = true;
            _playerController.StartRunning();
            _glacierSpawner.IsScrolling = true;
            _cameraController.IsMoving  = true;
            GameCanvas.SetTrigger("Show");
            MenuAnim.SetTrigger("Hide");
        }

        if (_hasGameStarted && !IsDead)
        {
            //Bump up the score
            _score += (Time.deltaTime * _modifierScore);
            if (_lastScore != (int)_score)
            {
                _lastScore     = (int)_score;
                ScoreText.text = _score.ToString("0");
            }
        }
    }
Пример #2
0
    private Color fadeCol = new Color(0, 0, 0, 0.5f);           // 50% transparent black to dim the screen

    public void Activate()
    {
        // animate all the elements into place
        MenuAnim.MoveTo(pausedText, new Vector3(0, 1, 0), 0.4f, 0.0f);
        MenuAnim.MoveTo(tapToResume, new Vector3(0, -1, 0), 0.4f, 0.0f);
        // dim the screen
        MenuAnim.FadeTo(screenFade, fadeCol, 0.3f, 0.0f);
        // pause the music
        SoundManager.PauseMusic(0.5f);
    }
Пример #3
0
 void OnStartPressed()
 {
     // animate out all the elements
     MenuAnim.MoveTo(title, new Vector3(12, 0.7f, 0), 0.5f, 0.0f);
     MenuAnim.MoveTo(playerImage, new Vector3(-12, -1, 0), 0.5f, 0.0f);
     MenuAnim.MoveTo(tapToStart, new Vector3(0, -10, 0), 0.3f, 0.0f);
     MenuAnim.FadeTo(screenFade, Color.clear, 0.3f, 0.2f);
     // start the actual game
     GameManager.Game.Restart();
 }
Пример #4
0
    public void Activate()
    {
        SoundManager.PlayMusic("Intro");

        // animate in all the elements, and dim the screen.
        MenuAnim.MoveTo(title, new Vector3(1, 0.7f, 0), 0.5f, 0.0f);
        MenuAnim.MoveTo(playerImage, new Vector3(-4, -1, 0), 0.5f, 0.0f);
        MenuAnim.MoveTo(tapToStart, new Vector3(0, -2.5f, 0), 0.3f, 0.5f);
        MenuAnim.FadeTo(screenFade, fadeCol, 0.3f, 0.2f);
    }
Пример #5
0
    public void ShowMenu(MenuAnim menu)
    {
        if (CurrentMenu != null)
        {
            CurrentMenu.IsOpen = false;
        }

        CurrentMenu        = menu;
        CurrentMenu.IsOpen = true;
    }
Пример #6
0
    /// <summary>
    /// Animate the color of an object, starting from its current color
    /// </summary>
    /// <param name="target">The object to animate</param>
    /// <param name="col">The desired final color for the object</param>
    /// <param name="time">he time in seconds to reach the final color</param>
    /// <param name="delay">The delay in seconds before the animation should start</param>
    public static void FadeTo(GameObject target, Color col, float time, float delay)
    {
        // create new colour animation and attach it to the given object
        MenuAnim anim = target.AddComponent <MenuAnim>();

        anim.type     = AnimType.Colour;
        anim.startCol = target.GetComponent <Renderer>().material.color;
        anim.endCol   = col;
        anim.time     = time;
        anim.delay    = delay;
    }
Пример #7
0
    private float prevFrameTime = 0.0f;                 // we calculate our own delta time between frames because the menus need
    // to animate whilst the game is paused (i.e. when Time.timeScale = 0)
    /// <summary>
    /// Animate the position of an object, starting from its current position
    /// </summary>
    /// <param name="target">The object to animate</param>
    /// <param name="pos">The desired ending position for the object</param>
    /// <param name="time">The time in seconds to reach the end position</param>
    /// <param name="delay">The delay in seconds before the animation should start</param>
    public static void MoveTo(GameObject target, Vector3 pos, float time, float delay)
    {
        // create new position animation and attach it to the given object
        MenuAnim anim = target.AddComponent <MenuAnim>();

        anim.type     = AnimType.Position;
        anim.startPos = target.transform.position;
        anim.endPos   = pos;
        anim.time     = time;
        anim.delay    = delay;
    }
Пример #8
0
 public void OnBackToMenu()
 {
     // animate the elements out
     MenuAnim.MoveTo(gameOverText, new Vector3(0, 5, 0), 0.4f, 0.1f);
     MenuAnim.MoveTo(score, new Vector3(0, -4, 0), 0.4f, 0.1f);
     MenuAnim.MoveTo(exitButton, new Vector3(-10, -1.5f, 0), 0.4f, 0.0f);
     MenuAnim.MoveTo(restartButton, new Vector3(10, -1.5f, 0), 0.4f, 0.0f);
     // fade to black (the title screen handles fading back in)
     MenuAnim.FadeTo(screenFade, Color.black, 0.3f, 0.1f);
     // show the title screen once the screen is black
     GameManager.Game.Invoke("ShowTitleScreen", 0.7f);
 }
Пример #9
0
 public void OnRestart()
 {
     // animate all the elements out again
     MenuAnim.MoveTo(gameOverText, new Vector3(0, 5, 0), 0.4f, 0.1f);
     MenuAnim.MoveTo(score, new Vector3(0, -4, 0), 0.4f, 0.1f);
     MenuAnim.MoveTo(exitButton, new Vector3(-10, -1.5f, 0), 0.4f, 0.0f);
     MenuAnim.MoveTo(restartButton, new Vector3(10, -1.5f, 0), 0.4f, 0.0f);
     // fade to black
     MenuAnim.FadeTo(screenFade, Color.black, 0.3f, 0.1f);
     // restart the game once the screen is black
     GameManager.Game.Invoke("Restart", 0.7f);
     // fade back in as the game starts
     MenuAnim.FadeTo(screenFade, Color.clear, 0.3f, 0.7f);
 }
Пример #10
0
 void OnResume()
 {
     if (GameManager.Game.IsPaused)
     {
         // animate everything offscreen again
         MenuAnim.MoveTo(pausedText, new Vector3(-12, 1, 0), 0.3f, 0.0f);
         MenuAnim.MoveTo(tapToResume, new Vector3(12, -1, 0), 0.3f, 0.0f);
         // undim the screen
         MenuAnim.FadeTo(screenFade, Color.clear, 0.3f, 0.1f);
         // start the music again
         SoundManager.UnpauseMusic();
         // resume the game
         GameManager.Game.IsPaused = false;
     }
 }
Пример #11
0
    private Color fadeCol = new Color(0, 0, 0, 0.5f);           // 50% transparent black to dim the screen

    public void Activate()
    {
        // fill in score text
        distanceText.text = GameManager.Game.LastScore.ToString() + "m";
        bestText.text     = GameManager.Game.BestScore.ToString() + "m";

        // animate all the elements onto the screen
        MenuAnim.FadeTo(screenFade, fadeCol, 0.3f, 0.0f);
        MenuAnim.MoveTo(gameOverText, new Vector3(0, 0.5f, 0), 0.4f, 0.0f);
        MenuAnim.MoveTo(score, new Vector3(0, 0, 0), 0.4f, 0.1f);
        MenuAnim.MoveTo(exitButton, new Vector3(-1.35f, -1.5f, 0), 0.4f, 0.3f);
        MenuAnim.MoveTo(restartButton, new Vector3(1.35f, -1.5f, 0), 0.4f, 0.3f);

        // fade out the music
        SoundManager.PauseMusic(0.5f);
    }
Пример #12
0
 private void Update()
 {
     if (MobileInputs.Instance.Tap && !isGameStarted)
     {
         isGameStarted = true;
         controller.StartRunning();
         FindObjectOfType <CameraController>().IsMoving  = true;
         FindObjectOfType <GlacierSpawner>().IsScrolling = true;
         //GameCanvas.SetTrigger("Show");
         MenuAnim.SetTrigger("Hide");
     }
     if (isGameStarted && !IsDead && !isPaused)
     {
         PauseShow();
         score += (Time.deltaTime * modifierScore);
         if (lastScore != (int )score)
         {
             lastScore      = (int)score;
             scoreText.text = "Score : " + score.ToString("0");
         }
     }
 }