User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'graphics')' in this line: 'self.graphics.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
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 = true;' Line Number: 110
User prompt
add one type of each building at the begining
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
User prompt
add one type of each batiment at the begining
User prompt
add 5 nesw functionality
User prompt
improve villager behavior and movement base on their behavior
User prompt
add 4 new functionality
User prompt
add 3 new functionality
User prompt
add 2 new functionality
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 124
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeRandomPosition is not a function' in this line: 'self.initializeRandomPosition();' Line Number: 122
User prompt
improve 2 time
User prompt
Add a day cycle in 24 hours where every hours take one second
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var Farmer = Villager.expand(function (resources, iq) {' Line Number: 282
User prompt
Improve villager behavior
User prompt
Improve behavior
User prompt
Fix Bug: 'Uncaught ReferenceError: House is not defined' in this line: 'var house = new House();' Line Number: 788
User prompt
Fix Bug: 'Uncaught ReferenceError: House is not defined' in this line: 'var home = new House();' Line Number: 764
===================================================================
--- original.js
+++ change.js
@@ -278,58 +278,60 @@
}
}
};
});
-var Farmer = Container.expand(function (resources, iq) {
+var Farmer = Container.expand(function (resources) {
var self = Container.call(this);
- var self = new Villager(resources, iq);
- self.farmingSkill = 5;
- self.plant = function (resourceType) {
- if (resourceType === 'food' && self.gameResources.seeds.amount > 0) {
- var newPlant = new Plant('food', 10);
- newPlant.x = Math.random() * 2048;
- newPlant.y = Math.random() * 2732;
- if (self.parent) {
- self.parent.addChild(newPlant);
- }
- self.gameResources.seeds.amount--;
- }
- };
- self.harvest = function (plant) {
- if (plant instanceof Plant && plant.isMature) {
- self.gameResources[plant.type].amount += plant.harvestAmount;
- plant.destroy();
- }
- };
+ self.gameResources = resources;
+ 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 Blacksmith = Villager.expand(function (resources, iq) {
+var Blacksmith = Container.expand(function (resources) {
var self = Container.call(this);
- var self = Villager.call(this, resources, iq);
- self.blacksmithingSkill = 5;
- self.forge = function (itemType) {
- if (self.gameResources.iron.amount >= 2) {
- self.gameResources[itemType].amount++;
- self.gameResources.iron.amount -= 2;
- }
- };
+ self.gameResources = resources;
+ 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 Merchant = Villager.expand(function (resources, iq) {
+var Merchant = Container.expand(function (resources) {
var self = Container.call(this);
- var self = Villager.call(this, resources, iq);
- self.tradingSkill = 5;
- self.trade = function (market, resourceType, amount) {
- if (market instanceof Market && self.gameResources[resourceType].amount >= amount) {
- self.gameResources[resourceType].amount -= amount;
- self.gameResources.gold.amount += amount * market.getTradeValueForResource(resourceType);
- }
- };
+ self.gameResources = resources;
+ 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;
self.startTime = Date.now();
self.timeOfDayText = self.createTimeOfDayText();
LK.gui.topCenter.addChild(self.timeOfDayText);
+ LK.on('tick', function () {
+ var currentTime = Date.now();
+ var elapsedTime = (currentTime - self.startTime) / 1000;
+ var hours = Math.floor(elapsedTime % 24);
+ var minutes = Math.floor(elapsedTime % 1 * 60);
+ self.timeOfDayText.setText(hours + ':' + (minutes < 10 ? '0' : '') + minutes);
+ });
});
var VillagerFactory = Container.expand(function (resources) {
var self = Container.call(this);
self.resources = resources;
@@ -394,32 +396,10 @@
});
var Villager = Container.expand(function (resources, iq) {
var self = Container.call(this);
Villager.prototype.seekResource = function (resourceType) {
- var closestResource = this.findClosestResourceOfType(resourceType);
- if (closestResource) {
- this.moveTo(closestResource.x, closestResource.y, this.speed);
- if (this.intersects(closestResource)) {
- closestResource.collectResource(this);
- }
- }
+ console.log('Seeking ' + resourceType);
};
- Villager.prototype.findClosestResourceOfType = function (resourceType) {
- var resources = this.parent.children.filter(function (child) {
- return child instanceof Resource && child.type === resourceType;
- });
- var closestResource = null;
- var closestDistance = Infinity;
- for (var i = 0; i < resources.length; i++) {
- var resource = resources[i];
- var distance = Math.sqrt(Math.pow(resource.x - this.x, 2) + Math.pow(resource.y - this.y, 2));
- if (distance < closestDistance) {
- closestDistance = distance;
- closestResource = resource;
- }
- }
- return closestResource;
- };
self.gameResources = resources;
self.iq = iq;
self.collectingPower = 50;
self.x = Math.random() * 2048;
@@ -517,11 +497,8 @@
}
this.performAction();
};
Villager.prototype.update = function () {
- if (!this.isDoingSomething()) {
- this.decideNextAction();
- }
this.updateStateAndPosition();
};
ResourceDisplay.prototype.positionDisplays = function () {
this.woodDisplay.position.set(100, 50);
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.