Exemple #1
0
    private void CalculateShowForecast(TacticsMove attacker, MapTile target)
    {
        if (target.currentCharacter == null)
        {
            // BLOCK FIGHT
            TacticsMove       defender   = target.blockMove;
            BattleAction.Type battleMode = (currentMode.value == ActionMode.ATTACK) ? BattleAction.Type.DAMAGE : BattleAction.Type.HEAL;
            BattleAction      act1       = new BattleAction(AttackSide.LEFT, battleMode, attacker, defender);
            _attackerTactics = attacker;
            _defenderTactics = defender;
            act1.weaponAtk   = attacker.inventory.GetTuple(battleWeaponIndex.value);

            if (battleMode == BattleAction.Type.DAMAGE)
            {
                int  distance = BattleMap.DistanceTo(attacker, target);
                int  atk      = (act1.weaponAtk.InRange(distance)) ? act1.GetDamage() : -1;
                int  ret      = -1;
                int  spd      = 0;
                int  hit      = (atk != -1) ? act1.GetHitRate() : -1;
                int  hit2     = -1;
                int  crit     = -1;
                int  crit2    = -1;
                bool atkWeak  = false;
                bool defWeak  = false;
                UpdateHealthUI();
                ShowAttackerStats(attacker, act1.weaponAtk, atk, spd, hit, crit, atkWeak);
                ShowDefenderStats(defender, new InventoryTuple(null), ret, spd, hit2, crit2, defWeak);
                if (!inBattle)
                {
                    backgroundFight.SetActive(true);
                    backgroundHeal.SetActive(false);
                }
            }
        }
        else
        {
            TacticsMove       defender   = target.currentCharacter;
            BattleAction.Type battlemode = (currentMode.value == ActionMode.ATTACK) ? BattleAction.Type.DAMAGE : BattleAction.Type.HEAL;
            BattleAction      act1       = new BattleAction(AttackSide.LEFT, battlemode, attacker, defender);
            _attackerTactics = attacker;
            _defenderTactics = defender;
            act1.weaponAtk   = attacker.inventory.GetTuple(battleWeaponIndex.value);

            if (inBattle)
            {
                if (battlemode == BattleAction.Type.DAMAGE)
                {
                    attackerView.SetActive(true);
                    defenderView.SetActive(true);
                    healerView.SetActive(false);
                }
                else
                {
                    attackerView.SetActive(false);
                    defenderView.SetActive(false);
                    healerView.SetActive(true);
                }
            }

            if (battlemode == BattleAction.Type.DAMAGE)
            {
                BattleAction act2 = new BattleAction(AttackSide.RIGHT, BattleAction.Type.DAMAGE, defender, attacker);
                act2.weaponDef = attacker.inventory.GetTuple(battleWeaponIndex.value);
                int  distance = BattleMap.DistanceTo(defender, walkTile.value);
                int  atk      = (act1.weaponAtk.InRange(distance)) ? act1.GetDamage() : -1;
                int  ret      = (act1.DefenderInRange(distance)) ? act2.GetDamage() : -1;
                int  spd      = act1.GetSpeedDifference();
                int  hit      = (atk != -1) ? act1.GetHitRate() : -1;
                int  hit2     = (ret != -1) ? act2.GetHitRate() : -1;
                int  crit     = (atk != -1) ? act1.GetCritRate() : -1;
                int  crit2    = (ret != -1) ? act2.GetCritRate() : -1;
                bool atkWeak  = act1.CheckWeaponWeakness();
                bool defWeak  = act2.CheckWeaponWeakness();
                UpdateHealthUI();
                ShowAttackerStats(attacker, act1.weaponAtk, atk, spd, hit, crit, atkWeak);
                ShowDefenderStats(defender, act2.weaponAtk, ret, spd, hit2, crit2, defWeak);
                if (!inBattle)
                {
                    backgroundFight.SetActive(true);
                    backgroundHeal.SetActive(false);
                }
            }
            else
            {
                ShowHealForecast(attacker, defender, act1.staffAtk);
                if (!inBattle)
                {
                    backgroundFight.SetActive(false);
                    backgroundHeal.SetActive(true);
                }
            }
        }
    }