public UnitAttack?Attack(Coord attackPos) { if (isAlive && Math.Pow((attackPos.x - pos.x), 2) + Math.Pow((attackPos.y - pos.y), 2) <= Math.Pow(atkRange, 2)) { //if (attackPos.x - pos.x + attackPos.y - pos.y <= atkRange) SingleLogBattle.log.LogNewLine(name + " deal "); return(new UnitAttack((short)SingleRandom.Rand(dmg.min * number, dmg.max * number), atk)); } return(null); }
public double GetLuckBonus(Hero hero) { sbyte luck = (sbyte)(this.luck + hero.luck); if (luck == 0) { return(1.0); } double chance = 0; if (luck > 0) { if (luck >= 3) { chance = 12.5; } else if (luck == 2) { chance = 8.3; } else if (luck == 1) { chance = 4.2; } if (chance <= SingleRandom.Rand(1, 10000) / 100.0) { SingleLogBattle.log.LogAddToLine(" (Luck)"); return(2.0); } } if (luck > 0) { if (luck <= -3) { chance = 25; } else if (luck == -2) { chance = 16.6; } else if (luck == -1) { chance = 8.3; } if (chance <= SingleRandom.Rand(1, 10000) / 100.0) { SingleLogBattle.log.LogAddToLine(" (Unluck)"); return(0.5); } } return(1.0); }