2019-07-28 13:32:28 +02:00
|
|
|
extends Spatial
|
|
|
|
|
|
|
|
class_name BaseInventory
|
|
|
|
|
|
|
|
var road_straights = [
|
2019-08-07 20:29:46 +02:00
|
|
|
roads_factory.BUMP,
|
|
|
|
roads_factory.BUMP_SMALL,
|
|
|
|
roads_factory.STRAIGHT,
|
|
|
|
roads_factory.STRAIGHT_SMALL,
|
2019-07-28 13:32:28 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
var roads_right = [
|
2019-08-07 20:29:46 +02:00
|
|
|
roads_factory.CURVE_RIGHT,
|
|
|
|
roads_factory.CURVE_LARGE_RIGHT,
|
|
|
|
roads_factory.CURVE_SMALL_RIGHT,
|
|
|
|
roads_factory.SKEW_RIGHT,
|
2019-07-28 13:32:28 +02:00
|
|
|
roads_factory.CURVED_RIGHT,
|
|
|
|
]
|
|
|
|
|
|
|
|
var roads_left = [
|
2019-08-07 20:29:46 +02:00
|
|
|
roads_factory.CURVE_LEFT,
|
|
|
|
roads_factory.CURVE_LARGE_LEFT,
|
|
|
|
roads_factory.CURVE_SMALL_LEFT,
|
|
|
|
roads_factory.SKEW_LEFT,
|
|
|
|
roads_factory.CURVED_LEFT,
|
2019-07-28 13:32:28 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
var roads_up = [
|
2019-08-07 20:29:46 +02:00
|
|
|
roads_factory.RAMP_UP,
|
|
|
|
roads_factory.RAMP_CURVED_UP,
|
|
|
|
roads_factory.RAMP_SMALL_UP,
|
|
|
|
]
|
2019-07-28 13:32:28 +02:00
|
|
|
|
|
|
|
var roads_down = [
|
|
|
|
roads_factory.RAMP_DOWN,
|
|
|
|
roads_factory.RAMP_CURVED_DOWN,
|
|
|
|
roads_factory.RAMP_SMALL_DOWN,
|
2019-08-07 20:29:46 +02:00
|
|
|
]
|
2019-07-28 13:32:28 +02:00
|
|
|
|
|
|
|
var roads_special = [
|
|
|
|
roads_factory.LOOP,
|
|
|
|
]
|
|
|
|
|
|
|
|
var roads = [ road_straights, roads_right, roads_left, roads_up, roads_down, roads_special ]
|
|
|
|
|
|
|
|
var player:Player
|
|
|
|
var route:Route
|
|
|
|
var item:Road
|
|
|
|
var type:int = 0
|
|
|
|
var index:int = 0
|
|
|
|
|
|
|
|
signal item_changed(index, player)
|
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
route = gamestate.game.route
|
|
|
|
|
|
|
|
|
|
|
|
func set_player(new_player:Player):
|
|
|
|
player = new_player
|
|
|
|
|
|
|
|
|
|
|
|
func set_item():
|
|
|
|
if is_network_master():
|
|
|
|
if item:
|
|
|
|
item.free()
|
|
|
|
item = roads_factory.get_road_instance(roads[type][index])
|
2019-08-07 20:29:46 +02:00
|
|
|
|
2019-07-28 13:32:28 +02:00
|
|
|
if player != null:
|
|
|
|
item.set_color(player.get_player_color())
|
2019-08-07 20:29:46 +02:00
|
|
|
|
2019-07-28 13:32:28 +02:00
|
|
|
item.rotate_y(PI/2)
|
2019-08-07 20:29:46 +02:00
|
|
|
|
2019-07-28 13:32:28 +02:00
|
|
|
emit_signal("item_changed", roads[type][index], player)
|