Exemple #1
0
    private bool CheckReq(TacticsMove user, TacticsMove enemy)
    {
        bool terrainOk = false;

        for (int i = 0; i < terrainReq.Count; i++)
        {
            if (user.currentTile.terrain == terrainReq[i])
            {
                terrainOk = true;
                break;
            }
        }

        int  dist    = BattleMap.DistanceTo(user, enemy);
        bool rangeOk = (range <= dist && dist <= rangeMax);

        bool retaliateOk = (enemyCanAttack == EnemyCanAttack.BOTH);

        if (enemyCanAttack != EnemyCanAttack.BOTH)
        {
            InventoryTuple tuple   = enemy.GetEquippedWeapon(ItemCategory.WEAPON);
            bool           inRange = (!string.IsNullOrEmpty(tuple.uuid) && tuple.InRange(range));
            retaliateOk = ((inRange && enemyCanAttack == EnemyCanAttack.ATTACK) ||
                           (!inRange && enemyCanAttack == EnemyCanAttack.NO_ATTACK));
        }

        return(retaliateOk && (terrainOk || rangeOk));
    }
    /// <summary>
    /// Shows a basic overview of the character with some stats and combat stats.
    /// </summary>
    /// <param name="tactics"></param>
    private void ShowBasicStats(TacticsMove tactics)
    {
        if (tactics == null)
        {
            return;
        }
        StatsContainer  stats  = tactics.stats;
        SkillsContainer skills = tactics.skills;

        menuView.SetActive(true);
        statsObject.SetActive(false);
        basicObject.SetActive(true);
        inventoryObject.SetActive(false);

        //		colorBackground.color = (tactics.faction == Faction.PLAYER) ?
        //			new Color(0.2f,0.2f,0.5f) : new Color(0.5f,0.2f,0.2f);

        characterName.text = stats.charData.entryName;
        portrait.enabled   = true;
        portrait.sprite    = stats.charData.portraitSet.small;
        levelClass.text    = string.Format("Level {0}  {1}", stats.level, stats.currentClass.entryName);
        healthBar.SetAmount(tactics.currentHealth, tactics.stats.hp);
        expBar.SetAmount(tactics.stats.currentExp, 100);
        expBar.gameObject.SetActive(tactics.faction == Faction.PLAYER);
        weakIcon1.sprite  = weaknessIcons.icons[(int)stats.currentClass.classType];
        weakIcon1.enabled = (weakIcon1.sprite != null);

        InventoryTuple weapon = tactics.GetEquippedWeapon(ItemCategory.WEAPON);

        wpnIcon.sprite  = weapon?.icon;
        wpnIcon.enabled = (weapon != null);
        wpnName.text    = (weapon != null) ? weapon.entryName : "---";

        for (int i = 0; i < skillImages.Length; i++)
        {
            if (i >= skills.skills.Length || skills.skills[i] == null)
            {
                skillImages[i].sprite = noSkillImage;
            }
            else
            {
                skillImages[i].sprite = skills.skills[i].icon;
            }
        }

        int pwer = BattleCalc.CalculateDamage(weapon, stats);

        pwrText.text = (pwer != -1) ? "Pwr:  " + pwer : "Pwr:  --";
        int hitrate = BattleCalc.GetHitRate(weapon, stats);

        hitText.text   = (hitrate != -1) ? "Hit:  " + hitrate : "Hit:  --";
        avoidText.text = "Avo:  " + (BattleCalc.GetAvoid(stats) + tactics.currentTile.terrain.avoid);
        for (int i = 0; i < fatigueLevels.Length; i++)
        {
            fatigueLevels[i].SetActive(i == tactics.stats.fatigueAmount);
        }

        //Terrain
        boostAvoid.enabled = (tactics.currentTile.terrain.avoid > 0);
    }
    public void GenerateDamageActions()
    {
        TacticsMove attacker = attackerTile.value.currentCharacter;
        TacticsMove defender = defenderTile.value.currentCharacter;

        dialogue = null;
        if (defender == null)
        {
            showBattleAnim    = false;
            _currentCharacter = attacker;
            actions.Clear();
            actions.Add(new BattleAction(AttackSide.LEFT, BattleAction.Type.DAMAGE, attacker, defenderTile.value.blockMove));
            Debug.Log("BLOCK FIGHT!!");
        }
        else
        {
            showBattleAnim = useBattleAnimations.value;
            // Add battle init boosts
            attacker.ActivateSkills(SkillActivation.INITCOMBAT, defender);
            attacker.ActivateSkills(SkillActivation.PRECOMBAT, defender);
            defender.ActivateSkills(SkillActivation.COUNTER, attacker);
            defender.ActivateSkills(SkillActivation.PRECOMBAT, attacker);

            _currentCharacter = attacker;
            InventoryTuple atkTup = attacker.GetEquippedWeapon(ItemCategory.WEAPON);
            InventoryTuple defTup = defender.GetEquippedWeapon(ItemCategory.WEAPON);
            actions.Clear();
            actions.Add(new BattleAction(AttackSide.LEFT, BattleAction.Type.DAMAGE, attacker, defender));
            int range = Mathf.Abs(attacker.posx - defender.posx) + Mathf.Abs(attacker.posy - defender.posy);
            if (!string.IsNullOrEmpty(defTup.uuid) && defTup.currentCharges > 0 && defender.GetEquippedWeapon(ItemCategory.WEAPON).InRange(range))
            {
                actions.Add(new BattleAction(AttackSide.RIGHT, BattleAction.Type.DAMAGE, defender, attacker));
            }
            //Compare speeds
            int spdDiff = actions[0].GetSpeedDifference();
            if (spdDiff >= doublingSpeed.value)
            {
                if (atkTup.currentCharges > 1)
                {
                    actions.Add(new BattleAction(AttackSide.LEFT, BattleAction.Type.DAMAGE, attacker, defender));
                }
            }
            else if (spdDiff <= -doublingSpeed.value)
            {
                if (!string.IsNullOrEmpty(defTup.uuid) && defTup.currentCharges > 0 && defender.GetEquippedWeapon(ItemCategory.WEAPON).InRange(range))
                {
                    actions.Add(new BattleAction(AttackSide.RIGHT, BattleAction.Type.DAMAGE, defender, attacker));
                }
            }

            TacticsMove quoter    = (attacker.faction == Faction.ENEMY) ? attacker : defender;
            CharEntry   triggerer = (attacker.faction == Faction.ENEMY) ? defender.stats.charData : attacker.stats.charData;
            FightQuote  bestFind  = null;
            for (int q = 0; q < quoter.fightQuotes.Count; q++)
            {
                if (quoter.fightQuotes[q].triggerer == null)
                {
                    if (bestFind == null)
                    {
                        bestFind = quoter.fightQuotes[q];
                    }
                }
                else if (quoter.fightQuotes[q].triggerer == triggerer)
                {
                    bestFind = quoter.fightQuotes[q];
                    break;
                }
            }
            if (bestFind != null && !bestFind.activated)
            {
                dialogue           = bestFind.quote;
                bestFind.activated = true;
            }
        }
    }