summaryrefslogtreecommitdiff
path: root/scripts/HexSpace.gd
blob: c8269fd481c1f651ecad150eb554e589807ed01c (plain)
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
42
43
44
45
46
47
48
49
50
tool
extends StaticBody

var cell_type : String = "normal"

# airport variables
var airport_number : int
var airport_color : Color
var airport_id : int
# cell offsets that describe valid approaches based on runways and surroundings
# used to choose a takeoff position
const bearings = [ [0,1] , [-1, 0], [-1, -1], [0, -1], [1, 0], [1, 1] ]
var valid_approaches = []
var valid_bearings = []



func _ready():
	pass

func set_up(tile_type, settings={}):
	valid_bearings = [] # reset
	cell_type = tile_type
	
	if settings["rotation"]: # bearing according to E, NE, etc. 
		self.global_rotation.y = settings["rotation"] * deg2rad(60)
	
	if tile_type == "hills":
		$Hills.visible = true
	elif tile_type == "mountain":
		$Mountain.visible = true
	elif tile_type == "airport":
		$Airport.visible = true
		
		airport_number = settings["airport_number"]
		airport_color = settings["airport_color"]
		valid_approaches = settings["valid_approaches"]
		for approach in valid_approaches:
			var bearing_i = bearings.find(approach)
			valid_bearings.push_back(bearings[bearing_i])
		airport_id = settings["airport_id"]
		
		$Airport/AirportIcon.texture = load("res://textures/airport_indicator_%d.png" % airport_number)
		$Airport/AirportIcon.modulate = airport_color
		
		if settings["difficulty"] == "easy": return
		$Airport/EasyRunway.visible = false
		if settings["difficulty"] == "hard":
			$Airport/MediumRunway.visible = false