예제 #1
0
        public async Task ShowTurnCompare(CombatUtil.CombatAction playerAction,
                                          CombatUtil.CombatAction enemyAction,
                                          float duration = 1.5f)
        {
            _playerActionLabel.Text     = CombatUtil.GetActionName(playerAction);
            _playerActionLabel.Modulate = CombatUtil.GetActionColor(playerAction);
            _enemyActionLabel.Text      = CombatUtil.GetActionName(enemyAction);
            _enemyActionLabel.Modulate  = CombatUtil.GetActionColor(enemyAction);
            _lineLabel.Visible          = true;
            compareContainer.Visible    = true;

            if (duration > 0)
            {
                var color = _playerActionLabel.Modulate;
                color.a = 0;
                _playerActionLabel.Modulate = color;
                color   = _enemyActionLabel.Modulate;
                color.a = 0;
                _enemyActionLabel.Modulate = color;

                _tween.InterpolateProperty(_enemyActionLabel, "modulate:a", 0f, 1f,
                                           actionTweenDuration, Tween.TransitionType.Quad, Tween.EaseType.Out,
                                           actionTweenDelay);
                _tween.InterpolateProperty(_playerActionLabel, "modulate:a", 0f, 1f,
                                           actionTweenDuration, Tween.TransitionType.Quad, Tween.EaseType.Out,
                                           actionTweenDelay);
                _tween.Start();

                await ToSignal(_tween, "tween_all_completed");
                await ToSignal(GetTree().CreateTimer(duration), "timeout");

                _lineLabel.Visible       = false;
                compareContainer.Visible = false;
            }
        }
예제 #2
0
        public async Task AnimatePlayerHurt(int damage, bool enemyCountered = false)
        {
            if (enemyCountered)
            {
                await _attackEffect.Play(_effectAnimations.GetAnimation("counter"),
                                         CombatUtil.GetActionColor(CombatUtil.CombatAction.Heavy));
            }

            Shake(1, 20, 1);
            _playerHealthIcon.Blink(1, 6);
            await ToSignal(GetTree().CreateTimer(1.5f), "timeout");
        }
예제 #3
0
        public async Task AnimatePlayerAttack(PlayerCombat playerCombat,
                                              CombatUtil.CombatAction action)
        {
            if (action == CombatUtil.CombatAction.Counter)
            {
                await _attackEffect.Play(_effectAnimations.GetAnimation("counter"),
                                         CombatUtil.GetActionColor(CombatUtil.CombatAction.Heavy));
            }

            var damageType = playerCombat.GetDamageType(action);

            if (damageType == "none")
            {
                return;
            }
            var effectAnimation = _effectAnimations.GetAnimation(damageType);
            await _attackEffect.Play(effectAnimation,
                                     CombatUtil.GetActionColor(action));
        }
예제 #4
0
        public async void ShowWinResult(CombatUtil.CombatAction playerAction,
                                        CombatUtil.CombatAction enemyAction,
                                        float duration = 0)
        {
            if (playerAction == CombatUtil.CombatAction.Flee ||
                enemyAction == CombatUtil.CombatAction.Flee)
            {
                await ToSignal(GetTree(), "idle_frame");

                return;
            }

            var win = CombatUtil.ActionCompare(playerAction, enemyAction);

            switch (win)
            {
            case CombatUtil.TurnOutcome.Tie:
                SetWinLabel("TIE", playerAction);
                break;

            case CombatUtil.TurnOutcome.PlayerWin:
                SetWinLabel("Player Win", playerAction);
                break;

            case CombatUtil.TurnOutcome.EnemyWin:
                SetWinLabel("Enemy Win", enemyAction);
                break;

            default:
                SetWinLabel("Error", CombatUtil.CombatAction.Invalid);
                throw new ArgumentOutOfRangeException();
            }

            winContainer.Visible = true;
            if (duration > 0)
            {
                await ToSignal(GetTree().CreateTimer(duration), "timeout");

                winContainer.Visible = false;
            }
        }
예제 #5
0
 private void SetWinLabel(string actor, CombatUtil.CombatAction action)
 {
     _winActorLabel.Text      = actor;
     _winActionLabel.Text     = CombatUtil.GetActionName(action);
     _winActionLabel.Modulate = CombatUtil.GetActionColor(action);
 }
예제 #6
0
        private async Task <bool> TakeTurn()
        {
            var playerAction = await _playerCombat.GetAction();

            var enemyAction = await _enemyCombat.GetAction();

            _combatMenu.SetButtonsVisible(false);
            await _combatMenu.ShowTurnResult(playerAction, enemyAction);

            var timer = GetTree().CreateTimer(1.5f);

            if (playerAction == CombatUtil.CombatAction.Flee)
            {
                var flee = await PlayerFlee(enemyAction);

                if (flee)
                {
                    _combatMenu.combatLabel.Visible = true;
                    EndCombat(CombatUtil.CombatOutcome.CombatFlee);
                    return(false);
                }
            }
            else
            {
                var win = CombatUtil.ActionCompare(playerAction, enemyAction);
                switch (win)
                {
                case CombatUtil.TurnOutcome.Tie:
                    await Tie(playerAction);

                    break;

                case CombatUtil.TurnOutcome.PlayerWin:
                    await PlayerWin(playerAction);

                    break;

                case CombatUtil.TurnOutcome.EnemyWin:
                    await EnemyWin(enemyAction);

                    break;

                default:
                    await _combatMenu.ShowCombatLabel("ERROR: Invalid win check",
                                                      2);

                    throw new ArgumentOutOfRangeException();
                }
            }

            if (timer.TimeLeft > 0)
            {
                await ToSignal(timer, "timeout");
            }

            _combatMenu.HideTurnResult();
            if (CheckCombatEnd())
            {
                if (_playerInstance.Health <= 0)
                {
                    await _combatMenu.ShowCombatLabel("YOU DIED", 2);

                    await _combatMenu.ShowCombatLabel("GAME OVER", 2);

                    _combatMenu.combatLabel.Visible = true;
                    EndCombat(CombatUtil.CombatOutcome.CombatLose);
                }
                else if (_enemyInstance.Health <= 0)
                {
                    await _combatMenu.ShowCombatLabel("YOU WON", 2);

                    await _combatMenu.ShowCombatLabel("CONGRATULATION", 2);

                    _combatMenu.Visible = true;
                    EndCombat(CombatUtil.CombatOutcome.CombatWin);
                }

                return(false);
            }

            return(true);
        }