Fix Card Selection Menu, Pause
parent
bbe9a17cfa
commit
ccac9da653
|
@ -48,8 +48,12 @@ func _physics_process(delta):
|
|||
$Sprite.global_position.y += sin(Time.get_ticks_msec() * 0.01) / 3
|
||||
|
||||
velocity *= speed * speed_multiplier
|
||||
if Global.playing:
|
||||
$Sprite.playing = true
|
||||
if not shooting:
|
||||
velocity = move_and_slide(velocity)
|
||||
else:
|
||||
$Sprite.playing = false
|
||||
|
||||
func _shoot():
|
||||
sonic_wave = sonic_wave_preload.instance()
|
||||
|
|
|
@ -124,7 +124,6 @@ visible = false
|
|||
position = Vector2( 11, 2 )
|
||||
frames = ExtResource( 5 )
|
||||
animation = "idle"
|
||||
frame = 3
|
||||
playing = true
|
||||
|
||||
[node name="AudioGetDamage" type="AudioStreamPlayer" parent="."]
|
||||
|
|
|
@ -138,7 +138,7 @@ func _physics_process(delta):
|
|||
|
||||
choose_target()
|
||||
|
||||
if target != null and is_instance_valid(target) and not target.dead:
|
||||
if Global.playing and target != null and is_instance_valid(target) and not target.dead:
|
||||
target.material = outline_material
|
||||
|
||||
if recharge_timer >= get_recharge():
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=28 format=2]
|
||||
[gd_scene load_steps=29 format=2]
|
||||
|
||||
[ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2]
|
||||
|
@ -6,6 +6,7 @@
|
|||
[ext_resource path="res://res/themes/8px.tres" type="Theme" id=4]
|
||||
[ext_resource path="res://src/models/player/Player.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://src/scenes/game/sprites/health/health.png" type="Texture" id=6]
|
||||
[ext_resource path="res://src/scenes/game/card_placeholder.gd" type="Script" id=8]
|
||||
[ext_resource path="res://src/scenes/game/sprites/player_icon.png" type="Texture" id=10]
|
||||
[ext_resource path="res://src/scenes/game/game.gd" type="Script" id=11]
|
||||
[ext_resource path="res://src/scenes/game/sprites/ui_background.png" type="Texture" id=12]
|
||||
|
@ -153,10 +154,12 @@ color = Color( 0.133333, 0.133333, 0.137255, 1 )
|
|||
|
||||
[node name="UIWrapper" type="CanvasLayer" parent="."]
|
||||
layer = 3
|
||||
follow_viewport_enable = true
|
||||
|
||||
[node name="UI" type="Control" parent="UIWrapper"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 180.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Background" type="TextureRect" parent="UIWrapper/UI"]
|
||||
margin_top = 120.0
|
||||
|
@ -252,36 +255,47 @@ margin_right = 40.0
|
|||
margin_bottom = 40.0
|
||||
|
||||
[node name="Cards" type="Control" parent="UIWrapper/UI"]
|
||||
visible = false
|
||||
margin_right = 320.0
|
||||
margin_bottom = 120.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="LeftPlaceholder" type="Control" parent="UIWrapper/UI/Cards"]
|
||||
[node name="LeftPlaceholder" type="Control" parent="UIWrapper/UI/Cards" groups=["card_placeholder"]]
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = 102.0
|
||||
margin_bottom = 111.0
|
||||
mouse_filter = 1
|
||||
script = ExtResource( 8 )
|
||||
|
||||
[node name="Card" parent="UIWrapper/UI/Cards/LeftPlaceholder" instance=ExtResource( 18 )]
|
||||
|
||||
[node name="CenterPlaceholder" type="Control" parent="UIWrapper/UI/Cards"]
|
||||
[node name="CenterPlaceholder" type="Control" parent="UIWrapper/UI/Cards" groups=["card_placeholder"]]
|
||||
margin_left = 113.0
|
||||
margin_top = 8.0
|
||||
margin_right = 207.0
|
||||
margin_bottom = 111.0
|
||||
mouse_filter = 1
|
||||
script = ExtResource( 8 )
|
||||
id = 1
|
||||
|
||||
[node name="Card" parent="UIWrapper/UI/Cards/CenterPlaceholder" instance=ExtResource( 18 )]
|
||||
|
||||
[node name="RightPlaceholder" type="Control" parent="UIWrapper/UI/Cards"]
|
||||
[node name="RightPlaceholder" type="Control" parent="UIWrapper/UI/Cards" groups=["card_placeholder"]]
|
||||
margin_left = 218.0
|
||||
margin_top = 8.0
|
||||
margin_right = 312.0
|
||||
margin_bottom = 111.0
|
||||
mouse_filter = 1
|
||||
script = ExtResource( 8 )
|
||||
id = 2
|
||||
|
||||
[node name="Card" parent="UIWrapper/UI/Cards/RightPlaceholder" instance=ExtResource( 18 )]
|
||||
|
||||
[node name="Gameover" type="Control" parent="UIWrapper/UI"]
|
||||
margin_right = 320.0
|
||||
margin_bottom = 180.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="UIWrapper/UI/Gameover"]
|
||||
modulate = Color( 1, 1, 1, 0 )
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
extends Control
|
||||
|
||||
export var id: int
|
||||
onready var game = get_tree().get_root().get_node("Game")
|
||||
|
||||
func _process(delta):
|
||||
if not Global.playing:
|
||||
if game.selected_card == null or game.selected_card == id:
|
||||
self.modulate = Color(1, 1, 1, 1)
|
||||
else:
|
||||
self.modulate = Color(0.2, 0.2, 0.2, 1)
|
||||
|
||||
func _ready():
|
||||
connect("mouse_entered", self, "select_hover", [self])
|
||||
|
||||
func select_hover(node):
|
||||
game.selected_card = id
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
extends Node
|
||||
|
||||
var selected_card = null
|
||||
var difficulty = 0
|
||||
var last_diff = 0
|
||||
var mob_preloads = [
|
||||
|
@ -13,12 +14,18 @@ var mob_threshold = [5, 7, 10, 7]
|
|||
|
||||
func _ready():
|
||||
Global.playing = true
|
||||
Global.play_time = 55
|
||||
Global.play_time = 56
|
||||
Global.health = 5
|
||||
Global.add_health(0)
|
||||
|
||||
func pause():
|
||||
Global.playing = false
|
||||
func _input(event):
|
||||
if not Global.playing:
|
||||
if event is InputEventMouseButton:
|
||||
select_card()
|
||||
if event is InputEventMouseMotion:
|
||||
var pos = event.position
|
||||
if pos.x < 8 or pos.y < 8 or pos.x > 312 or pos.y > 112:
|
||||
selected_card = null
|
||||
|
||||
func _physics_process(delta):
|
||||
if Global.playing:
|
||||
|
@ -29,11 +36,11 @@ func _physics_process(delta):
|
|||
Global.playing = false
|
||||
last_diff = difficulty
|
||||
var cards = range(8)
|
||||
for card_placeholder in $UIWrapper/UI/Cards.get_children():
|
||||
for child in $UIWrapper/UI/Cards.get_children():
|
||||
randomize()
|
||||
card_placeholder.get_node("Card").frame = cards.pop_at(randi()%cards.size())
|
||||
if child.is_in_group("card_placeholder"):
|
||||
child.get_node("Card").frame = cards.pop_at(randi()%cards.size())
|
||||
$UIWrapper/UI/Cards.visible = true
|
||||
#TODO Pause
|
||||
|
||||
$UIWrapper/UI/LevelProgressBar/ColorRect.rect_size.x = (Global.play_time - difficulty * 60) / 60.0 * 300
|
||||
|
||||
|
@ -45,3 +52,7 @@ func _physics_process(delta):
|
|||
var mob_instance = mob_preloads[i].instance()
|
||||
$View/Enemies.add_child(mob_instance)
|
||||
|
||||
func select_card():
|
||||
if selected_card != null:
|
||||
Global.playing = true
|
||||
$UIWrapper/UI/Cards.visible = false
|
||||
|
|
Loading…
Reference in New Issue