diff options
Diffstat (limited to 'scripts/HexSpace.gd')
| -rw-r--r-- | scripts/HexSpace.gd | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/HexSpace.gd b/scripts/HexSpace.gd new file mode 100644 index 0000000..c8269fd --- /dev/null +++ b/scripts/HexSpace.gd @@ -0,0 +1,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 + |
