-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTile.gd
41 lines (30 loc) · 1.05 KB
/
Tile.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
extends Node2D
func root():
return get_tree().get_root().get_node("mainNode")
func addStructure(type):
var rootNode = root()
if self.resource != null:
self.remove_child(self.get_node(self.resource))
self.resource = null
self.structure = type
var structureNode = root().tilesTypes.structures[type].instance()
structureNode.set_z(9)
self.add_child(structureNode)
root().structure[type] += 1
if structureNode.has_node("AnimationPlayer"):
structureNode.get_node("AnimationPlayer").play("standard_summon")
rootNode.bought(type)
rootNode.character.refreshOverlap()
func addResource(type):
self.structure = null
self.resource = type
var resourceNode = root().tilesTypes.resources[type].instance()
resourceNode.set_z(9)
self.add_child(resourceNode)
root().character.refreshOverlap()
if resourceNode.has_node("AnimationPlayer"):
resourceNode.get_node("AnimationPlayer").play("standard_structure_appear")
func hasResource(_resource_):
return _resource_ == self.resource
func hasStructure(_structure_):
return _structure_ == self.structure