public void GenerateActions(TacticsMove attacker, TacticsMove defender) { // Add battle init boosts attacker.ActivateSkills(Activation.INITCOMBAT, defender); attacker.ActivateSkills(Activation.PRECOMBAT, defender); defender.ActivateSkills(Activation.PRECOMBAT, attacker); _currentCharacter = attacker; actions.Clear(); actions.Add(new BattleAction(true, true, attacker, defender)); int range = Mathf.Abs(attacker.posx - defender.posx) + Mathf.Abs(attacker.posy - defender.posy); if (defender.GetWeapon() != null && defender.GetWeapon().InRange(range)) { actions.Add(new BattleAction(false, true, defender, attacker)); } //Compare speeds int spdDiff = attacker.stats.spd - defender.stats.spd; if (spdDiff >= 5) { actions.Add(new BattleAction(true, true, attacker, defender)); } else if (spdDiff <= -5) { if (defender.GetWeapon() != null && defender.GetWeapon().InRange(range)) { actions.Add(new BattleAction(false, true, defender, attacker)); } } }
private void ShowHealForecast(TacticsMove lefter, TacticsMove righter, int heal) { StatsContainer stats = lefter.stats; int currentHp = lefter.currentHealth; fullBackground.SetActive(true); attackBackground.SetActive(false); playerNormalObject.SetActive(false); playerForecastObject.SetActive(true); characterName.text = stats.charName; portrait.enabled = true; portrait.sprite = stats.portrait; typeIcon.enabled = true; typeIcon.color = (lefter.GetWeapon() != null) ? lefter.GetWeapon().GetTypeColor() : Color.white; hpText.text = currentHp + " -> " + currentHp; damageTextObj.SetActive(false); advIcon.enabled = false; extraSkillName.text = (stats.GetSkill() != null) ? stats.GetSkill().skillName : ""; extraSkillValue.text = (stats.GetSkill() != null) ? Mathf.Max(0, stats.GetSkill().maxCharge - lefter.skillCharge).ToString() : ""; extraSkillObject.gameObject.SetActive(true); playerStatsObject.SetActive(true); stats = righter.stats; currentHp = righter.currentHealth; eCharacterName.text = stats.charName; ePortrait.enabled = true; ePortrait.sprite = stats.portrait; eTypeIcon.enabled = true; eTypeIcon.color = (righter.GetWeapon() != null) ? righter.GetWeapon().GetTypeColor() : Color.white; eHpText.text = currentHp + " -> " + Mathf.Min(currentHp + heal, stats.hp); eDamageTextObj.SetActive(false); eAdvIcon.enabled = false; targetStatsObject.SetActive(true); }
protected override void UseSkill(TacticsMove user, TacticsMove enemy) { if (enemy.GetWeapon() != null && enemy.GetWeapon().weaponType == weaponType) { user.ReceiveBuff(boost, true, false); } }
protected override void RemoveEffect(TacticsMove user, TacticsMove enemy) { if (enemy.GetWeapon() != null && enemy.GetWeapon().weaponType == weaponType) { user.ReceiveBuff(boost.InvertStats(), true, false); } }
protected override int EditValue(int value, TacticsMove user) { if (user.GetWeapon() != null && user.GetWeapon().weaponType == weaponType) { value = Mathf.FloorToInt(value * multiplier); } return(value); }
public int GetDamage() { int wpn = attacker.GetWeapon().power; int atk = attacker.stats.atk; int def = defender.stats.def; int adv = GetAdvantage(); float bonus = (adv == 1) ? 1.2f : (adv == -1) ? 0.8f : 1f; float weakness = GetWeaknessBonus(attacker.GetWeapon().advantageType, defender.stats.charClass.classType); int damage = Mathf.Max(0, Mathf.FloorToInt((wpn + atk) * weakness * bonus) - def); return(damage); }
private void CalculateShowForecast(TacticsMove attacker, TacticsMove defender) { bool isDamage = (currentMode.value == ActionMode.ATTACK); BattleAction act1 = new BattleAction(true, isDamage, attacker, defender); if (isDamage) { BattleAction act2 = new BattleAction(false, true, defender, attacker); int distance = MapCreator.DistanceTo(defender, walkTile.value); int atk = (attacker.GetWeapon().InRange(distance)) ? act1.GetDamage() : -1; int def = (defender.GetWeapon() != null && defender.GetWeapon().InRange(distance)) ? act2.GetDamage() : -1; int spd = attacker.stats.spd - defender.stats.spd; bool atkWeak = attacker.stats.IsWeakAgainst(defender.stats.GetWeapon()); bool defWeak = defender.stats.IsWeakAgainst(attacker.stats.GetWeapon()); ShowForecast(attacker, defender, atk, def, spd, act1.GetAdvantage(), atkWeak, defWeak); } else { ShowHealForecast(attacker, defender, act1.GetHeals()); } }
public bool CheckRange(TacticsMove player, bool isAttack) { if (isAttack) { WeaponSkill weapon = player.GetWeapon(); if (weapon == null) { return(false); } for (int i = 0; i < enemyList.values.Count; i++) { int distance = MapCreator.DistanceTo(player, enemyList.values[i]); if (weapon.InRange(distance)) { return(true); } } } else { SupportSkill support = player.GetSupport(); if (support == null) { return(false); } for (int i = 0; i < playerList.values.Count; i++) { if (!playerList.values[i].IsInjured()) { continue; } int distance = MapCreator.DistanceTo(player, playerList.values[i]); if (support.InRange(distance)) { return(true); } } } return(false); }
public int GetAdvantage() { return(attacker.GetWeapon().GetAdvantage(defender.GetWeapon())); }
private void ShowForecast(TacticsMove lefter, TacticsMove righter, int damage, int taken, int speed, int adv, bool atkWeak, bool defWeak) { StatsContainer stats = lefter.stats; int currentHp = lefter.currentHealth; int receive = (speed <= -5) ? taken * 2 : taken; fullBackground.SetActive(false); attackBackground.SetActive(true); playerNormalObject.SetActive(false); playerForecastObject.SetActive(true); characterName.text = stats.charName; portrait.enabled = true; portrait.sprite = stats.portrait; typeIcon.enabled = true; typeIcon.color = (lefter.GetWeapon() != null) ? lefter.GetWeapon().GetTypeColor() : Color.white; hpText.text = currentHp + " -> " + Mathf.Max(0, (currentHp - Mathf.Max(0, receive))); damageTextObj.SetActive(true); wpnText.text = (damage < 0) ? "-" : damage.ToString(); wpnText.color = (defWeak) ? Color.green : Color.white; if (speed >= 5) { wpnText.text += " x2"; } if (adv == 0) { advIcon.enabled = false; } else { advIcon.enabled = true; advIcon.sprite = (adv == 1) ? advIconGood : advIconBad; } extraSkillObject.SetActive(false); playerStatsObject.SetActive(true); stats = righter.stats; currentHp = righter.currentHealth; receive = (speed >= 5) ? damage * 2 : damage; eCharacterName.text = stats.charName; ePortrait.enabled = true; ePortrait.sprite = stats.portrait; eTypeIcon.enabled = true; eTypeIcon.color = (righter.GetWeapon() != null) ? righter.GetWeapon().GetTypeColor() : Color.white; eHpText.text = currentHp + " -> " + Mathf.Max(0, (currentHp - Mathf.Max(0, receive))); eDamageTextObj.SetActive(true); eWpnText.text = (taken < 0) ? "-" : taken.ToString(); eWpnText.color = (atkWeak) ? Color.green : Color.white; if (speed <= -5) { eWpnText.text += " x2"; } if (adv == 0) { eAdvIcon.enabled = false; } else { eAdvIcon.enabled = true; eAdvIcon.sprite = (adv == -1) ? advIconGood : advIconBad; } targetStatsObject.SetActive(true); }
public void FindNeighbours(Queue <MapTile> progress, int currentDistance, TacticsMove tactics, int moveSpeed, bool showAttack, bool isDanger) { MapTile tile = mapCreator.GetTile(posx - 1, posy); if (CheckTile(tile, currentDistance, moveSpeed, tactics.faction, tactics.stats.charClass.classType, tactics.GetWeapon(), tactics.GetSupport(), showAttack, isDanger)) { progress.Enqueue(tile); } tile = mapCreator.GetTile(posx + 1, posy); if (CheckTile(tile, currentDistance, moveSpeed, tactics.faction, tactics.stats.charClass.classType, tactics.GetWeapon(), tactics.GetSupport(), showAttack, isDanger)) { progress.Enqueue(tile); } tile = mapCreator.GetTile(posx, posy - 1); if (CheckTile(tile, currentDistance, moveSpeed, tactics.faction, tactics.stats.charClass.classType, tactics.GetWeapon(), tactics.GetSupport(), showAttack, isDanger)) { progress.Enqueue(tile); } tile = mapCreator.GetTile(posx, posy + 1); if (CheckTile(tile, currentDistance, moveSpeed, tactics.faction, tactics.stats.charClass.classType, tactics.GetWeapon(), tactics.GetSupport(), showAttack, isDanger)) { progress.Enqueue(tile); } }