User prompt
Fix Bug: 'Uncaught TypeError: this.well.createAsset is not a function' in this line: 'this.wellGraphics = this.well.createAsset('well', 'Well Graphics', .5, .5);' Line Number: 299
User prompt
Improve
User prompt
Fix Bug: 'Uncaught ReferenceError: House is not defined' in this line: 'var house = new House();' Line Number: 489
User prompt
Improve
User prompt
Improve
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of null (reading 'addChild')' in this line: 'self.parent.addChild(villager);' Line Number: 273
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of null (reading 'addChild')' in this line: 'self.parent.addChild(villager);' Line Number: 273
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of null (reading 'addChild')' in this line: 'self.parent.addChild(villager);' Line Number: 271
User prompt
Improve
User prompt
Improve
User prompt
Improve the code
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'houses')' in this line: 'this.self.houses.push(house);' Line Number: 445
User prompt
Fix Bug: 'Uncaught ReferenceError: houses is not defined' in this line: 'houses.push(house);' Line Number: 475
User prompt
Fix Bug: 'Uncaught TypeError: self.initializeHouses is not a function' in this line: 'self.initializeHouses();' Line Number: 447
===================================================================
--- original.js
+++ change.js
@@ -237,28 +237,26 @@
var self = Container.call(this);
self.isEmploying = true;
self.employVillager = function (villager, workplace) {};
});
-var House = Container.expand(function () {
+var VillagerHome = Container.expand(function () {
var self = Container.call(this);
- House.prototype.scheduleVillagerWork = function (villager) {
+ self.initializeRandomPosition();
+ var homeGraphics = self.createAsset('house', 'Villager Home Graphics', .5, .5);
+ self.isOccupiable = true;
+ self.occupy = function (villager) {
+ if (!this.isOccupiable) return;
+ this.isOccupiable = false;
+ villager.home = this;
LK.setTimeout(function () {
villager.state = 'goingToWork';
villager.moveTo(villager.workplace.x, villager.workplace.y);
}, 5000);
};
- House.prototype.initializeRandomPosition = function () {
+ self.initializeRandomPosition = function () {
this.x = Math.random() * 2048;
this.y = Math.random() * 2732;
};
- var houseGraphics = self.createAsset('house', 'House Graphics', .5, .5);
- self.isOccupiable = true;
- House.prototype.occupy = function (villager) {
- if (!this.isOccupiable) return;
- this.isOccupiable = false;
- villager.home = this;
- this.scheduleVillagerWork(villager);
- };
});
var DayNightCycleManager = Container.expand(function () {
var self = Container.call(this);
self.cycleDuration = 24000;
@@ -335,9 +333,23 @@
DayNightCycleManager.prototype.updateCycle = function () {};
Villager.prototype.isDoingSomething = function () {
return this.currentAction !== null;
};
-Villager.prototype.decideNextAction = function () {};
+Villager.prototype.decideNextAction = function () {
+ if (this.energy < 20 && this.home) {
+ this.targetX = this.home.x;
+ this.targetY = this.home.y;
+ this.state = 'goingHomeToRest';
+ } else if (this.energy >= 20 && this.workplace) {
+ this.targetX = this.workplace.x;
+ this.targetY = this.workplace.y;
+ this.state = 'goingToWork';
+ } else {
+ this.targetX = Math.random() * 2048;
+ this.targetY = Math.random() * 2732;
+ this.state = 'wandering';
+ }
+};
Villager.prototype.initializePosition = function (x, y) {
this.x = x;
this.y = y;
};
@@ -442,13 +454,11 @@
}
};
Game.prototype.addVillager = function (isBaby, iq, x, y) {
var villager = this.villagerFactory.createVillager(iq);
- this.villagerFactory.initializeVillager(villager, isBaby, x, y);
- this.registerVillager(villager);
- this.initializeVillager(villager);
- };
- Game.prototype.initializeVillager = function (villager) {
+ villager.setAge(isBaby);
+ villager.x = x;
+ villager.y = y;
villager.speed = 2;
villager.energy = 100;
villager.tiredness = 0;
villager.state = 'idle';
@@ -456,8 +466,9 @@
villager.workplace = null;
villager.currentAction = null;
villager.targetX = null;
villager.targetY = null;
+ this.registerVillager(villager);
};
self.villagers = [];
self.houses = [];
self.cloudLayer = new Container();
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.