User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var Doctor = Villager.expand(function (resources) {' Line Number: 47
User prompt
Add 3 new functionality
User prompt
Add 5 New functionality
User prompt
Lumberjack move base on their iq
User prompt
Lumberjack move 3 time faster
User prompt
Make lumberjack move
User prompt
Show villager
User prompt
Show villager
User prompt
Make villager upfront the background
User prompt
Add 8 new functionality
User prompt
Add 6 New functionality
User prompt
Fix villager
User prompt
Fix villager not spawning
User prompt
Improve all fonctionality
User prompt
Improve
User prompt
Fix Bug: 'Cannot read properties of undefined (reading 'villagers')' in this line: 'self.gameInstance.villagers.forEach(function (villager) {' Line Number: 8
User prompt
Improve the entire code in two pass
User prompt
Fix Bug: 'Cannot read properties of undefined (reading 'villagers')' in this line: 'self.gameInstance.villagers.forEach(function (villager) {' Line Number: 8
User prompt
Improve the entire code
User prompt
Fix Bug: 'TypeError: this.performAction is not a function' in this line: 'this.performAction();' Line Number: 852
User prompt
Fix Bug: 'TypeError: this.performAction is not a function' in this line: 'this.performAction();' Line Number: 852
User prompt
Fix Bug: 'TypeError: villager.decideNextAction is not a function' in this line: 'villager.decideNextAction();' Line Number: 995
User prompt
Fix Bug: 'TypeError: villager.decideNextAction is not a function' in this line: 'villager.decideNextAction();' Line Number: 995
User prompt
Fix Bug: 'TypeError: villager.updateStateAndPosition is not a function' in this line: 'villager.updateStateAndPosition();' Line Number: 1005
User prompt
Fix Bug: 'TypeError: villager.updateStateAndPosition is not a function' in this line: 'villager.updateStateAndPosition();' Line Number: 1005
===================================================================
--- original.js
+++ change.js
@@ -40,8 +40,13 @@
},
'rock': function () {
self.villager.state = 'seekingRock';
},
+ 'trade': function () {
+ self.villager.state = 'trading';
+ self.villager.targetX = self.villager.marketplace.x;
+ self.villager.targetY = self.villager.marketplace.y;
+ },
'wander': function () {
self.villager.targetX = Math.random() * 2048;
self.villager.targetY = Math.random() * 2732;
self.villager.state = 'wandering';
@@ -819,13 +824,40 @@
positionInitializer.initializeRandomPosition(self, self.width, self.height, function () {
return self.checkOverlapWithOtherBuildings();
});
});
+var Trader = Container.expand(function (resources) {
+ var self = Container.call(this);
+ self.traderGraphics = self.createAsset('trader', 'Trader Graphics', 0.5, 0.5);
+ self.addChild(self.traderGraphics);
+ self.gameResources = resources;
+ self.trade = function (resourceType, amount, targetResourceType) {
+ if (self.gameResources[resourceType].amount >= amount) {
+ self.gameResources[resourceType].amount -= amount;
+ self.gameResources[targetResourceType].amount += amount * self.getExchangeRate(resourceType, targetResourceType);
+ }
+ };
+ self.getExchangeRate = function (resourceType, targetResourceType) {
+ return 1;
+ };
+});
var Villager = Container.expand(function (resources, iq) {
var self = Container.call(this);
self.gameResources = resources;
self.iq = iq;
});
+var Granary = Container.expand(function () {
+ var self = Container.call(this);
+ self.granaryGraphics = self.createAsset('granary', 'Granary Graphics', 0.5, 0.5);
+ var positionInitializer = new PositionInitializer();
+ positionInitializer.initializeRandomPosition(self, self.granaryGraphics.width, self.granaryGraphics.height, function () {
+ return self.checkOverlapWithOtherBuildings();
+ });
+ self.storeFood = function (amount) {
+ self.gameResources.food.amount += amount;
+ if (self.gameResources.food.amount > 1000) self.gameResources.food.amount = 1000;
+ };
+});
function globalSeekResource(villager, resourceType) {}
this.weatherSystem = new WeatherSystem();
Villager.prototype.moveTo = function (targetX, targetY, speed) {
var dx = targetX - this.x;
@@ -888,8 +920,14 @@
case 'seekingWood':
case 'seekingRock':
this.seekResource(this.state.substring(7).toLowerCase());
break;
+ case 'trading':
+ this.moveTo(this.targetX, this.targetY, this.speed);
+ if (this.hasReachedTarget(this.targetX, this.targetY)) {
+ this.tradeWithMarketplace();
+ }
+ break;
default:
this.wanderRandomly();
break;
}
@@ -904,8 +942,14 @@
var dx = this.x - targetX;
var dy = this.y - targetY;
return Math.sqrt(dx * dx + dy * dy) < 5;
};
+Villager.prototype.tradeWithMarketplace = function () {
+ if (this.marketplace) {
+ this.marketplace.trade(this, 'wood', 10, 'food');
+ this.decideNextAction();
+ }
+};
Villager.prototype.setRandomTarget = function () {
this.targetX = Math.random() * 2048;
this.targetY = 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.