@ -206,43 +206,209 @@ let game = new Vue({
} ,
} ,
currentQuest : null ,
currentQuest : null ,
questSkipCounter : 0 ,
questSkipCounter : 0 ,
loadedIntervals : [ ]
loadedIntervals : [ ] ,
selectedBuilding : null ,
selectedDecoration : null ,
selection : null ,
modalBuilding : null ,
mapDecorations : [
{
path : 'img/tiles/environment/birch_small.png' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/birch_large.png' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/spruce_small.png' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/spruce_large.png' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/bush.png' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/bush_berries.png' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/stone.png' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/stone_0.png' ,
name : 'Stone 1' ,
price : 50
} ,
{
path : 'img/tiles/environment/stone_1.png' ,
name : 'Stone 2' ,
price : 50
} ,
{
path : 'img/tiles/environment/stone_3.png' ,
name : 'Stone 3' ,
price : 50
} ,
{
path : 'img/tiles/dummy/dummy' ,
name : 'dummy' ,
price : 50
} ,
{
path : 'img/tiles/environment/wood_log.png' ,
name : 'Log' ,
price : 50
} ,
] ,
roads : [
{
path : 'img/tiles/roads/corner_n_o.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/corner_n_w.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/corner_o_s.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/corner_s_w.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/cross.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/end_n.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/end_o.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/end_s.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/end_w.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/straight_n_s.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/straight_o_w.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/t_n_o_s.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/t_n_o_w.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/t_n_s_w.png' ,
name : 'Log' ,
price : 50
} ,
{
path : 'img/tiles/roads/t_o_s_w.png' ,
name : 'Log' ,
price : 50
} ,
]
} ,
} ,
created ( ) {
created ( ) {
this . generateMap ( 100 , 50 ) ;
let game = this ;
this . setTile ( 1 , 1 , {
this . generateMap ( 10 , 10 ) ;
asset : 'img/tiles/environment/birch_large.png'
} ) ;
$ ( function ( ) {
this . setTile ( 1 , 2 , {
$ ( '[data-toggle="tooltip"]' ) . tooltip ( )
asset : 'img/tiles/environment/birch_large.png'
} ) ;
this . setTile ( 2 , 1 , {
asset : 'img/tiles/environment/birch_large.png'
} ) ;
this . setTile ( 2 , 2 , {
asset : 'img/tiles/structure/house.png' ,
building : 'lumberjack'
} ) ;
} ) ;
this . setTile ( 5 , 4 , {
asset : 'img/tiles/structure/blacksmith.png' ,
$ ( '#buildingModal' ) . on ( 'close.bs.modal' , function ( event ) {
building : 'blacksmith'
game . modalBuilding = null ;
} ) ;
} ) ;
// this.storageNames = {
this . storageNames = {
// lastVersion: 'lastVersion',
lastVersion : 'lastVersion' ,
// resources: 'resources' + this.version,
resources : 'resources' + this . version ,
// buildings: 'buildings' + this.version,
buildings : 'buildings' + this . version ,
// }
}
//
// this.checkVersion();
this . checkVersion ( ) ;
//
// this.checkBuildings();
this . checkBuildings ( ) ;
// this.loadResourcesFromStorage();
this . loadResourcesFromStorage ( ) ;
// this.loadBuildingsFromStorage();
this . loadBuildingsFromStorage ( ) ;
// this.reloadBuildings();
this . reloadBuildings ( ) ;
} ,
} ,
methods : {
methods : {
// Map generation
// Map system
getResourcesNeededToBuildText ( building ) {
let game = this ;
let message = '' ;
if ( building . resourcesToBuild ) {
Object . keys ( building . resourcesToBuild ) . forEach ( ( resourceName , resourceAmount ) => {
if ( message . length > 0 ) {
message += ', '
}
message += building . resourcesToBuild [ resourceName ] + ' ' + game . resources [ resourceName ] . name ;
} ) ;
} else {
message += building . price + '<img class="resource-icon" src="img/gold.png"/>' ;
}
return message ;
} ,
initiateBuilding ( building ) {
this . selection = {
building : building
} ;
} ,
selectDecoration ( item ) {
this . selection = {
decoration : item
} ;
} ,
generateMap ( rows , cols ) {
generateMap ( rows , cols ) {
let map = [ ] ;
let map = [ ] ;
@ -266,9 +432,31 @@ let game = new Vue({
this . map [ x - 1 ] [ y - 1 ] = tile ;
this . map [ x - 1 ] [ y - 1 ] = tile ;
} ,
} ,
interactWithTile ( tile ) {
interactWithTile ( tile , x , y ) {
if ( game . selection ) {
if ( game . selection . building ) {
tile . asset = 'img/tiles/structure/' + game . selection . building . name . toLowerCase ( ) + '.png' ;
tile . building = game . selection . building . name . toLowerCase ( ) ;
this . selection = null ;
}
if ( game . selection . decoration ) {
tile . asset = game . selection . decoration . path ;
tile . building = null ;
// decorations can only be cancelled by cancel button
}
if ( game . selection . bulldozer ) {
tile . asset = 'img/tiles/trans.png' ;
tile . building = null ;
// bulldozer can only be cancelled by cancel button
}
}
if ( tile . building ) {
if ( tile . building ) {
this . sendNotification ( tile . building ) ;
this . modalBuilding = this . buildings [ tile . building ] ;
$ ( '#buildingModal' ) . modal ( 'show' ) ;
this . $forceUpdate ( ) ;
}
}
} ,
} ,