StartGame() public method

public StartGame ( float tF ) : void
tF float
return void
Example #1
0
    private void Update()
    {
        AudioSource audio = GetComponent <AudioSource> ();

        switch (state)
        {
        case State.WAITING:
            waitTime += Time.deltaTime;
            if (waitTime > timeToWait)
            {
                state = State.LOADING;
            }
            break;

        case State.LOADING:
            g = GetGame();
            g.StartGame(timeFactor);
            addAudio();
            state = State.RUNNING;
            break;

        case State.RUNNING:
            switch (g.GetState())
            {
            case MiniGame.State.RUNNING:
                break;

            case MiniGame.State.WON:
                score += g.Score;
                gamesCompleted++;
                CalculateTimeFactor();
                g.Destroy();
                g          = null;
                audio.clip = win;
                audio.Play();
                state    = State.WAITING;
                waitTime = 0;
                break;

            case MiniGame.State.LOST:
                life--;
                if (life == 0)
                {
                    GameOver();
                }
                g.Destroy();
                g          = null;
                audio.clip = lose;
                audio.Play();
                state    = State.WAITING;
                waitTime = 0;
                break;
            }
            break;
        }
    }
Example #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (_player == null)
     {
         _player       = collision.transform.GetComponent <Player>();
         _inputHandler = collision.transform.GetComponent <InputHandler>();
         _miniGame.OnMiniGameStarted += OnMiniGameStarted;
         if (_miniGame.GetType() == typeof(PongMiniGame))
         {
             _playerIndex = ((PongMiniGame)_miniGame).AddPlayer(_player, (name == "RPosition"));
             Debug.Log(name + " " + _playerIndex);
         }
         else
         {
             _miniGame.AddPlayer(_player);
         }
         if (_miniGame.PlayerNumSatisfied())
         {
             _miniGame.StartGame();
         }
     }
 }
Example #3
0
    private void Update()
    {
        AudioSource audio = GetComponent<AudioSource> ();

        switch (state)
        {
        case State.WAITING:
            waitTime += Time.deltaTime;
            if (waitTime > timeToWait)
                state = State.LOADING;
            break;

        case State.LOADING:
            g = GetGame();
            g.StartGame(timeFactor);
            addAudio();
            state = State.RUNNING;
            break;

        case State.RUNNING:
            switch (g.GetState())
            {
            case MiniGame.State.RUNNING:
                break;
            case MiniGame.State.WON:
                score += g.Score;
                gamesCompleted ++;
                CalculateTimeFactor();
                g.Destroy();
                g = null;
                audio.clip = win;
                audio.Play ();
                state = State.WAITING;
                waitTime = 0;
                break;
            case MiniGame.State.LOST:
                life --;
                if (life == 0)
                    GameOver();
                g.Destroy();
                g = null;
                audio.clip = lose;
                audio.Play ();
                state = State.WAITING;
                waitTime = 0;
                break;
            }
            break;
        }
    }