Add script for dissolve dagger
This commit is contained in:
Binary file not shown.
@@ -1,23 +1,58 @@
|
|||||||
extends Spatial
|
extends Spatial
|
||||||
|
|
||||||
|
const time_max = 3000 # msec
|
||||||
|
|
||||||
|
onready var meshes = {
|
||||||
|
"dagger": {
|
||||||
|
"mesh": $"Main Scene Props/dagger",
|
||||||
|
"value": 0.0,
|
||||||
|
"label": "Dagger",
|
||||||
|
"lock": false,
|
||||||
|
"tick_reference": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
$Dialog/ConfirmEscape.set_title("Quit ?")
|
||||||
|
$Dialog/ConfirmEscape.set_text("Voulez vous vraiment quitté ?")
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
# Event key "escape" and "godot event" ui_end
|
# Event key "escape" and "godot event" ui_end
|
||||||
if Input.is_action_just_pressed("ui_end"):
|
if Input.is_action_just_pressed("ui_end"):
|
||||||
_confirm_before_quit()
|
_confirm_before_quit()
|
||||||
|
|
||||||
|
# Event dissolve in object searched by gamer
|
||||||
|
for mesh in meshes:
|
||||||
|
if meshes[mesh]["lock"] == true and meshes[mesh]["mesh"] != null:
|
||||||
|
if meshes[mesh]["tick_reference"] == null:
|
||||||
|
meshes[mesh]["tick_reference"] = OS.get_ticks_msec()
|
||||||
|
|
||||||
|
if OS.get_ticks_msec() < meshes[mesh]["tick_reference"] + time_max:
|
||||||
|
meshes[mesh]["value"] += 0.01
|
||||||
|
meshes[mesh]["mesh"].get_surface_material(0).set("shader_param/dissolve_amount", meshes[mesh]["value"])
|
||||||
|
else:
|
||||||
|
meshes[mesh]["mesh"].call_deferred("free")
|
||||||
|
meshes[mesh]["mesh"] = null
|
||||||
|
|
||||||
func _notification(what):
|
func _notification(what):
|
||||||
# Notification for android back action
|
# Notification for android back action
|
||||||
if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
|
if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
|
||||||
_confirm_before_quit()
|
_confirm_before_quit()
|
||||||
|
|
||||||
func _confirm_before_quit():
|
func _confirm_before_quit():
|
||||||
var confirm = ConfirmationDialog.new()
|
$Dialog/ConfirmEscape.popup()
|
||||||
confirm.set_title("Quit ?")
|
|
||||||
confirm.set_text("Voulez vous vraiment quitté ?")
|
|
||||||
add_child(confirm)
|
|
||||||
confirm.connect("confirmed", self, "_quit_to_menu")
|
|
||||||
confirm.popup()
|
|
||||||
|
|
||||||
# Back to main scene
|
# Back to main scene
|
||||||
func _quit_to_menu():
|
func _quit_to_menu():
|
||||||
Global.goto_scene("res://scenes/main.tscn")
|
Global.goto_scene("res://scenes/main.tscn")
|
||||||
|
|
||||||
|
# Event when user click/touch dagger
|
||||||
|
func _on_dagger_input_event(camera, event, click_position, click_normal, shape_idx):
|
||||||
|
_initialize_mesh_ref("dagger", event)
|
||||||
|
|
||||||
|
func _initialize_mesh_ref(meshInstance, event):
|
||||||
|
if meshes[meshInstance]["lock"] == false and (event is InputEventMouseButton or event is InputEventScreenTouch):
|
||||||
|
meshes[meshInstance]["lock"] = true
|
||||||
|
|
||||||
|
func _on_ConfirmEscape_confirmed():
|
||||||
|
_quit_to_menu()
|
||||||
|
|||||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=23 format=2]
|
[gd_scene load_steps=25 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets/props/candle/sm_candle_top.mesh" type="ArrayMesh" id=1]
|
[ext_resource path="res://assets/props/candle/sm_candle_top.mesh" type="ArrayMesh" id=1]
|
||||||
[ext_resource path="res://scenes/levels/warcraft/WarCraft.gd" type="Script" id=2]
|
[ext_resource path="res://scenes/levels/warcraft/WarCraft.gd" type="Script" id=2]
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
[ext_resource path="res://scenes/levels/warcraft/WarCraft.lmbake" type="BakedLightmapData" id=16]
|
[ext_resource path="res://scenes/levels/warcraft/WarCraft.lmbake" type="BakedLightmapData" id=16]
|
||||||
[ext_resource path="res://assets/props/candle/sm_candle_d.mesh" type="ArrayMesh" id=17]
|
[ext_resource path="res://assets/props/candle/sm_candle_d.mesh" type="ArrayMesh" id=17]
|
||||||
[ext_resource path="res://assets/props/book/sm_book.mesh" type="ArrayMesh" id=18]
|
[ext_resource path="res://assets/props/book/sm_book.mesh" type="ArrayMesh" id=18]
|
||||||
|
[ext_resource path="res://assets/props/dagger/materials/MA_dagger.material" type="Material" id=19]
|
||||||
|
|
||||||
[sub_resource type="CubeMesh" id=1]
|
[sub_resource type="CubeMesh" id=1]
|
||||||
|
|
||||||
@@ -36,6 +37,8 @@ surfaces/0 = {
|
|||||||
"vertex_count": 66436
|
"vertex_count": 66436
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape" id=5]
|
||||||
|
|
||||||
[sub_resource type="PanoramaSky" id=3]
|
[sub_resource type="PanoramaSky" id=3]
|
||||||
panorama = ExtResource( 11 )
|
panorama = ExtResource( 11 )
|
||||||
|
|
||||||
@@ -212,7 +215,12 @@ material/0 = null
|
|||||||
[node name="dagger" type="MeshInstance" parent="Main Scene Props"]
|
[node name="dagger" type="MeshInstance" parent="Main Scene Props"]
|
||||||
transform = Transform( -0.242904, -0.97005, -4.24022e-08, 0, -4.37114e-08, 1, -0.97005, 0.242904, 1.06177e-08, 0.441892, 0.938817, 0.531178 )
|
transform = Transform( -0.242904, -0.97005, -4.24022e-08, 0, -4.37114e-08, 1, -0.97005, 0.242904, 1.06177e-08, 0.441892, 0.938817, 0.531178 )
|
||||||
mesh = ExtResource( 14 )
|
mesh = ExtResource( 14 )
|
||||||
material/0 = null
|
material/0 = ExtResource( 19 )
|
||||||
|
|
||||||
|
[node name="Area" type="Area" parent="Main Scene Props/dagger"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="Main Scene Props/dagger/Area"]
|
||||||
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
[node name="sm_stool_b2" type="MeshInstance" parent="Main Scene Props"]
|
[node name="sm_stool_b2" type="MeshInstance" parent="Main Scene Props"]
|
||||||
transform = Transform( -0.232037, 0, -0.972707, 0, 1, 0, 0.972707, 0, -0.232037, -2.91873, 0.0130518, 0.702275 )
|
transform = Transform( -0.232037, 0, -0.972707, 0, 1, 0, 0.972707, 0, -0.232037, -2.91873, 0.0130518, 0.702275 )
|
||||||
@@ -338,6 +346,7 @@ material/0 = null
|
|||||||
|
|
||||||
[node name="Red Color Left" type="SpotLight" parent="Lighting"]
|
[node name="Red Color Left" type="SpotLight" parent="Lighting"]
|
||||||
transform = Transform( 0.885702, -0.222818, 0.407289, 0, 0.877297, 0.479948, -0.464255, -0.425091, 0.777023, 0.848516, 1.5034, 2.26553 )
|
transform = Transform( 0.885702, -0.222818, 0.407289, 0, 0.877297, 0.479948, -0.464255, -0.425091, 0.777023, 0.848516, 1.5034, 2.26553 )
|
||||||
|
visible = false
|
||||||
light_color = Color( 1, 0, 0.0862745, 1 )
|
light_color = Color( 1, 0, 0.0862745, 1 )
|
||||||
light_energy = 2.0
|
light_energy = 2.0
|
||||||
light_bake_mode = 2
|
light_bake_mode = 2
|
||||||
@@ -346,11 +355,13 @@ shadow_contact = 1.0
|
|||||||
|
|
||||||
[node name="Blue Color Right" type="SpotLight" parent="Lighting"]
|
[node name="Blue Color Right" type="SpotLight" parent="Lighting"]
|
||||||
transform = Transform( -0.728997, 0.597286, -0.334384, 0.0537007, 0.536893, 0.84194, 0.682407, 0.595815, -0.423468, -0.540161, 1.80711, -0.561909 )
|
transform = Transform( -0.728997, 0.597286, -0.334384, 0.0537007, 0.536893, 0.84194, 0.682407, 0.595815, -0.423468, -0.540161, 1.80711, -0.561909 )
|
||||||
|
visible = false
|
||||||
light_color = Color( 0.8, 0.835294, 1, 1 )
|
light_color = Color( 0.8, 0.835294, 1, 1 )
|
||||||
light_bake_mode = 2
|
light_bake_mode = 2
|
||||||
|
|
||||||
[node name="Blue Color Right2" type="SpotLight" parent="Lighting"]
|
[node name="Blue Color Right2" type="SpotLight" parent="Lighting"]
|
||||||
transform = Transform( -0.721569, 0.418156, -0.5518, -0.680158, -0.577006, 0.452161, -0.129319, 0.701576, 0.700762, -6.73766, 1.80711, 4.06785 )
|
transform = Transform( -0.721569, 0.418156, -0.5518, -0.680158, -0.577006, 0.452161, -0.129319, 0.701576, 0.700762, -6.73766, 1.80711, 4.06785 )
|
||||||
|
visible = false
|
||||||
light_color = Color( 0.905882, 0.862745, 0.72549, 1 )
|
light_color = Color( 0.905882, 0.862745, 0.72549, 1 )
|
||||||
light_specular = 0.23
|
light_specular = 0.23
|
||||||
light_bake_mode = 2
|
light_bake_mode = 2
|
||||||
@@ -359,6 +370,7 @@ spot_angle = 55.8
|
|||||||
|
|
||||||
[node name="Blue Color Right3" type="SpotLight" parent="Lighting"]
|
[node name="Blue Color Right3" type="SpotLight" parent="Lighting"]
|
||||||
transform = Transform( 0.0552331, -0.60583, -0.793675, -0.717326, -0.577006, 0.390522, -0.694545, 0.547754, -0.466447, -6.73826, 1.80435, -3.64354 )
|
transform = Transform( 0.0552331, -0.60583, -0.793675, -0.717326, -0.577006, 0.390522, -0.694545, 0.547754, -0.466447, -6.73826, 1.80435, -3.64354 )
|
||||||
|
visible = false
|
||||||
light_color = Color( 0.905882, 0.862745, 0.72549, 1 )
|
light_color = Color( 0.905882, 0.862745, 0.72549, 1 )
|
||||||
light_specular = 0.64
|
light_specular = 0.64
|
||||||
light_bake_mode = 2
|
light_bake_mode = 2
|
||||||
@@ -367,6 +379,7 @@ spot_angle = 55.8
|
|||||||
|
|
||||||
[node name="Sun" type="DirectionalLight" parent="Lighting"]
|
[node name="Sun" type="DirectionalLight" parent="Lighting"]
|
||||||
transform = Transform( -0.777664, -0.348191, 0.523451, 0.0166148, 0.820946, 0.570764, -0.62846, 0.45256, -0.632636, 0, 1.62188, 0 )
|
transform = Transform( -0.777664, -0.348191, 0.523451, 0.0166148, 0.820946, 0.570764, -0.62846, 0.45256, -0.632636, 0, 1.62188, 0 )
|
||||||
|
visible = false
|
||||||
light_color = Color( 0.501961, 0.67451, 1, 1 )
|
light_color = Color( 0.501961, 0.67451, 1, 1 )
|
||||||
light_energy = 2.0
|
light_energy = 2.0
|
||||||
light_bake_mode = 2
|
light_bake_mode = 2
|
||||||
@@ -375,3 +388,22 @@ shadow_contact = 0.3
|
|||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="Lighting"]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="Lighting"]
|
||||||
environment = SubResource( 4 )
|
environment = SubResource( 4 )
|
||||||
|
|
||||||
|
[node name="Dialog" type="Control" parent="."]
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ConfirmEscape" type="ConfirmationDialog" parent="Dialog"]
|
||||||
|
visible = true
|
||||||
|
margin_right = 200.0
|
||||||
|
margin_bottom = 70.0
|
||||||
|
window_title = "Veuillez confirmer…"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[connection signal="input_event" from="Main Scene Props/dagger/Area" to="." method="_on_dagger_input_event"]
|
||||||
|
[connection signal="confirmed" from="Dialog/ConfirmEscape" to="." method="_on_ConfirmEscape_confirmed"]
|
||||||
|
|||||||
Reference in New Issue
Block a user