added game states
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://j06vthscroca"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://j06vthscroca"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bm80w1xsgge1i" path="res://Blends/Bullet/bullet.gltf" id="1_xjght"]
|
||||
[ext_resource type="Script" uid="uid://bckkey7836cjp" path="res://Scripts/bullet.gd" id="2_oduel"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_oduel"]
|
||||
size = Vector3(0.039157, 0.0783691, 0.0383301)
|
||||
|
||||
[node name="bullet" instance=ExtResource("1_xjght")]
|
||||
script = ExtResource("2_oduel")
|
||||
|
||||
[node name="Cylinder" parent="." index="0"]
|
||||
transform = Transform3D(0.02, 0, 0, 0, 0.02, 0, 0, 0, 0.02, 0, 0, 0)
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." index="1"]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="0"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00286226, 0.00549316, 0.000634715)
|
||||
shape = SubResource("BoxShape3D_oduel")
|
||||
|
||||
[connection signal="input_event" from="StaticBody3D" to="." method="_on_static_body_3d_input_event"]
|
||||
|
||||
@@ -15,7 +15,6 @@ transform = Transform3D(1, 0, 0, 0, 0.960866, 0.277013, 0, -0.277013, 0.960866,
|
||||
h_offset = -0.33
|
||||
v_offset = -0.47
|
||||
current = true
|
||||
fov = 12.3
|
||||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 6.13189, 0)
|
||||
@@ -29,14 +28,26 @@ transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.0599
|
||||
transform = Transform3D(-0.1, -8.74228e-09, 0, 8.74228e-09, -0.1, 0, 0, 0, 0.1, 0.354285, 4.2476, 0.425178)
|
||||
is_player_revolver = true
|
||||
|
||||
[node name="Cylinder_002" parent="revolver" index="1"]
|
||||
transform = Transform3D(0.388665, 1.69891e-08, 0.673188, 0.673188, -2.9426e-08, -0.388665, 1.69891e-08, 0.77733, -2.9426e-08, 0.0429976, 0.542699, 3.97893)
|
||||
|
||||
[node name="BulletStack" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.09463, 3.35364, -0.941887)
|
||||
script = ExtResource("4_kry3j")
|
||||
|
||||
[node name="bullet2" parent="BulletStack" instance=ExtResource("3_8gbba")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0812991, -0.0193229, 0.00827265)
|
||||
|
||||
[node name="bullet" parent="BulletStack" instance=ExtResource("3_8gbba")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000887632, -0.00966144, 0.00413632)
|
||||
|
||||
[node name="bullet3" parent="BulletStack" instance=ExtResource("3_8gbba")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.172968, -0.0193229, 0.0478075)
|
||||
|
||||
[node name="bullet4" parent="BulletStack" instance=ExtResource("3_8gbba")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.20906, -0.0193229, 0.168294)
|
||||
|
||||
[node name="bullet5" parent="BulletStack" instance=ExtResource("3_8gbba")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.126874, -0.00966144, 0.164157)
|
||||
|
||||
[node name="bullet6" parent="BulletStack" instance=ExtResource("3_8gbba")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.300729, -0.0193229, 0.207828)
|
||||
|
||||
[editable path="revolver"]
|
||||
|
||||
@@ -27,3 +27,8 @@ func moveTo(target_pos: Vector3):
|
||||
func on_target_reached():
|
||||
print("Target Reached")
|
||||
is_target_reached = true
|
||||
|
||||
|
||||
func _on_static_body_3d_input_event(camera: Node, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) -> void:
|
||||
if event.is_action_released("left_mouse_click"):
|
||||
GameManager.bullet_selected.emit(self)
|
||||
|
||||
@@ -10,7 +10,7 @@ var v_offset: float = 0.1
|
||||
|
||||
func _ready() -> void:
|
||||
GameManager.set_bullet_stack(self)
|
||||
generate_bullet_stack()
|
||||
#generate_bullet_stack()
|
||||
|
||||
func generate_bullet_stack():
|
||||
for i in range(1, 22, 1):
|
||||
@@ -18,3 +18,6 @@ func generate_bullet_stack():
|
||||
newBullet.position = Vector3(i*h_offset,0,0)
|
||||
bullets.append(newBullet)
|
||||
add_child(newBullet)
|
||||
|
||||
func add_bullets():
|
||||
pass
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
extends Node
|
||||
|
||||
|
||||
signal bullet_selected(object)
|
||||
|
||||
enum GameState { PLAYER1_GUN_LOAD, PLAYER2_GUN_LOAD, GUN_ANIMATION}
|
||||
var current_state = GameState.PLAYER1_GUN_LOAD
|
||||
var bullets: Array
|
||||
|
||||
var player1_revolver: Node3D
|
||||
@@ -8,6 +13,7 @@ var bullet_stack: Node3D
|
||||
|
||||
func _ready() -> void:
|
||||
bullets.resize(21)
|
||||
bullet_selected.connect(on_bullet_selected)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_released("load"):
|
||||
@@ -24,3 +30,14 @@ func set_bullet_stack(newStack):
|
||||
|
||||
func add_bullet():
|
||||
pass
|
||||
|
||||
|
||||
func on_bullet_selected(bullet_object: Node3D):
|
||||
if current_state == GameState.PLAYER1_GUN_LOAD:
|
||||
current_state = GameState.GUN_ANIMATION
|
||||
player1_revolver.load_bullet(bullet_object)
|
||||
|
||||
|
||||
func end_turn():
|
||||
if current_state == GameState.PLAYER1_GUN_LOAD:
|
||||
current_state = GameState.PLAYER2_GUN_LOAD
|
||||
|
||||
@@ -12,7 +12,7 @@ var timer: Timer
|
||||
|
||||
var is_cylinder_out: bool = false
|
||||
func _ready() -> void:
|
||||
loaded_bullets.resize(6)
|
||||
loaded_bullets.resize(max_bullets + 1)
|
||||
timer = $Timer
|
||||
if is_player_revolver:
|
||||
GameManager.set_player_revolver(self)
|
||||
@@ -34,13 +34,12 @@ func load_bullet(bullet_object: Node3D):
|
||||
bullet_object.rotate_x(deg_to_rad(-90))
|
||||
is_cylinder_out = true
|
||||
bullet_object.reparent(cylinder)
|
||||
print_tree()
|
||||
timer.timeout.connect(on_load_anim_end)
|
||||
#cylinder.rotation.x = 90.0
|
||||
|
||||
func on_load_anim_end():
|
||||
is_cylinder_out = false
|
||||
|
||||
GameManager.end_turn()
|
||||
timer.timeout.disconnect(on_load_anim_end)
|
||||
|
||||
func on_bullet_reached():
|
||||
|
||||
@@ -31,3 +31,8 @@ load2={
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
left_mouse_click={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(290, 15),"global_position":Vector2(299, 63),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user