Esempio n. 1
0
    private void FinishAction(TimedActionController.Performance defPerformance)
    {
        _performanceHasEnded = true;

        AbilityDetails details = Gm.combatManager.DequeueNextAbility();

        details.performance = ((NPCombatant)details.performer).DetermineNPCPerformance();
        details.targets[0].overheadHud.inputIndicator.Show(false);

        foreach (GridObject target in details.targets)
        {
            details.RegisterTargetPerformance(target, _defPerformance);
        }

        details.performer.PerformAbility(details);
        foreach (GridObject target in details.targets)
        {
            if (target is Combatant combatant)
            {
                if (combatant.state == Combatant.State.Blocking)
                {
                    combatant.state = Combatant.State.Idle;
                }
            }
        }
    }
Esempio n. 2
0
 public float DetermineFlatArmourPen(TimedActionController.Performance performance)
 {
     if (performance == TimedActionController.Performance.Perfect)
     {
         return(0.4f + weapon.lethality * 0.1f);
     }
     return(0);
 }
Esempio n. 3
0
    private void MarkPerformance(TimedActionController.Performance defPerformance)
    {
        if (Gm.combatManager.firstTimeDefending && Gm.combatManager.firstTimeAttacking && defPerformance == TimedActionController.Performance.Perfect)
        {
            FreezeTime(true);
        }

        _currentPerformanceThreshold = defPerformance;
    }
Esempio n. 4
0
    private void MarkPerformance(TimedActionController.Performance performance)
    {
        if (Gm.combatManager.firstTimeAttacking && performance == TimedActionController.Performance.Perfect)
        {
            FreezeTime     = true;
            Time.timeScale = 0;
        }

        _currentPerformanceThreshold = performance;
    }
Esempio n. 5
0
 private void WrongButtonPressed()
 {
     if (!_performanceHasEnded)
     {
         foreach (GridObject target in Gm.combatManager.CurrentAbilityDetails.targets)
         {
             if (target is Combatant combatant)
             {
                 combatant.overheadHud.inputIndicator.Fade(new Color(1, 0.5f, 0.5f, 0.5f));
             }
         }
         _defPerformance = TimedActionController.Performance.Meh;
     }
 }
Esempio n. 6
0
 private void CorrectButtonPressed()
 {
     FreezeTime(false);
     if (!_performanceHasEnded)
     {
         foreach (GridObject target in Gm.combatManager.CurrentAbilityDetails.targets)
         {
             if (target is Combatant combatant)
             {
                 combatant.state = Combatant.State.Blocking;
                 combatant.overheadHud.inputIndicator.Fade(new Color(0.5f, 1, 0.5f, 0.5f));
             }
         }
         _defPerformance = _currentPerformanceThreshold;
     }
 }
Esempio n. 7
0
    public override void OnEnter()
    {
        base.OnEnter();

        _performanceHasEnded = false;
        _defPerformance      = TimedActionController.Performance.Meh;

        EventManager <TimedActionController.Performance> .AddListener(EventType.OnDefencePerformanceMarked, MarkPerformance);

        EventManager <TimedActionController.Performance> .AddListener(EventType.OnEnemyAbilityEnd, FinishAction);

        Button[] inputButtons  = Gm.inputController.AbilityInputButtons();
        Button   correctButton = inputButtons[Random.Range(0, inputButtons.Length)];

        foreach (Button button in inputButtons)
        {
            Action downAction;
            if (button == correctButton)
            {
                downAction = CorrectButtonPressed;
            }
            else
            {
                downAction = WrongButtonPressed;
            }
            Gm.inputController.BindActionToKey(button, downAction, null);
        }
        Gm.combatManager.CurrentAbilityDetails.targets[0].overheadHud.inputIndicator.Show(true, Gm.inputController.GetKeyCode(correctButton));

        Gm.hudManager.inputInfoInterface.ShowCommands(new Dictionary <string, string>
        {
            { Gm.inputController.GetKeyCode(correctButton).ToString(), "Block / Dodge" }
        });

        // TODO: Below code causes an EventManager-related exception in the live build
        // if (Gm.combatManager.CurrentAbilityDetails.targets.Any(target => target is PCombatant))
        // {
        //     EventManager<AbilityDetails>.Invoke(EventType.OnEnemyAttackInitiated, Gm.combatManager.CurrentAbilityDetails);
        // }

        CurrentActor.PlayAbilityAnimation();
    }
Esempio n. 8
0
    public override void OnEnter()
    {
        base.OnEnter();

        _currentPerformanceThreshold = TimedActionController.Performance.Meh;
        _isButtonPressed             = false;
        _isButtonReleased            = false;
        _idleCounter           = 0;
        _endEarlyButtonPressed = false;
        _performanceHasEnded   = false;

        EventManager <TimedActionController.Performance> .AddListener(EventType.OnPerformanceMarked, MarkPerformance);

        EventManager <TimedActionController.Performance> .AddListener(EventType.OnAbilityEnd, FinishAction);

        Button[] inputButtons = InputController.AbilityInputButtons();
        _correctButton = inputButtons[Random.Range(0, inputButtons.Length)];
        foreach (Button button in inputButtons)
        {
            Action downAction;
            if (button == _correctButton)
            {
                downAction = CorrectButtonPressed;
            }
            else
            {
                downAction = WrongButtonPressed;
            }
            InputController.BindActionToKey(button, downAction, RegisterPerformance);
        }
        CurrentActor.overheadHud.inputIndicator.Show(true, InputController.GetKeyCode(_correctButton));
        InputController.BindActionToKey(Button.Back, null, EndPerformanceEarly);

        Gm.hudManager.inputInfoInterface.ShowCommands(new Dictionary <string, string>
        {
            { InputController.GetKeyCode(_correctButton).ToString(), "(Hold) Execute command" },
            { "E", "(Twice) End turn early" }
        });

        Gm.tileManager.RemoveFlags(Tile.Flag.HighlightedForMovement, Tile.Flag.HighlightedForAttack);
        HighlightTargetTiles();
    }
    public float GetPerformanceMultiplier(TimedActionController.Performance performance)
    {
        if (performance == TimedActionController.Performance.Meh)
        {
            return(mehMultiplier);
        }
        else if (performance == TimedActionController.Performance.Okay)
        {
            return(okayMultiplier);
        }
        else if (performance == TimedActionController.Performance.Good)
        {
            return(goodMultiplier);
        }
        else if (performance == TimedActionController.Performance.Perfect)
        {
            return(perfectMultiplier);
        }

        return(mehMultiplier);
    }
Esempio n. 10
0
    protected float GetRatio(TimedActionController.Performance performance)
    {
        if (performance == TimedActionController.Performance.Meh)
        {
            return(mehRatio);
        }
        if (performance == TimedActionController.Performance.Okay)
        {
            return(okayRatio);
        }
        if (performance == TimedActionController.Performance.Good)
        {
            return(goodRatio);
        }
        if (performance == TimedActionController.Performance.Perfect)
        {
            return(perfectRatio);
        }

        Debug.LogWarning("Performance [" + performance + "] not found");
        return(0);
    }
Esempio n. 11
0
    private void FinishAction(TimedActionController.Performance performance)
    {
        _performanceHasEnded = true;
        AbilityDetails details = Gm.combatManager.DequeueNextAbility();

        if (details.targets.Count > 0)
        {
            foreach (GridObject gridObject in details.targets)
            {
                if (gridObject is NPCombatant npc)
                {
                    float rand = Random.Range(0.0f, 1.0f);
                    npc.state = rand <= Mathf.Clamp(npc.chanceToBlock + _idleCounter * 0.6f, 0, 1) ? Combatant.State.Blocking : Combatant.State.Idle;

                    details.RegisterTargetPerformance(npc,
                                                      npc.state == Combatant.State.Blocking
                            ? npc.DetermineBlockPerformance()
                            : TimedActionController.Performance.Meh);
                }
            }
        }

        details.performer.PerformAbility(details);
    }
Esempio n. 12
0
 public void RegisterTargetPerformance(GridObject def, TimedActionController.Performance targetPerformance)
 {
     _targetPerformances[def] = targetPerformance;
 }