コード例 #1
0
ファイル: ViewMiniGame.cs プロジェクト: galen-manuel/BearJam
    /* PRIVATE METHODS */
    private void SpawnNewMiniGame()
    {
        float delay = 0f;

        // Clear game data.
        _currentGame?.Cleanup();
        _currentGame = null;

        // Clear input panel first.
        for (int i = 0; i < _inputActionPanel.childCount; i++)
        {
            RectTransform rt = _inputActionPanel.GetChild(i) as RectTransform;
            rt.DOScale(Vector3.zero, 0.35f).SetEase(Ease.InBack).OnComplete(() => Destroy(rt.gameObject));
        }
        delay += (_inputActionPanel.childCount == 0) ? 0f : 0.4f;

        DOTween.Sequence().InsertCallback(delay, () => {
            _currentGameType = (Constants.GameType)Random.Range(0, (int)Constants.GameType.AllTypes);
            _currentGameType = Constants.GameType.Yoga;
            _currentGame     = _miniGameFactory.CreateMiniGame(Constants.GameType.Yoga);
            _updateMinigame  = true;

            _instructions.text = _currentGame.Instructions;

            ShowNextInput(_currentGame.GetType());
        });
    }
コード例 #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();
         }
     }
 }