solarpanel
This commit is contained in:
parent
8c66cb2901
commit
89bc084f43
5 changed files with 28 additions and 6 deletions
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 820 B |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2 KiB |
14
src/entities/solarpanel.coffee
Normal file
14
src/entities/solarpanel.coffee
Normal file
|
@ -0,0 +1,14 @@
|
|||
class Solarpanel
|
||||
tick: (tile)->
|
||||
|
||||
sprite: ->
|
||||
[0, 8*3, 8, 8]
|
||||
|
||||
spritedetail: ->
|
||||
[0, 16*3, 16, 16]
|
||||
|
||||
isMoveable: ->
|
||||
false
|
||||
|
||||
spaceProvided: 0
|
||||
isDockable: true
|
|
@ -64,6 +64,7 @@ app.game =
|
|||
keyup: (event) ->
|
||||
switch event.key
|
||||
when "m" then @createMiner()
|
||||
when "e" then @createSolarpanel()
|
||||
when "i" then app.game.hud.showBuildInfo()
|
||||
when "s" then @createSilo()
|
||||
when "c" then @cheatah()
|
||||
|
@ -88,13 +89,21 @@ app.game =
|
|||
if @checkPosition(@currentSelectedTile)
|
||||
if @checkResource('stardust', 20, true)
|
||||
@currentSelectedTile.entity = new Silo
|
||||
else
|
||||
@speechbubble.say 'nores'
|
||||
else
|
||||
@speechbubble.say 'nores'
|
||||
else
|
||||
@speechbubble.say 'toofar'
|
||||
else
|
||||
@speechbubble.say 'nosel'
|
||||
|
||||
# TODO: OMG refactor this ...
|
||||
createSolarpanel: ->
|
||||
if @currentSelectedTile
|
||||
if @checkPosition(@currentSelectedTile)
|
||||
if @checkResource('notch', 10, true)
|
||||
@currentSelectedTile.entity = new Solarpanel
|
||||
else
|
||||
@speechbubble.say 'nores'
|
||||
else
|
||||
@speechbubble.say 'toofar'
|
||||
checkResource: (type, amount, drain = false) ->
|
||||
if @resources[type] >= amount
|
||||
@resources[type] -= amount if drain
|
||||
|
|
|
@ -28,12 +28,11 @@ app.game.hud =
|
|||
if currentSelectedTile != null
|
||||
panelusage = 'tile'
|
||||
|
||||
|
||||
if currentSelectedTile.entity
|
||||
panelusage = 'entity'
|
||||
app.layer.drawRegion app.images.entitydetails, currentSelectedTile.entity.spritedetail(), 12, 95
|
||||
else
|
||||
app.layer.drawRegion app.images.layerdetails, currentSelectedTile.getCurrentLayer().spritedetail, 12, 95
|
||||
app.layer.drawRegion app.images.layerdetails, currentSelectedTile.getCurrentLayer().spritedetail, 1, 95
|
||||
|
||||
# silo capacity
|
||||
usedSiloStoragePercent = Math.round((100 / app.game.availableSiloStorage()) * app.game.usedSiloStorage())
|
||||
|
|
Loading…
Reference in a new issue