From 251c7c673542a2a459fa79fc84a703df01dada65 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 17 Feb 2018 01:21:46 -0500 Subject: [PATCH] Color Hero 1 walls according to friendliness! --- scenes/wall.tscn | 5 ++++- scripts/heroes/0-wall.gd | 20 ++++++++++++++++++++ scripts/heroes/1.gd | 11 +++++++++-- scripts/player.gd | 9 ++++----- 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 scripts/heroes/0-wall.gd diff --git a/scenes/wall.tscn b/scenes/wall.tscn index d898bf2..9db4c98 100644 --- a/scenes/wall.tscn +++ b/scenes/wall.tscn @@ -1,4 +1,6 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://scripts/heroes/0-wall.gd" type="Script" id=1] [sub_resource type="CubeMesh" id=1] @@ -21,6 +23,7 @@ friction = 1.0 bounce = 0.0 constant_linear_velocity = Vector3( 0, 0, 0 ) constant_angular_velocity = Vector3( 0, 0, 0 ) +script = ExtResource( 1 ) [node name="MeshInstance" type="MeshInstance" parent="." index="0"] diff --git a/scripts/heroes/0-wall.gd b/scripts/heroes/0-wall.gd new file mode 100644 index 0000000..01229f6 --- /dev/null +++ b/scripts/heroes/0-wall.gd @@ -0,0 +1,20 @@ +extends StaticBody + +# class member variables go here, for example: +# var a = 2 +# var b = "textvar" + +func _ready(): + # Called every time the node is added to the scene. + # Initialization here + pass + +func set_color(color): + var mat = SpatialMaterial.new() + mat.albedo_color = color + get_node("MeshInstance").set_surface_material(0, mat) + +#func _process(delta): +# # Called every frame. Delta is time since last frame. +# # Update game logic here. +# pass diff --git a/scripts/heroes/1.gd b/scripts/heroes/1.gd index 6ee928b..2c40963 100644 --- a/scripts/heroes/1.gd +++ b/scripts/heroes/1.gd @@ -8,7 +8,7 @@ const max_walls = 7 func _process(delta): if is_network_master(): - + if Input.is_action_just_pressed("hero_1_place_wall"): # Press button twice to cancel if is_placing_wall: @@ -36,6 +36,10 @@ func _process(delta): placing_wall_node = null is_placing_wall = false +func _exit_tree(): + for wall in walls: + wall.queue_free() + slave func slave_place_wall(tf): var wall = add_wall() finalize_wall(wall, tf) @@ -43,6 +47,9 @@ slave func slave_place_wall(tf): # Creates wall, adds to world, and returns the node func add_wall(): var wall = preload("res://scenes/wall.tscn").instance() + var friendly = player_info.is_right_team == master_player.player_info.is_right_team + var color = friend_color if friendly else enemy_color + wall.set_color(color) get_node("/root/Level").add_child(wall) return wall @@ -60,4 +67,4 @@ func check_wall_count(): # If we've made max_walls, remove the first we made if walls.size() > max_walls: walls[0].queue_free() - walls.pop_front() \ No newline at end of file + walls.pop_front() diff --git a/scripts/player.gd b/scripts/player.gd index 2816de8..29a4fbd 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -32,6 +32,8 @@ var tp_camera = "TPCamera" var master_only = "MasterOnly" var master_player +var friend_color = Color("#073a98") # Blue +var enemy_color = Color("#62071a") # Red var ai_instanced = false @@ -104,9 +106,9 @@ func begin(): # Set color to blue (teammate) or red (enemy) var color if master_player.player_info.is_right_team == player_info.is_right_team: - color = Color("#073a98") # Blue for friendly + color = friend_color else: - color = Color("#62071a") # Red for enemy + color = enemy_color var mat = SpatialMaterial.new() mat.albedo_color = color get_node("Yaw/MainMesh").set_surface_material(0, mat) @@ -256,9 +258,6 @@ sync func switch_hero(hero): new_hero.call_deferred("set_status", get_status()) queue_free() -func _exit_scene(): - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - func _exit_tree(): if "record" in player_info: write_recording()