User prompt
Create différents asset for each villager type
User prompt
Fix Bug: 'TypeError: this.seekResource is not a function' in this line: 'this.seekResource(this.state.substring(7).toLowerCase());' Line Number: 796
User prompt
Fix Bug: 'TypeError: this.seekResource is not a function' in this line: 'this.seekResource('food');' Line Number: 796
User prompt
Spawn a New villager every 0.1 second
User prompt
Fix villager not apairing
User prompt
Add 4 of each villager type at launch
User prompt
Fix Bug: 'Uncaught ReferenceError: Villager is not defined' in this line: 'Villager.prototype.isDoingSomething = function () {' Line Number: 771
User prompt
Fix Bug: 'Cannot read properties of undefined (reading 'villagers')' in this line: 'self.gameInstance.villagers.forEach(function (villager) {' Line Number: 7
User prompt
Villager need to have différents asset base on their job
User prompt
Add 4 of each type of villager at launch
User prompt
Fix Bug: 'Cannot read properties of undefined (reading 'villagers')' in this line: 'self.gameInstance.villagers.forEach(function (villager) {' Line Number: 7
User prompt
Add 8 new functionality
User prompt
Fix Bug: 'Cannot read properties of null (reading 'villagers')' in this line: 'self.parent.villagers.forEach(function (villager) {' Line Number: 7
User prompt
Fix Bug: 'Uncaught ReferenceError: Market is not defined' in this line: 'self.market = new Market();' Line Number: 1119
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.addChild(self.weatherSystem);' Line Number: 807
User prompt
Fix Bug: 'Uncaught TypeError: this.addChild is not a function' in this line: 'this.addChild(this.weatherSystem);' Line Number: 807
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.addChild(self.weatherSystem);' Line Number: 807
User prompt
Fix Bug: 'Uncaught TypeError: this.addChild is not a function' in this line: 'this.addChild(this.weatherSystem);' Line Number: 807
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.addChild(weatherSystem);' Line Number: 807
User prompt
Add 5 New functionality
User prompt
Add 16 new functionality
User prompt
Add a building of each type
User prompt
Add a building of one type at launch
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'isTeaching')' in this line: 'self.isTeaching = false;' Line Number: 110
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'isTeaching')' in this line: 'self.isTeaching = false;' Line Number: 110
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,6 @@
var WeatherSystem = Container.expand(function () {
var self = Container.call(this);
- self.gameInstance = null;
self.currentWeather = 'sunny';
self.changeWeather = function () {
var weathers = ['sunny', 'rainy', 'windy', 'snowy'];
self.currentWeather = weathers[Math.floor(Math.random() * weathers.length)];
@@ -208,20 +207,20 @@
if (villager.happiness > 100) villager.happiness = 100;
});
};
});
-var Healer = Container.expand(function (resources) {
+var Apothecary = Container.expand(function () {
var self = Container.call(this);
- self.gameResources = resources;
- self.healingPower = 10;
- self.x = Math.random() * 2048;
- self.y = Math.random() * 2732;
- var healerGraphics = self.createAsset('healer', 'Healer Graphics', 0.5, 0.5);
- self.addChild(healerGraphics);
- self.heal = function (apothecary) {
- if (apothecary instanceof Apothecary) {
- self.gameResources.health.amount += self.healingPower;
- if (self.gameResources.health.amount > 100) self.gameResources.health.amount = 100;
+ self.apothecaryGraphics = self.createAsset('apothecary', 'Apothecary Graphics', 0.5, 0.5);
+ var positionInitializer = new PositionInitializer();
+ positionInitializer.initializeRandomPosition(self, self.apothecaryGraphics.width, self.apothecaryGraphics.height, function () {
+ return self.checkOverlapWithOtherBuildings();
+ });
+ self.provideMedicine = function (villager) {
+ if (villager.gameResources.food.amount >= 2) {
+ villager.gameResources.food.amount -= 2;
+ villager.health += 10;
+ if (villager.health > 100) villager.health = 100;
}
};
});
var BlacksmithShop = Container.expand(function () {
@@ -245,15 +244,26 @@
self.addChild(self.guardGraphics);
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
self.speed = 2;
- self.patrolArea = function (guardTower) {
- if (guardTower instanceof GuardTower) {
+ self.isDaytime = true;
+ self.patrolArea = function () {
+ if (!self.isDaytime) {
var patrolX = Math.random() * 2048;
var patrolY = Math.random() * 2732;
self.moveTo(patrolX, patrolY, self.speed);
}
};
+ self.sleep = function () {
+ if (self.isDaytime) {}
+ };
+ LK.on('tick', function () {
+ if (self.isDaytime) {
+ self.sleep();
+ } else {
+ self.patrolArea();
+ }
+ });
});
var Brewery = Container.expand(function () {
var self = Container.call(this);
self.breweryGraphics = self.createAsset('brewery', 'Brewery Graphics', 0.5, 0.5);
@@ -270,17 +280,16 @@
}, 30000);
};
self.produceBeverage();
});
-var Forester = Container.expand(function (resources) {
+var Lumberjack = Container.expand(function (resources) {
var self = Container.call(this);
self.gameResources = resources;
self.choppingPower = 5;
- self.plantingPower = 1;
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
- var foresterGraphics = self.createAsset('forester', 'Forester Graphics', 0.5, 0.5);
- self.addChild(foresterGraphics);
+ var lumberjackGraphics = self.createAsset('lumberjack', 'Lumberjack Graphics', 0.5, 0.5);
+ self.addChild(lumberjackGraphics);
self.chop = function (tree) {
if (tree instanceof Tree) {
self.gameResources.wood.amount += self.choppingPower;
if (self.gameResources.wood.amount > 100) self.gameResources.wood.amount = 100;
@@ -289,16 +298,8 @@
tree.destroy();
}
}
};
- self.plantTree = function () {
- var newTree = new Tree();
- newTree.x = Math.random() * 2048;
- newTree.y = Math.random() * 2732;
- if (self.parent) {
- self.parent.addChild(newTree);
- }
- };
});
var Miner = Container.expand(function (resources) {
var self = Container.call(this);
self.gameResources = resources;
@@ -306,10 +307,10 @@
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
var minerGraphics = self.createAsset('miner', 'Miner Graphics', 0.5, 0.5);
self.addChild(minerGraphics);
- self.mine = function (quarry) {
- if (quarry instanceof Quarry) {
+ self.mine = function (rock) {
+ if (rock instanceof Rock) {
self.gameResources.rock.amount += self.miningPower;
if (self.gameResources.rock.amount > 100) self.gameResources.rock.amount = 100;
}
};
@@ -321,10 +322,10 @@
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
var fishermanGraphics = self.createAsset('fisherman', 'Fisherman Graphics', 0.5, 0.5);
self.addChild(fishermanGraphics);
- self.fish = function (fishingHut) {
- if (fishingHut instanceof FishingHut) {
+ self.fish = function (well) {
+ if (well instanceof Well) {
self.gameResources.food.amount += self.fishingPower;
if (self.gameResources.food.amount > 100) self.gameResources.food.amount = 100;
}
};
@@ -353,22 +354,21 @@
};
var positionInitializer = new PositionInitializer();
positionInitializer.initializeRandomPosition(self, self.graphics.width, self.graphics.height, self.checkOverlapWithOtherBuildings);
});
-var Teacher = Container.expand(function (resources) {
- var self = Container.call(this);
- self.gameResources = resources;
- self.teachingPower = 10;
- self.x = Math.random() * 2048;
- self.y = Math.random() * 2732;
- var teacherGraphics = self.createAsset('teacher', 'Teacher Graphics', 0.5, 0.5);
- self.addChild(teacherGraphics);
- self.teach = function (school) {
- if (school instanceof School) {
- self.gameResources.iq.amount += self.teachingPower;
- if (self.gameResources.iq.amount > 200) self.gameResources.iq.amount = 200;
- }
+var School = Building.expand(function () {
+ var self = Building.call(this, 'School');
+ self.isTeaching = false;
+ self.teach = function (villager) {
+ if (!self.isTeaching) return;
+ villager.iq += 10;
};
+ self.startTeaching = function () {
+ self.isTeaching = true;
+ LK.setTimeout(function () {
+ self.isTeaching = false;
+ }, 20000);
+ };
});
var Resource = Container.expand(function (type, amount) {
var self = Container.call(this);
self.type = type;
@@ -643,19 +643,17 @@
});
var Merchant = Container.expand(function (resources) {
var self = Container.call(this);
self.gameResources = resources;
- self.tradingPower = 5;
- self.x = Math.random() * 2048;
- self.y = Math.random() * 2732;
- var merchantGraphics = self.createAsset('merchant', 'Merchant Graphics', 0.5, 0.5);
- self.addChild(merchantGraphics);
- self.trade = function (marketplace, resourceType, amount) {
- if (marketplace instanceof Marketplace && self.gameResources[resourceType].amount >= amount) {
- self.gameResources[resourceType].amount -= amount;
- marketplace.addResource(resourceType, amount);
- }
- };
+ self.currentAction = null;
+ self.targetX = null;
+ self.targetY = null;
+ self.speed = 1;
+ self.energy = 100;
+ self.tiredness = 0;
+ self.state = 'idle';
+ self.home = null;
+ self.workplace = null;
});
var DayNightCycleManager = Container.expand(function () {
var self = Container.call(this);
self.cycleDuration = 24000;
@@ -691,20 +689,33 @@
}
return villager;
};
});
-var Baker = Container.expand(function (resources) {
+var Bakery = Container.expand(function () {
var self = Container.call(this);
- self.gameResources = resources;
- self.bakingPower = 10;
- self.x = Math.random() * 2048;
- self.y = Math.random() * 2732;
- var bakerGraphics = self.createAsset('baker', 'Baker Graphics', 0.5, 0.5);
- self.addChild(bakerGraphics);
- self.bakeBread = function (bakery) {
- if (bakery instanceof Bakery) {
- self.gameResources.food.amount += self.bakingPower;
- if (self.gameResources.food.amount > 100) self.gameResources.food.amount = 100;
+ self.bakeryGraphics = self.createAsset('bakery', 'Bakery Graphics', 0.5, 0.5);
+ self.initializeRandomPosition = function () {
+ do {
+ self.x = Math.random() * (2048 - self.bakeryGraphics.width) + self.bakeryGraphics.width / 2;
+ self.y = Math.random() * (2732 - self.bakeryGraphics.height) + self.bakeryGraphics.height / 2;
+ } while (self.parent && self.checkOverlapWithOtherBuildings());
+ };
+ self.checkOverlapWithOtherBuildings = function () {
+ var buildings = self.parent.children.filter(function (child) {
+ return child !== self && child instanceof Building;
+ });
+ return buildings.some(function (building) {
+ var dx = self.x - building.x;
+ var dy = self.y - building.y;
+ return Math.sqrt(dx * dx + dy * dy) < 300 + Math.max(self.bakeryGraphics.width, self.bakeryGraphics.height) / 2 + Math.max(building.width, building.height) / 2;
+ });
+ };
+ self.bakeBread = function (villager) {
+ if (villager.gameResources.wood.amount >= 5 && villager.gameResources.food.amount >= 2) {
+ villager.gameResources.wood.amount -= 5;
+ villager.gameResources.food.amount -= 2;
+ villager.gameResources.food.amount += 10;
+ if (villager.gameResources.food.amount > 100) villager.gameResources.food.amount = 100;
}
};
});
var Cloud = Container.expand(function () {
@@ -792,9 +803,8 @@
return self.checkOverlapWithOtherBuildings();
});
});
this.weatherSystem = new WeatherSystem();
-this.weatherSystem.gameInstance = this;
Villager.prototype.isDoingSomething = function () {
return this.currentAction !== null;
};
Villager.prototype.moveTo = function (targetX, targetY, speed) {
@@ -1094,11 +1104,13 @@
self.houses = [];
self.cloudLayer = new Container();
self.clouds = [];
self.villagerFactory = new VillagerFactory(self.resources);
- for (var i = 0; i < 10; i++) {
- self.createAndAddVillager();
- }
+ ['Lumberjack', 'Miner', 'Fisherman', 'Guard', 'Farmer', 'Blacksmith', 'Merchant', 'Gardener'].forEach(function (villagerType) {
+ for (var i = 0; i < 4; i++) {
+ self.createAndAddVillager(villagerType);
+ }
+ });
for (var i = 0; i < 20; i++) {
var iq = Math.random() * 50 + 50;
var x = Math.random() * 2048;
var y = Math.random() * 2732;
A background of a paysage with plain and without tree or montainbut no water see from the top in the air 100m by 100m Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
One human medieval villager in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a house in a warcraft 2 style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree a rock and crambery in a RTS style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A heart comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cloud in a comic style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A market in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An Inn in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An school in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An bakery in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A well in a RTS fantasy style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tree in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An apple in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A rock in a rts style Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A home in a RTS and fantasy style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A brewery in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lumberjack in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a marketplace in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a festival in a fantasy rts style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.