can't click on dead tiles

This commit is contained in:
Aaron Mueller 2014-12-07 16:27:44 +01:00
parent 656547aacd
commit b510790ef8
2 changed files with 9 additions and 3 deletions

View file

@ -5,8 +5,7 @@ app.game =
@map[20*5+10].entity = new Base
@mouseX = 0
@mouseY = 0
@mouseY = 0
@currentHoveredTile = new Tile(-1)
@currentSelectedTile = null
@ -23,10 +22,14 @@ app.game =
@speechbubble.render()
mousedown: (event)->
tile = posToTile(Math.floor(event.x/8), Math.floor(event.y/8))
# Can't click on dead tiles
return unless tile and tile.isBuildable
if @isMouseInView event.x/8, event.y/8
switch event.button
when 'left'
tile = posToTile(Math.floor(event.x/8), Math.floor(event.y/8))
tile.click(event.button)
@currentSelectedTile.deselect() if @currentSelectedTile

View file

@ -16,6 +16,9 @@ class Tile
@randomSeed = Math.round(Math.random()*10)
click: (button)->
# Some tiles are not buildable
return unless @isBuildable
if button == "left"
if (app.game.availableSiloStorage() - app.game.usedSiloStorage()) > 0
if @layers[@currentLayer].collect()