//Keep track of the two latest tiles to calc direction private IQPathTile[] LastTwoTiles(IQPathTile t) { if (twins == null) { twins = new IQPathTile[2]; } if (t == null) { return(twins); } if (twins.Length == 0) { twins[0] = t; } if (twins.Length == 1) { twins[1] = t; } if (twins.Length == 2) { twins[0] = twins[1]; twins[1] = t; } if (twins.Length > 2) { Debug.LogError("twins.Length > 2"); } return(twins); }
public float AggregateTileCostToEnter(float costSoFar, IQPathTile sourcetile, IQPathUnit theUnit) { // TODO: We are ignoring source tile for now, will change soon // return ((Unit)theUnit).TotalTurnsToEnterHex(this, costSoFar); //return BaseMovementCost(); return(((Unit)theUnit).TotalTurnsToEnterHex((Hex)sourcetile, costSoFar)); //throw new System.NotImplementedException(); }
// cost in turns public float CostToEnterHex(IQPathTile sourceTile, IQPathTile destinationTile) { // return 1; // there doesn't appear to be anything that uses this return(MovementCostToEnterHex((Hex)destinationTile)); }
public static Cell GetCellData(Vector2Int position) { IQPathTile tile = null; for (int i = Layers.Count - 1; i >= 0; i--) { if (Layers[i].ContainsKey(position)) { tile = Layers[i][position]; break; } else { continue; } } return((Cell)tile); }
public static Cell[] GetMoveArea(Fighter f, int movement, bool weighted = true) { Dictionary <Cell, int> depths = GetTileDepths(f, movement + 1); Cell[] tiles = new Cell[depths.Count]; depths.Keys.CopyTo(tiles, 0); if (weighted) { IQPathTile startCell = UnitTile(f); List <Cell> range = new List <Cell> { (Cell)startCell }; foreach (Cell c in tiles) { Fighter unitInTile = c.unitInTile; IQPathTile[] path = QPath.FindPath(f, startCell, c, Cell.EstimateDistance); if (!c.impassible && AggregateCost(path, f.Unit) <= movement && c.MoveCost(f.Unit) >= 0 && (unitInTile == null || unitInTile.Unit.alignment == f.Unit.alignment)) { range.Add(c); c.Display_Debug(AggregateCost(path, f.Unit).ToString()); } } List <Cell> all = range; range = new List <Cell>(); foreach (Cell c in all) { if (c.unitInTile == null || c.unitInTile == f) { range.Add(c); } } return(range.ToArray()); } return(tiles); }
public static Cell[] GetNeighbors(Cell c) { Vector2Int cellPosition = c.position; List <Cell> cells = new List <Cell>(); IQPathTile[] tiles = new IQPathTile[4] { GetCellData(cellPosition + Vector2Int.up), GetCellData(cellPosition + Vector2Int.right), GetCellData(cellPosition + Vector2Int.down), GetCellData(cellPosition + Vector2Int.left) }; foreach (Cell t in tiles) { if (t != null) { cells.Add(t); } } return(cells.ToArray()); }
public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit) { //TODO: We are ignoring source tile atm, this will need to change with rivers return(((Unit)theUnit).AggregateTurnsToEnterHex(this, costSoFar)); }
public static float CostEstimate(IQPathTile aa, IQPathTile bb) { return(Distance((Tile)aa, (Tile)bb)); }
public float CostToEnterTile(IQPathTile sourceTile, IQPathTile destinationTile) { //Debug.Log("CostToEnterTile"); return(1f); }
//public static float Distance(Hex a, Hex b) //{ // return // Mathf.Max( // Mathf.Abs(a.Q - b.Q), // Mathf.Abs(a.R - b.R), // Mathf.Abs(a.S - b.S) // ); //} public static float CostEstimate(IQPathTile aa, IQPathTile bb) { // heuristic function for a-star. Maybe pad distance based on tile type // to smooth out pathfinding return(Distance((Hex)aa, (Hex)bb)); }
public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit) { // TODO: We are ignoring source tile right now, this will have to change when // we have rivers. return(((Unit)theUnit).AggregateTurnsToEnterHex(this, costSoFar)); }
public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit) { return(((Unit)theUnit).AggregateTurnsToEnterTile(this, costSoFar)); }
public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathTile[] twins, IQPathUnit theUnit) { return ((_Enemy)theUnit).TileToTileCost(this, twins); }
/// <summary> /// Turn cost to enter a hex (i.e. 0.5 turns if a movement cost is 1 and we have 2 max movement) /// </summary> public float CostToEnterHex(IQPathTile sourceTile, IQPathTile destinationTile) { return(1); }
//TEMP - TODO: FIX ME! (in Unit.cs too) public static float CostEstimate(IQPathTile aa, IQPathTile bb) { return(Distance((Hex)aa, (Hex)bb)); //assume these parameters are hexes }
public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit unit) { return(((Unit)(unit)).AggregateTurnsToEnterHex(this, costSoFar)); }
public static float CostEstimate(IQPathTile a, IQPathTile b) { return(Distance((Hex)a, (Hex)b)); }
public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit unit) { Fighter f = (Fighter)unit; return((f).AggregateTurnsToEnterTile(this, costSoFar) + MoveCost(f.Unit)); }
public static float EstimateDistance(IQPathTile a, IQPathTile b) { Cell s = (Cell)a, e = (Cell)b; return(Vector2.Distance(s.transform.position, e.transform.position)); }
public float CostToEnterHex(IQPathTile sourceTile, IQPathTile destinationTile) { return(1); // Turn cost to enter a hex (i.e. 0.5 turns if a movement cost is 1 and we have 2 max movement) }
public float AggregateCostToEnter(float costSoFar, IQPathTile sourceTile, IQPathUnit theUnit) { //throw new System.NotImplementedException(); //todo we are ignoring source tile right now, this will have to change when we have rivers return(((Unit)theUnit).AggregateTurnsToEnterHex(this, costSoFar)); }
public Offensive(Fighter attacker, Fighter defender, bool repeated = false) { Attacker = attacker; Defender = defender; Seed = StatsCalc.Seed(new Vector2Int[2] { attacker.Position(), defender.Position() }); Rand = new System.Random(Seed); IsPhysical = Attacker.Weapon.isPhysical; AtkStat = IsPhysical ? Attacker.Unit.stats.strength : Attacker.Unit.stats.magic; DefStat = IsPhysical ? Defender.Unit.stats.defense : Defender.Unit.stats.resistance; Cell = Map.UnitTile(Attacker); Support1 = StatsCalc.SupportBonus(Attacker); Support2 = StatsCalc.SupportBonus(Defender); TriangleBonus = StatsCalc.TriangleBonus(Attacker, Defender); TerrainBonus1 = StatsCalc.TerrainBonus(Map.UnitTile(Attacker)); TerrainBonus2 = StatsCalc.TerrainBonus(Map.UnitTile(Defender)); Speed1 = Attacker.Unit.stats.speed; Speed2 = Defender.Unit.stats.speed; Wgt1 = Attacker.Weapon.weight; Wgt2 = Defender.Weapon.weight; Con1 = Attacker.Unit.stats.constitution; Con2 = Defender.Unit.stats.constitution; Attack = AtkStat; Defense = DefStat; Spd1 = StatsCalc.AttackSpeed(Speed1, Wgt1, Con1); Spd2 = StatsCalc.AttackSpeed(Speed2, Wgt2, Con2); Atk = StatsCalc.PhysicalAttack(Attack, Attacker.Weapon.might, TriangleBonus, StatsCalc.WeaponEffectiveness(Attacker.Weapon, Defender), Support1, false); Def = StatsCalc.PhysicalDefense(TerrainBonus2, Defense, Support2); HitRate = StatsCalc.HitRate(Attacker.Weapon.hit, Attacker.Unit.stats.skill, Attacker.Unit.stats.luck, Support1); Avoid = StatsCalc.Avoid(Speed2, Defender.Unit.stats.luck, TerrainBonus2, Support2); Acc = StatsCalc.Accuracy(HitRate, Avoid, TriangleBonus); CritRate = StatsCalc.CriticalRate(Attacker.Weapon.crit, Attacker.Unit.stats.skill, Support1, StatsCalc.ClassCrit(Attacker.Unit.unitClass)); CritEvade = StatsCalc.CriticalEvade(Defender.Unit.stats.luck, Support2); CritChance = StatsCalc.CriticalChance(CritRate, CritEvade); if (StatsCalc.ClassCriticalModifier.ContainsKey(Attacker.Unit.unitClass)) { CritChance += StatsCalc.ClassCriticalModifier[Attacker.Unit.unitClass]; } if (repeated) { CritChance += Attacker.Unit.stats.pursuitCriticalCoefficient; } Hit = Rand.Next(0, 100) <= Acc; Crit = Rand.Next(0, 100) <= CritChance; Damage = Crit ? StatsCalc.CriticalDamage(StatsCalc.Damage(Atk, Def)) : StatsCalc.Damage(Atk, Def); if (Attacker.LastTarget == Defender) { Attacker.RepeatedTarget++; } else { Attacker.LastTarget = Defender; Attacker.RepeatedTarget = 0; } }
public float MovmementValue(IQPathTile SourceTile, IQPathTile destinationTile) { return(1); }