extends Node2D enum TileType { None, Sand, Grass, DeepGrass } var TileTypeFromString = { "None": TileType.None, "Sand": TileType.Sand, "Grass": TileType.Grass } var HexPoints = null var HexColors = [] export(Vector2) var hex_scale = Vector2(1, 1) setget set_hex_scale # Called when the node enters the scene tree for the first time. func _ready(): print ("Initialized") set_hex_scale(Vector2(Globals.hex_size,Globals.hex_size)) func set_hex_scale(scale): hex_scale = scale HexPoints = PoolVector2Array() for i in range (7): var angle = (60 * i) * PI / 180 HexPoints.append(Vector2(cos(angle), sin(angle)) * hex_scale.x / 2) var NoneColors = create_color_array ("#885555") var SandColors = create_color_array ("#ffa106") var GrassColors = create_color_array ("#4b9635") var DeepGrassColors = create_color_array ("#2b5d1d") HexColors = { TileType.None: NoneColors, TileType.Sand: SandColors, TileType.Grass: GrassColors, TileType.DeepGrass: DeepGrassColors } func create_color_array(color: Color): var result = PoolColorArray() for _i in range (7): result.append(color) return result func get_tile_color (type_name: String): match type_name: "None": return HexColors[TileType.None] "Sand": return HexColors[TileType.Sand] "Grass": return HexColors[TileType.Grass] "DeepGrass": return HexColors[TileType.DeepGrass] _ : return null