public DirectionalMatrix <DistanceCalculation> GetCustomDistanceMatrixFromTank( int playerIndex, int tankNumber, int ticksWithoutFiring, Rectangle restrictedBoardArea) { Tank tank = Game.Current.Players[playerIndex].Tanks[tankNumber]; TurnCalculationCache turnCalcCache = Game.Current.Turns[GameState.Tick].CalculationCache; // Don't ride over your own base! Base @base = tank.Player.Base; TankLocation tankLoc = turnCalcCache.TankLocationMatrix[@base.Pos]; Rectangle[] tabooAreas = new Rectangle[] { tankLoc.TankBody }; DistanceCalculator distanceCalculator = new DistanceCalculator(); distanceCalculator.Walls = GameState.Walls; distanceCalculator.TankOuterEdgeMatrix = GameState.CalculationCache.TankOuterEdgeMatrix; distanceCalculator.CellMatrix = turnCalcCache.CellMatrix; distanceCalculator.TabooAreas = tabooAreas; distanceCalculator.TicksWithoutFiring = ticksWithoutFiring; distanceCalculator.RestrictedMovementArea = restrictedBoardArea; MobileState tankState = GameState.GetMobileState(tank.Index); DirectionalMatrix <DistanceCalculation> distanceMatrix = distanceCalculator.CalculateShortestDistancesFromTank(ref tankState); return(distanceMatrix); }
public DirectionalMatrix <DistanceCalculation> GetDistanceMatrixFromTankByTankIndex(int tankIndex) { if (distanceMatricesFromTankByTankIndex == null) { distanceMatricesFromTankByTankIndex = new DirectionalMatrix <DistanceCalculation> [Constants.TANK_COUNT]; } if (distanceMatricesFromTankByTankIndex[tankIndex] == null) { TurnCalculationCache turnCalcCache = TurnCalculationCache; // Don't ride over your own base! Tank tank = Game.Current.Elements[tankIndex] as Tank; Base @base = tank.Player.Base; TankLocation tankLoc = turnCalcCache.TankLocationMatrix[@base.Pos]; Rectangle[] tabooAreas = new Rectangle[] { tankLoc.TankBody }; DistanceCalculator distanceCalculator = new DistanceCalculator(); distanceCalculator.Walls = GameState.Walls; distanceCalculator.TankOuterEdgeMatrix = TankOuterEdgeMatrix; distanceCalculator.CellMatrix = turnCalcCache.CellMatrix; distanceCalculator.TabooAreas = tabooAreas; MobileState tankState = GameState.GetMobileState(tankIndex); distanceMatricesFromTankByTankIndex[tankIndex] = distanceCalculator.CalculateShortestDistancesFromTank(ref tankState); } return(distanceMatricesFromTankByTankIndex[tankIndex]); }
public DirectionalMatrix <DistanceCalculation> CalculateDistancesForTank(MobileState tankState) { DistanceCalculator distanceCalculator = new DistanceCalculator(); distanceCalculator.Walls = Board; distanceCalculator.TankOuterEdgeMatrix = TankEdgeMatrix; distanceCalculator.CellMatrix = CellMatrix; return(distanceCalculator.CalculateShortestDistancesFromTank(ref tankState)); }