public int Test(PlayerView view, ref WorldBase world) { if (_unitIndex < 0) { return(-1); } var unit = world.unitSet.GetActiveUnit(_unitIndex, out var masterListIndex); for (int i = 0; i < world.unitSet.numberOfUnits; ++i) { if (world.unitSet.GetUnit(i).position == _newPosition) { _unitIndex = -1; return(-1); } } world = new WorldUnitSetChange( world, new UnitSetUnitChange( world.unitSet, masterListIndex, new UnitNewOrder( world.unitSet.GetUnit(masterListIndex), new UnitOrderMove(masterListIndex, unit.position, _newPosition) ) ) ); { // Debug.Log(unit.position.SquareTileDistance(_newPosition)); return(unit.position.SquareTileDistance(_newPosition)); } }
public int Test(PlayerView view, ref WorldBase world) { if (_unitIndex < 0) { return(-1); } UnitBase unit = world.unitSet.GetActiveUnit(_unitIndex, out int masterListIndex); var placeAtPosition = unit.position; for (int i = 0; i < world.citySet.numberOfCities; ++i) { if (Vector2Int.Distance(world.citySet.GetCity(i).position, placeAtPosition) <= 4.0F) { _unitIndex = -1; return(-1); } } world = new WorldUnitSetChange( world, new UnitSetUnitChange( world.unitSet, masterListIndex, new UnitNewOrder( unit, new UnitOrderBuildCity() ) ) ); world = new WorldCitySetChange( world, new CitySetNewCityChange( world.citySet, new City(placeAtPosition, 1) // new City(new Vector2Int(60, 30)) ) ); return(10); }