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
var RandomPositionInitializer = Container.expand(function () {
var self = Container.call(this);
self.initializeRandomPosition = function (building, graphics) {
do {
building.x = Math.random() * (2048 - graphics.width) + graphics.width / 2;
building.y = Math.random() * (2732 - graphics.height) + graphics.height / 2;
} while (building.parent && building.checkOverlapWithOtherBuildings());
};
});
var Building = Container.expand(function (assetName) {
var self = Container.call(this);
self.graphics = self.createAsset(assetName.toLowerCase(), assetName + ' Graphics', 0.5, 0.5);
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.graphics.width, self.graphics.height) / 2 + Math.max(building.graphics.width, building.graphics.height) / 2;
});
};
var positionInitializer = new RandomPositionInitializer();
positionInitializer.initializeRandomPosition(self, self.graphics);
});
var School = Building.expand(function () {
var self = Container.call(this);
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;
self.resourceGraphics = self.createAsset(type.toLowerCase(), type + ' Graphics', 0.5, 0.5);
self.amount = amount;
self.collectResource = function (villager) {
if (self.amount > 0) {
var collectedAmount = Math.min(villager.collectingPower, self.amount);
villager.gameResources[self.type.toLowerCase()].amount += collectedAmount;
self.amount -= collectedAmount;
if (self.amount <= 0) {
self.destroy();
}
}
};
});
var Food = Resource.expand(function () {
var self = Container.call(this);
var self = Resource.call(this, 'Food', 100);
});
var Rock = Resource.expand(function () {
var self = Container.call(this);
var self = Resource.call(this, 'Rock', 100);
});
var ResourceDisplay = Container.expand(function (resources) {
var self = Container.call(this);
self.woodDisplay = self.addChild(new WoodDisplay(resources.wood));
self.rockDisplay = self.addChild(new RockDisplay(resources.rock));
self.foodDisplay = self.addChild(new FoodDisplay(resources.food));
self.positionDisplays();
});
var WoodDisplay = Container.expand(function (woodResource) {
var self = Container.call(this);
self.woodResource = woodResource;
var woodGraphics = self.createAsset('wood', 'Wood Resource Display', 0.5, 0.5);
self.addChild(woodGraphics);
self.woodText = new Text2(woodResource.amount.toString(), {
size: 50,
fill: "#ffffff"
});
self.woodText.position.set(woodGraphics.width / 2, woodGraphics.height + 20);
self.addChild(self.woodText);
});
var RockDisplay = Container.expand(function (rockResource) {
var self = Container.call(this);
self.rockResource = rockResource;
var rockGraphics = self.createAsset('rock', 'Rock Resource Display', 0.5, 0.5);
self.addChild(rockGraphics);
self.rockText = new Text2(rockResource.amount.toString(), {
size: 50,
fill: "#ffffff"
});
self.rockText.x = rockGraphics.width / 2;
self.rockText.y = rockGraphics.height + 20;
self.addChild(self.rockText);
});
var FoodDisplay = Container.expand(function (foodResource) {
var self = Container.call(this);
self.foodResource = foodResource;
var foodGraphics = self.createAsset('food', 'Food Resource Display', 0.5, 0.5);
self.addChild(foodGraphics);
self.foodText = new Text2(foodResource.amount.toString(), {
size: 50,
fill: "#ffffff"
});
self.foodText.x = foodGraphics.width / 2;
self.foodText.y = foodGraphics.height + 20;
self.addChild(self.foodText);
});
var Well = Container.expand(function () {
var self = Container.call(this);
self.wellGraphics = self.createAsset('well', 'Well Graphics', .5, .5);
self.initializeRandomPosition = function () {
do {
self.x = Math.random() * (2048 - self.wellGraphics.width) + self.wellGraphics.width / 2;
self.y = Math.random() * (2732 - self.wellGraphics.height) + self.wellGraphics.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.wellGraphics.width, self.wellGraphics.height) / 2 + Math.max(building.width, building.height) / 2;
});
};
self.initializeRandomPosition();
self.drinkWater = function (villager) {
villager.tiredness -= 5;
if (villager.tiredness < 0) villager.tiredness = 0;
};
});
var Inn = Container.expand(function () {
var self = Container.call(this);
self.innGraphics = self.createAsset('inn', 'Inn Graphics', 0.5, 0.5);
self.initializeRandomPosition = function () {
do {
self.x = Math.random() * (2048 - self.innGraphics.width) + self.innGraphics.width / 2;
self.y = Math.random() * (2732 - self.innGraphics.height) + self.innGraphics.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.innGraphics.width, self.innGraphics.height) / 2 + Math.max(building.width, building.height) / 2;
});
};
self.initializeRandomPosition();
self.isOccupiable = true;
self.occupy = function (villager) {
if (!self.isOccupiable) return;
self.isOccupiable = false;
villager.state = 'restingAtInn';
villager.tiredness = Math.max(villager.tiredness - 20, 0);
LK.setTimeout(function () {
self.isOccupiable = true;
}, 10000);
};
});
var Gardener = Container.expand(function () {
var self = Container.call(this);
self.homeGraphics = self.createAsset('home', 'Home Graphics', 0.5, 0.5);
do {
self.x = Math.random() * (2048 - self.homeGraphics.width) + self.homeGraphics.width / 2;
self.y = Math.random() * (2732 - self.homeGraphics.height) + self.homeGraphics.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) < 200 + Math.max(self.homeGraphics.width, self.homeGraphics.height) / 2 + Math.max(building.width, building.height) / 2;
});
};
self.tendPlants = function () {};
self.plantNewTree = function () {
var newTree = new Tree();
newTree.x = Math.random() * 2048;
newTree.y = Math.random() * 2732;
if (self.parent) {
self.parent.addChild(newTree);
}
};
});
var Festival = Container.expand(function () {
var self = Container.call(this);
self.x = 2048 / 2;
self.y = 2732 / 2 - 800;
self.isActive = false;
self.activateFestival = function () {
self.isActive = true;
LK.setTimeout(function () {
self.isActive = false;
}, 10000);
};
self.isVillagerParticipating = function (villager) {
return self.isActive && villager.intersects(self);
};
});
var Heart = Container.expand(function () {
var self = Container.call(this);
self.showAbove = function (villager) {
self.x = villager.x;
self.y = villager.y - villager.height;
self.alpha = 1;
self.follow = function () {
if (villager) {
self.x = villager.x;
self.y = villager.y - villager.height;
}
};
LK.on('tick', self.follow);
LK.setTimeout(function () {
LK.off('tick', self.follow);
self.alpha = 1;
self.destroy();
}, 1000);
};
});
var Market = Container.expand(function () {
var self = Container.call(this);
self.marketGraphics = self.createAsset('market', 'Market Graphics', 0.5, 0.5);
self.availableResources = {
wood: 0,
rock: 0,
food: 0
};
self.trade = function (villager, resourceType, amount) {
if (self.availableResources[resourceType] >= amount) {
self.availableResources[resourceType] -= amount;
villager.gameResources[resourceType].amount += amount;
}
};
self.addResource = function (resourceType, amount) {
self.availableResources[resourceType] += amount;
};
self.initializePosition = function () {
if (!self.parent) return;
if (self.parent) {
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
}
};
self.initializePosition();
});
var Wood = Resource.expand(function () {
var self = Container.call(this);
var self = Resource.call(this, 'Wood', 100);
});
var RockResource = Resource.expand(function () {
var self = Container.call(this);
var self = Resource.call(this, 'Rock', 100);
});
var FoodResource = Resource.expand(function () {
var self = Container.call(this);
var self = Resource.call(this, 'Food', 100);
});
var Tree = Container.expand(function () {
var self = Container.call(this);
self.resourceType = 'food';
self.amount = 100;
self.collectResource = function (villager) {
if (self.amount > 0) {
var collectedAmount = Math.min(50, self.amount);
villager.gameResources.food.amount += collectedAmount;
villager.carriedFood += collectedAmount;
self.amount -= collectedAmount;
if (self.amount <= 0) {
self.destroy();
}
}
};
});
var Farmer = Container.expand(function (resources) {
var self = Container.call(this);
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 = Container.expand(function (resources) {
var self = Container.call(this);
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 = Container.expand(function (resources) {
var self = Container.call(this);
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);
});
var VillagerFactory = Container.expand(function (resources) {
var self = Container.call(this);
self.resources = resources;
self.createVillager = function (iq) {
return new Villager(self.resources, iq);
};
self.initializeAndAddVillager = function (isBaby, iq, x, y) {
var villager = this.createVillager(iq);
villager.setAge(isBaby);
if (this.parent) {
this.parent.addChild(villager);
}
return villager;
};
});
var Bakery = Container.expand(function () {
var self = Container.call(this);
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.initializeRandomPosition();
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 () {
var self = Container.call(this);
self.initializeMovement = function (speed) {
self.speed = speed * 1.5;
self.cloudGraphics = self.createAsset('cloud', 'Cloud Graphics', 0.5, 0.5);
self.addChild(self.cloudGraphics);
self.move = function () {
self.x += self.speed;
if (self.x > 2048) {
self.x = -self.cloudGraphics.width;
}
};
LK.on('tick', self.move);
};
});
var EmployingWorkPlace = Container.expand(function () {
var self = Container.call(this);
});
var Villager = Container.expand(function (resources, iq) {
var self = Container.call(this);
Villager.prototype.seekResource = function (resourceType) {
console.log('Seeking ' + resourceType);
};
self.gameResources = resources;
self.iq = iq;
self.collectingPower = 50;
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
self.speed = 10;
self.energy = 100;
self.tiredness = 0;
self.state = 'idle';
self.home = null;
self.workplace = null;
var villagerGraphics = self.createAsset('villager', 'Villager Graphics', 0.5, 0.5);
self.addChild(villagerGraphics);
});
var WoodResource = Container.expand(function (amount) {
var self = Container.call(this);
self.type = 'Wood';
self.amount = amount;
self.collect = function (villager) {};
});
var Home = Container.expand(function () {
var self = Container.call(this);
self.homeGraphics = self.createAsset('home', 'Home Graphics', 0.5, 0.5);
self.initializeRandomPosition = function () {
do {
self.x = Math.random() * (2048 - self.homeGraphics.width) + self.homeGraphics.width / 2;
self.y = Math.random() * (2732 - self.homeGraphics.height) + self.homeGraphics.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.homeGraphics.width, self.homeGraphics.height) / 2 + Math.max(building.width, building.height) / 2;
});
};
self.initializeRandomPosition();
});
Villager.prototype.isDoingSomething = function () {
return this.currentAction !== null;
};
Villager.prototype.moveTo = function (targetX, targetY, speed) {
var dx = targetX - this.x;
var dy = targetY - this.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx);
if (distance > 1) {
var moveDistance = Math.min(speed * (1 - Math.exp(-distance / 100)), distance);
this.x += Math.cos(angle) * moveDistance;
this.y += Math.sin(angle) * moveDistance;
}
};
Villager.prototype.decideNextAction = function () {};
Villager.prototype.performAction = function () {
if (this.state === 'idle') {
this.idle();
} else if (this.state === 'goingHomeToRest') {
this.goHomeToRest();
} else if (this.state === 'goingToWork') {
this.goToWork();
} else if (this.state === 'seekingFood') {
this.seekResource('food');
} else if (this.state === 'seekingWood') {
this.seekResource('wood');
} else if (this.state === 'seekingRock') {
this.seekResource('rock');
} else if (this.state === 'wandering') {
this.wander();
}
};
Villager.prototype.idle = function () {};
Villager.prototype.goHomeToRest = function () {
this.moveTo(this.home.x, this.home.y, this.speed);
if (this.x === this.home.x && this.y === this.home.y) {
this.state = 'resting';
}
};
Villager.prototype.goToWork = function () {
this.moveTo(this.workplace.x, this.workplace.y, this.speed);
if (this.x === this.workplace.x && this.y === this.workplace.y) {
this.state = 'working';
}
};
Villager.prototype.wander = function () {
this.moveTo(this.targetX, this.targetY, this.speed);
if (this.x === this.targetX && this.y === this.targetY) {
this.decideNextAction();
}
};
Villager.prototype.updateStateAndPosition = function () {
if (this.targetX !== null && this.targetY !== null) {
this.moveTo(this.targetX, this.targetY);
}
this.performAction();
};
Villager.prototype.update = function () {
this.updateStateAndPosition();
};
ResourceDisplay.prototype.positionDisplays = function () {
this.woodDisplay.position.set(100, 50);
this.rockDisplay.position.set(300, 50);
this.foodDisplay.position.set(500, 50);
};
Bakery.prototype.sellBread = function (villager) {
if (villager.gameResources.food.amount >= 5) {
villager.gameResources.food.amount -= 5;
villager.energy += 10;
if (villager.energy > 100) villager.energy = 100;
}
};
DayNightCycleManager.prototype.createTimeOfDayText = function () {
var text = new Text2('', {
size: 50,
fill: "#ffffff"
});
text.anchor.set(0.5, 0);
text.x = 2048 / 2;
text.y = 100;
return text;
};
Villager.prototype.decideNextAction = function () {
var needs = {
'rest': this.energy < 20,
'work': this.energy >= 20 && this.workplace,
'food': this.gameResources.food.amount < 20,
'wood': this.gameResources.wood.amount < 20,
'rock': this.gameResources.rock.amount < 20
};
var actions = {
'rest': () => {
this.targetX = this.home.x;
this.targetY = this.home.y;
this.state = 'goingHomeToRest';
},
'work': () => {
this.targetX = this.workplace.x;
this.targetY = this.workplace.y;
this.state = 'goingToWork';
},
'food': () => {
this.state = 'seekingFood';
},
'wood': () => {
this.state = 'seekingWood';
},
'rock': () => {
this.state = 'seekingRock';
},
'wander': () => {
this.targetX = Math.random() * 2048;
this.targetY = Math.random() * 2732;
this.state = 'wandering';
}
};
var chosenAction = Object.keys(needs).find(need => needs[need]);
if (chosenAction) {
actions[chosenAction]();
} else {
actions['wander']();
}
};
var Game = Container.expand(function () {
var self = Container.call(this);
this.createBackground = function () {
var background = this.createAsset('background', 'Game Background', 0, 0);
background.width = 2048 * 1.5;
background.height = 2732 * 1.5;
background.anchor.set(0.5, 0.5);
background.x = 2048 / 2;
background.y = 2732 / 2;
this.addChildAt(background, 0);
};
this.createBackground();
Game.prototype.createAndAddVillager = function () {
var iq = Math.random() * 50 + 100;
var villager = new Villager(this.resources, iq);
this.addChild(villager);
this.villagers.push(villager);
};
Game.prototype.executeCurrentAction = function (villager) {};
Game.prototype.registerVillager = function (villager) {
this.villagers.push(villager);
};
Game.prototype.createAndAddVillagerIfPossible = function () {
if (this.resources && this.resources.food.amount >= 10) {
this.createAndInitializeVillager(false, Math.random() * 50 + 50, Math.random() * 2048, Math.random() * 2732);
this.resources.food.amount -= 10;
}
};
Game.prototype.createAndInitializeVillager = function (isBaby, iq, x, y) {
var villager = this.villagerFactory.initializeAndAddVillager(isBaby, iq, x, y);
this.initializeVillagerProperties(villager);
this.registerVillager(villager);
};
Game.prototype.zoomOnVillagers = function (villagerA, villagerB) {
var zoomLevel = 2;
var centerX = (villagerA.x + villagerB.x) / 2;
var centerY = (villagerA.y + villagerB.y) / 2;
LK.stageContainer.scale.x = zoomLevel;
LK.stageContainer.scale.y = zoomLevel;
LK.stageContainer.pivot.x = centerX;
LK.stageContainer.pivot.y = centerY;
LK.stageContainer.x = LK.stageContainer.width / 2;
LK.stageContainer.y = LK.stageContainer.height / 2;
LK.setTimeout(function () {
LK.stageContainer.scale.x = 1;
LK.stageContainer.scale.y = 1;
LK.stageContainer.pivot.x = 0;
LK.stageContainer.pivot.y = 0;
LK.stageContainer.x = 0;
LK.stageContainer.y = 0;
}, 3000);
};
self.makeVillagerDecisions = function (villager) {
if (!villager.currentAction) {
villager.decideNextAction();
}
};
LK.on('tick', function () {
if (self.villagerAndFramerateDisplay) self.framerateDisplay.update();
var currentTime = Date.now();
var elapsedTime = Math.floor((currentTime - self.startTime) / 1000);
self.timerText.setText('Time: ' + elapsedTime);
for (var i = 0; i < self.villagers.length; i++) {
var villager = self.villagers[i];
villager.updateStateAndPosition();
self.makeVillagerDecisions(villager);
}
self.handleVillagersFallingInLove();
});
self.timerText = new Text2('Time: 0', {
size: 100,
fill: "#ffffff"
});
self.timerText.anchor.set(1, 1);
self.timerText.x = 2048 - 500;
self.timerText.y = 2732;
LK.gui.topCenter.addChild(self.timerText);
self.startTime = Date.now();
var inn = new Inn();
self.addChild(inn);
var bakery = new Bakery();
self.addChild(bakery);
var well = new Well();
self.addChild(well);
self.resources = createResources();
self.resourceDisplay = new ResourceDisplay(self.resources);
LK.gui.addChild(self.resourceDisplay);
Game.prototype.handleVillagersFallingInLove = function () {
for (var i = 0; i < this.villagers.length; i++) {
for (var j = i + 1; j < this.villagers.length; j++) {
var villagerA = this.villagers[i];
var villagerB = this.villagers[j];
}
}
};
function createResources() {
return {
wood: new WoodResource(100),
rock: new RockResource(100),
food: new FoodResource(100)
};
}
Villager.prototype.setAge = function (isBaby) {
if (isBaby) {
this.scale.x = 0.5;
this.scale.y = 0.5;
} else {
this.scale.x = 1;
this.scale.y = 1;
}
};
Game.prototype.addVillager = function (isBaby, iq, x, y) {
var villager = this.villagerFactory.initializeAndAddVillager(isBaby, iq, x, y);
this.initializeVillagerProperties(villager);
this.registerVillager(villager);
};
Game.prototype.initializeVillagerProperties = function (villager) {
villager.speed = 6;
villager.energy = 100;
villager.tiredness = 0;
villager.state = 'idle';
villager.home = null;
villager.workplace = null;
villager.currentAction = null;
villager.targetX = null;
villager.targetY = null;
};
self.villagers = self.villagers || [];
self.houses = [];
self.cloudLayer = new Container();
self.clouds = [];
self.villagerFactory = new VillagerFactory(self.resources);
for (var i = 0; i < 10; i++) {
self.createAndAddVillager();
}
for (var i = 0; i < 20; i++) {
var iq = Math.random() * 50 + 50;
var x = Math.random() * 2048;
var y = Math.random() * 2732;
var villager = this.villagerFactory.initializeAndAddVillager(false, iq, x, y);
this.initializeVillagerProperties(villager);
this.registerVillager(villager);
}
self.market = new Market();
self.addChild(self.market);
Game.prototype.createHouse = function (x, y) {
var house = new Home();
house.x = x;
house.y = y;
return house;
};
Game.prototype.addHouse = function (house) {
this.addChild(house);
this.houses.push(house);
};
var houses = [];
var newHouse = self.createHouse(2048 / 2, 2732 / 2);
self.addHouse(newHouse);
houses.push(newHouse);
Game.prototype.createWorkplace = function () {
var workplace = new EmployingWorkPlace();
workplace.x = Math.random() * 2048;
workplace.y = Math.random() * 2732;
return workplace;
};
Game.prototype.addWorkplace = function (workplace) {
this.addChild(workplace);
this.workplaces.push(workplace);
};
self.workplaces = [];
var workplace = self.createWorkplace();
self.addWorkplace(workplace);
self.workplaces.push(workplace);
var wood = new Wood();
wood.x = 2048 / 2;
wood.y = 2732 / 2 - 400;
self.addChild(wood);
var rock = new Rock();
rock.x = 2048 / 2 + 100;
rock.y = 2732 / 2 - 300;
self.addChild(rock);
var workplace = new EmployingWorkPlace();
workplace.x = Math.random() * 2048;
workplace.y = Math.random() * 2732;
self.workplaces.push(workplace);
self.addChild(workplace);
self.villagerCreationInterval = LK.setInterval(self.createAndAddVillagerIfPossible.bind(self), 10000);
var initialRock = new Rock();
initialRock.x = 1024;
initialRock.y = 1366;
self.addChild(initialRock);
var initialFood = new Food();
initialFood.x = 1024;
initialFood.y = 1566;
self.addChild(initialFood);
var villager1 = new Villager(self.resources, 100);
villager1.x = 500;
villager1.y = 500;
self.addChild(villager1);
self.villagers.push(villager1);
var villager2 = new Villager(self.resources, 100);
villager2.x = 600;
villager2.y = 600;
self.addChild(villager2);
self.villagers.push(villager2);
var home = new Home();
home.x = 700;
home.y = 700;
self.addChild(home);
var inn = new Inn();
inn.x = 900;
inn.y = 900;
self.addChild(inn);
var bakery = new Bakery();
bakery.x = 1000;
bakery.y = 1000;
self.addChild(bakery);
var well = new Well();
well.x = 1100;
well.y = 1100;
self.addChild(well);
var gardener = new Gardener();
gardener.x = 1200;
gardener.y = 1200;
self.addChild(gardener);
var festival = new Festival();
festival.x = 1300;
festival.y = 1300;
self.addChild(festival);
var house = new House();
house.x = 1400;
house.y = 1400;
self.addChild(house);
var employingWorkPlace = new EmployingWorkPlace();
employingWorkPlace.x = 1500;
employingWorkPlace.y = 1500;
self.addChild(employingWorkPlace);
});
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.