[gd_scene load_steps=6 format=1]

[ext_resource path="res://image/radial16.png" type="Texture" id=1]
[ext_resource path="res://misc/new_canvasitemmaterial.tres" type="CanvasItemMaterial" id=2]

[sub_resource type="GDScript" id=1]

script/source = "extends Control\n\nvar Energy=200;\nvar prevEnergy = 200;\nvar continues_pressed = false;\nvar energyPower = 0;\n\nfunc _ready():\n\tset_process(true);\n\tEnergy = Globals.get(\"game_saver\").savedict.maxEnergy;\n\tprevEnergy = Energy;\n\tget_node(\"Panel\").set_size(Vector2(Energy,20));\n\tGlobals.set(\"energy_left\", Energy);\n\tGlobals.set(\"last_energy_usage\", 0);\n\tGlobals.set(\"allow_energy_usage\", true);\n\nvar hintSpawned = false;\nvar forceVisualRef;\nvar forceVisual = preload(\"res://image/light.png\")\nfunc _process(delta):\n\tif(!hintSpawned && Input.is_mouse_button_pressed(BUTTON_LEFT) && Globals.get(\"curr_pressed_bubble\")):\n\t\tif(!forceVisualRef):\n\t\t\tif(!Globals.get(\"curr_pressed_bubble\")): return;\n\t\t\tforceVisualRef = Sprite.new();\n\t\t\tforceVisualRef.set_texture(forceVisual);\n\t\t\t#forceVisualRef.set_scale(Vector2(1,1));\n\t\t\tforceVisualRef.set_z_as_relative(true);\n\t\t\tforceVisualRef.set_z(-1);\n\t\t\tforceVisualRef.set_opacity(0.4);\n\t\t\tforceVisualRef.set_material(load(\"res://misc/new_canvasitemmaterial.tres\"));\n\t\t\tGlobals.get(\"curr_pressed_bubble\").add_child(forceVisualRef);\n\t\t\t\n\t\tcontinues_pressed = true;\n\t\tif(Energy > 0):\n\t\t\tEnergy -= 25*delta;\n\t\telse:\n\t\t\tEnergy = 0;\n\t\t\tGlobals.set(\"allow_energy_usage\", false);\n\t\t\tget_node(\"../restartButton\").set_hidden(false);\n\t\t\tvar appearText = load(\"res://objs/AppearLabel.tscn\").instance();\n\t\t\tget_node(\"Panel\").add_child(appearText);\n\t\t\tappearText.set_text(\"OUT OF ENERGY!\");\n\t\t\tif(!hintSpawned):\n\t\t\t\thintSpawned = true;\n\t\t\t\tvar appearText2 = load(\"res://objs/AppearLabel.tscn\").instance();\n\t\t\t\tappearText2.appearDelay = 1;\n\t\t\t\tget_node(\"../restartButton\").add_child(appearText2);\n\t\t\t\tappearText2.set_text(\"You can buy upgrades now\");\n\t\t\t\tappearText2.set_pos(Vector2(-100,-30));\n\t\t\t\tif(Globals.get(\"curr_pressed_bubble\")):\n\t\t\t\t\tGlobals.get(\"curr_pressed_bubble\").clickInfect(Globals.get(\"last_energy_usage_power\"));\n\t\t\n\t\tvar x = prevEnergy - Energy;\n\t\tenergyPower = pow(x,0.5)*Globals.get(\"game_saver\").savedict.explodeForce;\n\t\tGlobals.set(\"last_energy_usage\", prevEnergy - Energy);\n\t\tGlobals.set(\"last_energy_usage_power\", energyPower);\n\t\tGlobals.set(\"energy_left\", Energy);\n\t\tforceVisualRef.set_scale(Vector2(energyPower/2000,energyPower/2000));\n\t\t#forceVisualRef.set_rot(forceVisualRef.get_rot()+10);\n\t\tget_node(\"particles\").set_lifetime(7*(Energy/Globals.get(\"game_saver\").savedict.explodeForce));\n\t\tget_node(\"Panel\").set_size(Vector2(Energy,20));\n\t\tget_node(\"infectPowerPanel\").set_size(Vector2(energyPower/5,20));\n\t\t\n\telif(!hintSpawned && continues_pressed):\n\t\tcontinues_pressed = false;\n\t\tprevEnergy = Energy;\n\t\tforceVisualRef = null;\n\t\tif(Globals.get(\"curr_pressed_bubble\")):\n\t\t\tGlobals.get(\"curr_pressed_bubble\").clickInfect(Globals.get(\"last_energy_usage_power\"));\n\t\t\tGlobals.set(\"curr_pressed_bubble\", null);\n\t\n\t"

[sub_resource type="CanvasItemShader" id=2]

_code = { "fragment":"\nuniform color modulate=color(0.2,0.4,1.0,0.8);\nCOLOR = vec4(modulate.rgb,tex(TEXTURE,UV).a*modulate.a);\n\n", "fragment_ofs":0, "light":"", "light_ofs":0, "vertex":"", "vertex_ofs":0 }

[sub_resource type="CanvasItemMaterial" id=3]

shader/shader = SubResource( 2 )
shader/shading_mode = 0
shader_param/modulate = Color( 0.0264893, 0.140961, 0.484375, 0.415294 )

[node name="Energy" type="Control"]

focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 0.0
margin/top = 0.0
margin/right = 40.0
margin/bottom = 40.0
script/script = SubResource( 1 )

[node name="Panel" type="Panel" parent="."]

material/material = SubResource( 3 )
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 0.0
margin/top = 0.0
margin/right = 200.0
margin/bottom = 20.0

[node name="particles" type="Particles2D" parent="."]

visibility/opacity = 0.7
transform/pos = Vector2( 0.397217, 9.53314 )
transform/rot = 90.2026
config/amount = 128
config/lifetime = 7.0
config/preprocess = 7.0
config/half_extents = Vector2( 10, 0 )
config/texture = ExtResource( 1 )
params/direction = 0.0
params/spread = 5.0
params/linear_velocity = 20.0
params/spin_velocity = 10.0
params/orbit_velocity = 0.0
params/gravity_direction = 0.0
params/gravity_strength = 9.8
params/radial_accel = 1.0
params/tangential_accel = 0.0
params/damping = 6.0
params/initial_angle = 0.0
params/initial_size = 1.0
params/final_size = 0.2
params/hue_variation = 0.0
params/anim_speed_scale = 1.0
params/anim_initial_pos = 0.0
randomness/direction = 0.1
randomness/radial_accel = 0.1
randomness/damping = 0.1
randomness/initial_size = 0.5
randomness/final_size = 0.1
color/color = Color( 0.414062, 0.414062, 0.414062, 1 )

[node name="infectPowerPanel" type="Panel" parent="."]

visibility/visible = false
material/material = ExtResource( 2 )
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 0.0
margin/top = 20.0
margin/right = 0.0
margin/bottom = 40.0


