/// <summary> /// Forces the system to valuate the object type and adds it to the Bases /// </summary> /// <param name="basis">the item to value</param> /// <returns>the new value</returns> public decimal MakeValuation(IInanimateTemplate basis) { IEconomicBasis basi = Bases.FirstOrDefault(bas => bas.ItemType == basis); if (basi != null) { return(basi.Basis * basi.Adjustment); } int newBaseValue = basis.Name.Length; if (basis.Qualities.Any()) { newBaseValue += Math.Max(1, basis.Qualities.Sum(quality => quality.Value)); } EconomicBasis newBasis = new EconomicBasis() { Adjustment = 1, Basis = newBaseValue, ItemType = basis, Trend = 1 }; Bases.Add(newBasis); return(newBasis.Basis * newBasis.Adjustment); }
public static void Initialize() { Bases.Add("Tree", new ResourceNodeBase("Tree", new Point(32), Art.Textures["Tree"], ResourceNodeType.Tree)); Bases.Add("Iron Rock", new ResourceNodeBase("Iron Rock", new Point(32), Art.Textures["Iron Rock"], ResourceNodeType.IronRock)); Bases.Add("Sticks", new ResourceNodeBase("Sticks", new Point(32), Art.Textures["Sticks"], ResourceNodeType.Sticks)); Bases.Add("Coal Rock", new ResourceNodeBase("Coal Rock", new Point(32), Art.Textures["Coal Rock"], ResourceNodeType.CoalRock)); Bases.Add("Farm", new ResourceNodeBase("Farm", new Point(64), Art.Textures["Farm"], ResourceNodeType.Farm)); }
public static void Initialize() { Bases.Add("Stockpile", new BuildingBase(BuildingType.Stockpile, "Stockpile", new Point(64), Art.Textures["Stockpile"], -1)); Bases.Add("Forge", new BuildingBase(BuildingType.Forge, "Forge", new Point(64), Art.Textures["Forge"], 25)); Bases.Add("Smelter", new BuildingBase(BuildingType.Smelter, "Smelter", new Point(64), Art.Textures["Smelter"], 25)); Bases.Add("Windmill", new BuildingBase(BuildingType.Windmill, "Windmill", new Point(64), Art.Textures["Windmill"], 25)); Bases.Add("Bakery", new BuildingBase(BuildingType.Bakery, "Bakery", new Point(64), Art.Textures["Bakery"], 25)); }
/// <summary> /// Finds bases. /// </summary> public void FindBases() { var resources = Game.Minerals.Where(x => x.Resources > 8).Concat(Game.Geysers).ToList(); foreach (var sl in Game.StartLocations) { Bases.Add(FindBase(resources, sl, true)); } while (resources.Any()) { var b = FindBase(resources, resources.First().TilePosition, false); if (b != null) { Bases.Add(b); } else { Game.SendText($"Base center not found for {resources.First().TilePosition}."); } } }
public void OnStart(Tyr tyr) { int[,] distances = tyr.MapAnalyzer.Distances(SC2Util.To2D(tyr.MapAnalyzer.StartLocation)); BaseLocation natural = null; int dist = 1000000000; foreach (BaseLocation loc in tyr.MapAnalyzer.BaseLocations) { int distanceToMain = distances[(int)loc.Pos.X, (int)loc.Pos.Y]; Base newBase = new Base() { BaseLocation = loc, DistanceToMain = distanceToMain }; Bases.Add(newBase); if (distanceToMain <= 5) { Main = newBase; } else if (tyr.MapAnalyzer.MainAndPocketArea[loc.Pos]) { Pocket = newBase; System.Console.WriteLine("Found pocket base at: " + Pocket.BaseLocation.Pos); } else if (distanceToMain < dist) { natural = loc; dist = distanceToMain; Natural = newBase; } } System.Console.WriteLine("Mapname: " + tyr.GameInfo.MapName); NaturalDefensePos = tyr.MapAnalyzer.Walk(natural.Pos, tyr.MapAnalyzer.EnemyDistances, 10); int distToEnemy = tyr.MapAnalyzer.EnemyDistances[(int)NaturalDefensePos.X, (int)NaturalDefensePos.Y]; int wallDist = tyr.MapAnalyzer.WallDistances[(int)NaturalDefensePos.X, (int)NaturalDefensePos.Y]; for (int x = (int)NaturalDefensePos.X - 5; x <= NaturalDefensePos.X + 5; x++) { for (int y = (int)NaturalDefensePos.Y - 5; y <= NaturalDefensePos.Y + 5; y++) { if (SC2Util.DistanceSq(SC2Util.Point(x, y), natural.Pos) <= 7 * 7 || SC2Util.DistanceSq(SC2Util.Point(x, y), natural.Pos) >= 10 * 10) { continue; } if (tyr.MapAnalyzer.EnemyDistances[x, y] > distToEnemy) { continue; } int newDist = tyr.MapAnalyzer.WallDistances[x, y]; if (newDist > wallDist) { wallDist = newDist; NaturalDefensePos = SC2Util.Point(x, y); } } } MainDefensePos = tyr.MapAnalyzer.Walk(SC2Util.To2D(tyr.MapAnalyzer.StartLocation), tyr.MapAnalyzer.EnemyDistances, 10); }
public void OnStart(Tyr tyr) { int[,] distances = tyr.MapAnalyzer.Distances(SC2Util.To2D(tyr.MapAnalyzer.StartLocation)); BaseLocation natural = null; int dist = 1000000000; foreach (BaseLocation loc in tyr.MapAnalyzer.BaseLocations) { int distanceToMain = distances[(int)loc.Pos.X, (int)loc.Pos.Y]; Base newBase = new Base() { BaseLocation = loc, DistanceToMain = distanceToMain }; Bases.Add(newBase); if (distanceToMain <= 5) { Main = newBase; } else if (tyr.MapAnalyzer.MainAndPocketArea[loc.Pos]) { Pocket = newBase; DebugUtil.WriteLine("Found pocket base at: " + Pocket.BaseLocation.Pos); } else if (distanceToMain < dist) { natural = loc; dist = distanceToMain; Natural = newBase; } Point2D mineralPos = new Point2D() { X = 0, Y = 0 }; foreach (MineralField field in loc.MineralFields) { mineralPos.X += field.Pos.X; mineralPos.Y += field.Pos.Y; } mineralPos.X /= loc.MineralFields.Count; mineralPos.Y /= loc.MineralFields.Count; newBase.MineralLinePos = mineralPos; newBase.OppositeMineralLinePos = new Point2D() { X = 2 * loc.Pos.X - mineralPos.X, Y = 2 * loc.Pos.Y - mineralPos.Y }; Point2D furthest = null; float mineralDist = -1; foreach (MineralField field in loc.MineralFields) { float newDist = SC2Util.DistanceSq(mineralPos, field.Pos); if (newDist > mineralDist) { mineralDist = newDist; furthest = SC2Util.To2D(field.Pos); } } foreach (Gas field in loc.Gasses) { float newDist = SC2Util.DistanceSq(mineralPos, field.Pos); if (newDist > mineralDist) { mineralDist = newDist; furthest = SC2Util.To2D(field.Pos); } } newBase.MineralSide1 = furthest; furthest = null; mineralDist = -1; foreach (MineralField field in loc.MineralFields) { float newDist = SC2Util.DistanceSq(newBase.MineralSide1, field.Pos); if (newDist > mineralDist) { mineralDist = newDist; furthest = SC2Util.To2D(field.Pos); } } foreach (Gas field in loc.Gasses) { float newDist = SC2Util.DistanceSq(newBase.MineralSide1, field.Pos); if (newDist > mineralDist) { mineralDist = newDist; furthest = SC2Util.To2D(field.Pos); } } newBase.MineralSide2 = furthest; newBase.MineralSide1 = new Point2D() { X = (newBase.MineralSide1.X + newBase.BaseLocation.Pos.X) / 2f, Y = (newBase.MineralSide1.Y + newBase.BaseLocation.Pos.Y) / 2f }; newBase.MineralSide2 = new Point2D() { X = (newBase.MineralSide2.X + newBase.BaseLocation.Pos.X) / 2f, Y = (newBase.MineralSide2.Y + newBase.BaseLocation.Pos.Y) / 2f }; } DebugUtil.WriteLine("Mapname: " + tyr.GameInfo.MapName); NaturalDefensePos = tyr.MapAnalyzer.Walk(natural.Pos, tyr.MapAnalyzer.EnemyDistances, 10); int distToEnemy = tyr.MapAnalyzer.EnemyDistances[(int)NaturalDefensePos.X, (int)NaturalDefensePos.Y]; int wallDist = tyr.MapAnalyzer.WallDistances[(int)NaturalDefensePos.X, (int)NaturalDefensePos.Y]; for (int x = (int)NaturalDefensePos.X - 5; x <= NaturalDefensePos.X + 5; x++) { for (int y = (int)NaturalDefensePos.Y - 5; y <= NaturalDefensePos.Y + 5; y++) { if (SC2Util.DistanceSq(SC2Util.Point(x, y), natural.Pos) <= 7 * 7 || SC2Util.DistanceSq(SC2Util.Point(x, y), natural.Pos) >= 10 * 10) { continue; } if (tyr.MapAnalyzer.EnemyDistances[x, y] > distToEnemy) { continue; } int newDist = tyr.MapAnalyzer.WallDistances[x, y]; if (newDist > wallDist) { wallDist = newDist; NaturalDefensePos = SC2Util.Point(x, y); } } } MainDefensePos = tyr.MapAnalyzer.Walk(SC2Util.To2D(tyr.MapAnalyzer.StartLocation), tyr.MapAnalyzer.EnemyDistances, 10); }
public void AddBase(ParticleBase pbase) { Bases.Add(pbase); }