public Map() { SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // Generate map this.viewLayer = new Evolve.ViewLayer(); viewLayer.layerOre = true; viewLayer.layerFood = true; viewLayer.layerGold = true; MapOptions mapOptions; mapOptions.foodLayerOptions.density = 50; mapOptions.foodLayerOptions.mapScale = 0.05f; mapOptions.foodLayerOptions.octaves = 1; mapOptions.foodLayerOptions.persistence = 0.5f; mapOptions.oreLayerOptions.density = 50; mapOptions.oreLayerOptions.mapScale = 0.05f; mapOptions.oreLayerOptions.octaves = 1; mapOptions.oreLayerOptions.persistence = 0.5f; mapOptions.goldLayerOptions.density = 50; mapOptions.goldLayerOptions.mapScale = 0.05f; mapOptions.goldLayerOptions.octaves = 1; mapOptions.goldLayerOptions.persistence = 0.5f; // Pass rand to creatures Creature.rand = rand; // Generate map Generate(300, 300, 300, mapOptions); // View Transform viewTransform = new Matrix(); }
public Tile(int X, int Y, float food, float ore, float gold, ViewLayer viewLayer, Random rand, Map map) { // Record map this.map = map; // Record location this.tileX = X; this.tileY = Y; //ore /= int.MaxValue / 100; gold /= int.MaxValue / 100; // Assign Food //food = (int)(food / (long)int.MaxValue * 100); if (food < 0) { throw new System.ArgumentException("Creating tile with negative food"); } this.foodFertility = (int)(food * foodMax); this.food = foodFertility; // Assign Ore if (ore < 0) { throw new System.ArgumentException("Creating tile with negative ore"); } this.oreFertility = (int)(ore * oreMax); this.ore = oreFertility; // Assign Gold if (gold < 0) { throw new System.ArgumentException("Creating tile with negative gold"); } this.goldFertility = (int)(gold * goldMax); this.gold = goldFertility; brush = new SolidBrush(Color.FromArgb(255, viewLayer.layerOre?bodyR:0, viewLayer.layerFood?bodyG:0, viewLayer.layerGold?bodyB:0)); pen = new Pen(Color.FromArgb(255, rand.Next() % 256, rand.Next() % 256, rand.Next() % 256)); landRectangle = new Rectangle(X * tileSize, Y * tileSize, tileSize, tileSize); borderRectangle = new Rectangle(X * tileSize + 1, Y * tileSize + 1, tileSize - 1, tileSize - 1); // Create grass rectangles grassRectangle = new Point[10]; for (int i = 0; i < grassRectangle.Count(); i++) { //grassRectangle[i] = new Point(rand.Next() % (tileSize - 6) + pixelX, rand.Next() % (tileSize - 6) + pixelY); //grassRectangle[i] = new Point(rand.Next() % (tileSize - 6) + pixelX, rand.Next() % (tileSize - 6) + pixelY); } }
public int mine(Creature creature, ViewLayer viewLayer) { // Let oreProduction = rate of ore produced // oreProduction = (oreProductionBalance * miningSkill * tileImprovement * ore) / (miningDuration * creatureAverageMiningSkill * oreMax) int oreProduction = (Map.oreProductionBalance * creature.mineSkill * (tileOreImprovementDenomenator + tileOreImprovementNumerator) * ore) / (miningDuration * Creature.creatureAverageMiningSkill * oreMax); ore -= oreProduction; return(oreProduction); //int initialOre = this.ore; //ore -= (int)((long)creature.mineSkill++ * initialOre / int.MaxValue); //UpdateBrush(viewLayer); //return (initialOre - ore); }
// Let foodExtraction = rate of food depletion on the tile due to farming activity (food / tick) // Let foodProduction = rate of food produced (food / tick) // We multiply these by farmDuration to get amount extracted or produced in one farm activity public int farm(Creature creature, ViewLayer viewLayer) { // foodExtraction = ln(2) * foodMax * foodRegrowthModifier * (1 - foodRegrowthBalance) / tHalf // foodExtraction = 693 * foodMax * (tileImprovementFoodregrowthDenomenator - tileImprovementFoodregrowthNumerator) * (foodRegrowthBalanceDenomenator - foodRegrowthBalanceNumerator) / (tHalf * 1000 * tileImprovementFoodregrowthDenomenator * foodRegrowthBalanceDenomenator) food -= (int)(693L * foodMax * (tileImprovementFoodregrowthDenomenator - tileImprovementFoodregrowthNumerator) * (Map.foodRegrowthBalanceDenomenator - Map.foodRegrowthBalanceNumerator) * farmDuration / (tHalf * 1000L * tileImprovementFoodregrowthDenomenator * Map.foodRegrowthBalanceDenomenator)); if (food < 0) { food = 0; } UpdateBrush(viewLayer); // foodProduction = (farmSkill * tileImprovement * food * foodConsumptionActive) / (creatureAverageFarmSkill * foodMax * foodProductionBalance) return((int)(((long)creature.farmSkill * (tileFoodImprovementDenomenator + tileFoodImprovementNumerator) * food * Creature.foodConsumptionActiveNumerator * Map.foodProductionBalanceDenomenator * farmDuration) / ((long)Creature.creatureAverageFarmSkill * tileFoodImprovementDenomenator * foodMax * Creature.foodConsumptionActiveDenomenator * Map.foodProductionBalanceNumerator))); }
internal void UpdateBrush(ViewLayer viewLayer) { brush.Color = Color.FromArgb(255, viewLayer.layerOre?bodyR:0, viewLayer.layerFood?bodyG:0, viewLayer.layerGold?bodyB:0); }