private IEnumerator StartCinematic()
    {
        cinematicManager.StartCinematic();

        Destroy(lancelot.GetComponent <Collider2D>());

        var tweenerLancelot = lancelot.transform.DOMove(arthur.transform.position, Constants.SpeedRun).SetSpeedBased();

        yield return(tweenerLancelot.WaitForCompletion());

        Finalize();

        cinematicManager.StopCinematic();
    }
    private IEnumerator FirstTimeCinematicCoroutine()
    {
        cinematicManager.StartCinematic();

        yield return(dialogController.Show("Мальчик", "Привет. Го тусить."));

        yield return(dialogController.Show("Девочка", "Не могу, но может сестра пойдет."));

        yield return(dialogController.Show("Мальчик", "У тебя есть сестра?"));

        girlGameObject.SetMovementDirection(new Vector2(0.0f, 1.0f), true);

        yield return(girlGameObject.transform.DOMove(waypoint1.transform.position, girlGameObject.speed).SetSpeedBased().WaitForCompletion());

        girlGameObject.SetMovementDirection(new Vector2(0.0f, 1.0f), false);

        yield return(new WaitForSeconds(1.0f));

        yield return(dialogController.Show("Девочка", "Да, но она злая."));

        // TODO: I'd like to create animator parameter to switch between walk / idle. Speed, maybe?
        //girlGameObject.SetMovementDirection(new Vector2(0.0f, -1.0f));
        //girlGameObject.SetMovementDirection(new Vector2(0.0f, 0.0f));

        girlGameObject.GetComponent <SpriteRenderer>().enabled = false;

        yield return(new WaitForSeconds(1.0f));

        girlGameObject.GetComponent <Animator>().runtimeAnimatorController = animatorControllerMarthaPink;

        girlGameObject.GetComponent <SpriteRenderer>().enabled = true;

        girlGameObject.SetMovementDirection(new Vector2(0.0f, -1.0f), true);

        yield return(girlGameObject.transform.DOMove(waypoint2.transform.position, girlGameObject.speed / 2.0f).SetSpeedBased().WaitForCompletion());

        girlGameObject.SetMovementDirection(new Vector2(-1.0f, 0.0f), false);

        yield return(new WaitForSeconds(1.0f));

        yield return(dialogController.Show("Мальчик", "Ты нацепила парик."));

        yield return(new WaitForSeconds(1.0f));

        yield return(dialogController.Show("Злая Сестра", "Да."));

        yield return(dialogController.Show("Злая Сестра", "Пошли."));

        cinematicManager.StopCinematic();
    }
Esempio n. 3
0
    private IEnumerator StartCinematic()
    {
        cinematicManager.StartCinematic();

        var arthurAnimator   = arthur.GetComponent <Animator>();
        var lancelotAnimator = lancelot.GetComponent <Animator>();

        arthurAnimator.SetBool(_aidIsMoving, true);
        lancelotAnimator.SetBool(_aidIsMoving, true);

        arthur.transform.position = arthurStart.transform.position;
        var tweenerArthur = arthur.transform.DOMove(arthurStop.transform.position, Constants.SpeedWalk).SetSpeedBased();

        lancelot.transform.position = lancelotStart.transform.position;
        var tweenerLancelot = lancelot.transform.DOMove(lancelotStop.transform.position, Constants.SpeedWalk).SetSpeedBased();

        yield return(tweenerArthur.WaitForCompletion());

        yield return(tweenerLancelot.WaitForCompletion());

        arthurAnimator.SetBool(_aidIsMoving, false);
        lancelotAnimator.SetBool(_aidIsMoving, false);

        yield return(dialogController.Show(DialogLineAvatar.Lancelot, "Lancelot", "Arthur?"));

        yield return(dialogController.Show(DialogLineAvatar.Arthur, "Arthur", "Do you feel it?"));

        yield return(dialogController.Show(DialogLineAvatar.Lancelot, "Lancelot", "What?"));

        yield return(dialogController.Show(DialogLineAvatar.Arthur, "Arthur", "Power of the sword. It's getting stronger."));

        yield return(dialogController.Show(DialogLineAvatar.Arthur, "Arthur", "Let's go."));

        lancelotAnimator.SetBool(_aidIsMoving, true);

        yield return(lancelot.transform.DOMove(arthur.transform.position, Constants.SpeedWalk).SetSpeedBased()
                     .WaitForCompletion());

        Finalize();

        cinematicManager.StopCinematic();
    }
Esempio n. 4
0
    private IEnumerator StartBattle()
    {
        cinematicManager.StartCinematic();
        
        // TODO: Refactor. Hack.
        yield return gameObject.transform.parent.transform.DOMove(target.transform.position, 0.2f).WaitForCompletion();

        GameObject explosion = Instantiate(Resources.Load<GameObject>("Explosion"));
        
        // TODO: Probably implement layer sorting instead of Y sorting.
        explosion.transform.position = new Vector3(target.transform.position.x, target.transform.position.y - 1.0f, target.transform.position.z);

        // TODO: Refactor. Read real duration from animator or listen for the completion;
        yield return new WaitForSeconds(1.0f);
        
        Destroy(explosion);
        
        SceneManager.LoadScene("Scenes/Battle");  
        
        cinematicManager.StopCinematic();
    }
Esempio n. 5
0
    private IEnumerator StartBattleCoroutine(GameObject gameObjectLancelot, List <Enemy> enemies, bool isStartedByMonster)
    {
        audioSourceMusic.Stop();

        if (isStartedByMonster)
        {
            audioSourceMusic.clip = audioClipBattle;
        }
        else
        {
            audioSourceMusic.clip = audioClipBossBattle;
        }

        audioSourceMusic.Play();

        _isBattleStartedWithLancelot = GameState.Instance.LancelotHealth > 0;
        _isBattleStartedWithApple    = GameState.Instance.HasApple;

        Reset();

        _isBattleInProgress = true;

        _enemies = enemies;

        cinematicManager.StartCinematic();

        yield return(SpawnAllies(gameObjectLancelot));

        cinematicManager.StopCinematic();

        while (_isBattleInProgress)
        {
            _activePlayerIndex++;
            if (_activePlayerIndex >= _players.Count)
            {
                _activePlayerIndex = 0;
            }
            _activePlayer = _players[_activePlayerIndex];

            if (_activePlayerIndex == 0)
            {
                PrepareButtonsForArthur();
            }
            else
            {
                PrepareButtonsForLancelot();
            }

            _isPlayerTurn = true;

            yield return(PlayerTurn());

            _isPlayerTurn = false;

            _selectedPlayerIndex = -1;
            _selectedPlayer      = null;

            if (_enemies.Count > 0)
            {
                _activeEnemyIndex++;
                if (_activeEnemyIndex >= _enemies.Count)
                {
                    _activeEnemyIndex = 0;
                }

                _activeEnemy = _enemies[_activeEnemyIndex];

                yield return(EnemyTurn(isStartedByMonster));

                if (GameState.Instance.ArthurHealth == 0)
                {
                    if (isStartedByMonster)
                    {
                        GameState.Instance.ending = Ending.A;
                    }
                    else if (_isBattleStartedWithApple && _isBattleStartedWithLancelot)
                    {
                        GameState.Instance.ending = Ending.B;
                    }
                    else if (!_isBattleStartedWithApple)
                    {
                        GameState.Instance.ending = Ending.F;
                    }
                    else if (!_isBattleStartedWithLancelot)
                    {
                        GameState.Instance.ending = Ending.D;
                    }

                    SceneManager.LoadScene("End");
                }
            }
            else
            {
                if (GameState.Instance.ArthurHasExcalibur && GameState.Instance.LancelotHealth > 0)
                {
                    GameState.Instance.KillLancelot();

                    _enemies.ForEach(x => Destroy(x.gameObject));
                    _enemies.Clear();

                    var lancelot = _players[1];
                    _players.RemoveAt(1);
                    var lancelotPosition = lancelot.transform.position;
                    Destroy(lancelot);

                    var lancelotEnemy = Instantiate(lancelotEnemyPrefab);
                    lancelotEnemy.transform.position = lancelotPosition;
                    _enemies.Add(lancelotEnemy.GetComponent <Enemy>());

                    _isLancelotKillingStarted = true;

                    yield return(dialogController.Show(DialogLineAvatar.Arthur, "Arthur", "It demands blood!"));

                    yield return(dialogController.Show(DialogLineAvatar.Lancelot, "Lancelot", "Arthur, stop!"));
                }
                else
                {
                    if (_isLancelotKillingStarted)
                    {
                        GameState.Instance.ending = Ending.E;
                        SceneManager.LoadScene("End");
                    }
                    else
                    {
                        yield return(FinishBattle());
                    }
                }
            }
        }
    }