diff --git a/levels/test.tscn b/levels/test.tscn index cba4bd6..bcf474c 100644 --- a/levels/test.tscn +++ b/levels/test.tscn @@ -1,16 +1,23 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://characters/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2] [ext_resource path="res://Items/ChargeWandPickup.tscn" type="PackedScene" id=3] +[ext_resource path="res://ai/ogre.tscn" type="PackedScene" id=4] [node name="Node2D" type="Node2D"] -[node name="Player" parent="." instance=ExtResource( 1 )] -position = Vector2( 60, 176 ) - [node name="TileMap" parent="." instance=ExtResource( 2 )] tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 10, 65543, 0, 10, 65544, 0, 10, 65545, 0, 10, 65546, 0, 10, 65547, 0, 10, 65548, 0, 10, 65549, 0, 10, 65550, 0, 10, 65551, 0, 10, 65552, 0, 10, 65553, 0, 10, 65554, 0, 10, 65555, 0, 10, 65556, 0, 11, 131072, 0, 65544, 131073, 0, 131078, 131074, 0, 196617, 131075, 0, 196617, 131076, 0, 196617, 131077, 0, 196617, 131078, 0, 196617, 131079, 0, 196617, 131080, 0, 196617, 131081, 0, 196617, 131082, 0, 196617, 131083, 0, 196617, 131084, 0, 196617, 131085, 0, 196617, 131086, 0, 196617, 131087, 0, 196617, 131088, 0, 196617, 131089, 0, 196617, 131090, 0, 196617, 131091, 0, 131077, 131092, 0, 131083, 196608, 0, 65544, 196609, 0, 131083, 196627, 0, 65544, 196628, 0, 131083, 262144, 0, 65544, 262145, 0, 131083, 262163, 0, 65544, 262164, 0, 131083, 327680, 0, 65544, 327681, 0, 131083, 327699, 0, 65544, 327700, 0, 131083, 393216, 0, 65544, 393217, 0, 131083, 393235, 0, 65544, 393236, 0, 131083, 458752, 0, 65544, 458753, 0, 131083, 458771, 0, 65544, 458772, 0, 131083, 524288, 0, 65544, 524289, 0, 131083, 524307, 0, 65544, 524308, 0, 131083, 589824, 0, 65544, 589825, 0, 131083, 589843, 0, 65544, 589844, 0, 131083, 655360, 0, 65544, 655361, 0, 131083, 655379, 0, 65544, 655380, 0, 131083, 720896, 0, 65544, 720897, 0, 65542, 720898, 0, 10, 720899, 0, 10, 720900, 0, 10, 720901, 0, 10, 720902, 0, 10, 720903, 0, 10, 720904, 0, 10, 720905, 0, 10, 720906, 0, 10, 720907, 0, 10, 720908, 0, 10, 720909, 0, 10, 720910, 0, 10, 720911, 0, 10, 720912, 0, 10, 720913, 0, 10, 720914, 0, 10, 720915, 0, 65541, 720916, 0, 131083, 786432, 0, 196616, 786433, 0, 196617, 786434, 0, 196617, 786435, 0, 196617, 786436, 0, 196617, 786437, 0, 196617, 786438, 0, 196617, 786439, 0, 196617, 786440, 0, 196617, 786441, 0, 196617, 786442, 0, 196617, 786443, 0, 196617, 786444, 0, 196617, 786445, 0, 196617, 786446, 0, 196617, 786447, 0, 196617, 786448, 0, 196617, 786449, 0, 196617, 786450, 0, 196617, 786451, 0, 196617, 786452, 0, 196619 ) +[node name="Player" parent="." instance=ExtResource( 1 )] +position = Vector2( 60, 176 ) + [node name="ChargeWandPickup" parent="." instance=ExtResource( 3 )] -position = Vector2( 98, 162 ) +position = Vector2( 60, 165 ) + +[node name="Ogre" parent="." instance=ExtResource( 4 )] +position = Vector2( 235, 173 ) + +[node name="Ogre2" parent="." instance=ExtResource( 4 )] +position = Vector2( 266, 169 ) diff --git a/magic/Projectiles/EcoProjectile.gd b/magic/Projectiles/EcoProjectile.gd new file mode 100644 index 0000000..ea4d88d --- /dev/null +++ b/magic/Projectiles/EcoProjectile.gd @@ -0,0 +1,5 @@ +extends Projectile + + +func _ready(): + energy_cost = 0 diff --git a/magic/Projectiles/EcoProjectile.tscn b/magic/Projectiles/EcoProjectile.tscn index 05e779a..8a57994 100644 --- a/magic/Projectiles/EcoProjectile.tscn +++ b/magic/Projectiles/EcoProjectile.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://art/ecoprojectile.png" type="Texture" id=1] -[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2] +[ext_resource path="res://magic/Projectiles/EcoProjectile.gd" type="Script" id=2] [sub_resource type="CircleShape2D" id=1] radius = 5.09902 diff --git a/magic/Projectiles/ExplosiveProjectile.gd b/magic/Projectiles/ExplosiveProjectile.gd new file mode 100644 index 0000000..d1b5b34 --- /dev/null +++ b/magic/Projectiles/ExplosiveProjectile.gd @@ -0,0 +1,17 @@ +extends Projectile + +func _ready(): + damage = 3 + +func on_impact(collision): + for body in $Area2D.get_overlapping_bodies(): + if body.get("health") != null and body.get_type() != "player": + body.health -= damage + $Particles2D.emitting = true + $KillTimer.start() + set_physics_process(false) + $CollisionShape2D.disabled = true + $Sprite.visible = false + +func _on_KillTimer_timeout(): + queue_free() diff --git a/magic/Projectiles/ExplosiveProjectile.tscn b/magic/Projectiles/ExplosiveProjectile.tscn index 0197ae6..cea6cfa 100644 --- a/magic/Projectiles/ExplosiveProjectile.tscn +++ b/magic/Projectiles/ExplosiveProjectile.tscn @@ -1,11 +1,32 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://art/MineProjectile.png" type="Texture" id=1] -[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2] +[ext_resource path="res://magic/Projectiles/ExplosiveProjectile.gd" type="Script" id=2] [sub_resource type="CircleShape2D" id=1] radius = 6.0 +[sub_resource type="Gradient" id=3] +offsets = PoolRealArray( 0.0120482, 0.192771, 0.534137, 1 ) +colors = PoolColorArray( 1, 0.449219, 0.449219, 1, 1, 0, 0, 1, 1, 0.351563, 0, 1, 0.155762, 0.155762, 0.155762, 1 ) + +[sub_resource type="GradientTexture" id=4] +gradient = SubResource( 3 ) + +[sub_resource type="ParticlesMaterial" id=5] +emission_shape = 1 +emission_sphere_radius = 1.0 +flag_disable_z = true +spread = 180.0 +gravity = Vector3( 0, 0, 0 ) +initial_velocity = 50.0 +orbit_velocity = 0.0 +orbit_velocity_random = 0.0 +color_ramp = SubResource( 4 ) + +[sub_resource type="CircleShape2D" id=2] +radius = 50.0 + [node name="ExplosiveProjectile" type="KinematicBody2D"] collision_layer = 8 collision_mask = 6 @@ -15,4 +36,23 @@ script = ExtResource( 2 ) texture = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +visible = false shape = SubResource( 1 ) + +[node name="Particles2D" type="Particles2D" parent="."] +emitting = false +amount = 200 +one_shot = true +speed_scale = 2.5 +explosiveness = 0.8 +process_material = SubResource( 5 ) + +[node name="Area2D" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +visible = false +shape = SubResource( 2 ) + +[node name="KillTimer" type="Timer" parent="."] +one_shot = true +[connection signal="timeout" from="KillTimer" to="." method="_on_KillTimer_timeout"] diff --git a/magic/Projectiles/PhantomProjectile.gd b/magic/Projectiles/PhantomProjectile.gd new file mode 100644 index 0000000..e2f7846 --- /dev/null +++ b/magic/Projectiles/PhantomProjectile.gd @@ -0,0 +1,9 @@ +extends Projectile + + +var ignore = [] + +func _on_body_entered(body): + if body.get("health") != null: + body.health -= 1 + diff --git a/magic/Projectiles/PhantomProjectile.tscn b/magic/Projectiles/PhantomProjectile.tscn index 11b427e..8d40986 100644 --- a/magic/Projectiles/PhantomProjectile.tscn +++ b/magic/Projectiles/PhantomProjectile.tscn @@ -1,20 +1,34 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://art/PhantomProjectile.png" type="Texture" id=1] -[ext_resource path="res://magic/Projectiles/Projectile.gd" type="Script" id=2] +[ext_resource path="res://magic/Projectiles/PhantomProjectile.gd" type="Script" id=2] -[sub_resource type="CapsuleShape2D" id=1] -radius = 4.0 +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 1, 4 ) + +[sub_resource type="CapsuleShape2D" id=2] +radius = 3.0 height = 6.0 [node name="PhantomProjectile" type="KinematicBody2D"] collision_layer = 8 -collision_mask = 6 +collision_mask = 2 script = ExtResource( 2 ) -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -rotation = 1.5708 -shape = SubResource( 1 ) - [node name="Sprite" type="Sprite" parent="."] texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +visible = false +rotation = 1.5708 +shape = SubResource( 1 ) + +[node name="Area2D" type="Area2D" parent="."] +monitorable = false +collision_layer = 0 +collision_mask = 4 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +rotation = 1.5708 +shape = SubResource( 2 ) +[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"] diff --git a/magic/Projectiles/Projectile.gd b/magic/Projectiles/Projectile.gd index 3c279c8..d8cbca7 100644 --- a/magic/Projectiles/Projectile.gd +++ b/magic/Projectiles/Projectile.gd @@ -1,12 +1,10 @@ extends KinematicBody2D class_name Projectile -export var speed = 300 +export var speed = 400 var velocity = Vector2.ZERO var energy_cost = 1 var damage = 1 -onready var Hit = get_node("Node/Hit") -onready var Hit_Wall = get_node("Node/Hit Wall") func _physics_process(delta): var collision = move_and_collide(velocity * delta) diff --git a/project.godot b/project.godot index 71a858f..f42bf74 100644 --- a/project.godot +++ b/project.godot @@ -97,6 +97,13 @@ texture={ [input] +ui_end={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777230,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null) + ] +} up={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) diff --git a/script/Inventory.gd b/script/Inventory.gd index c8f5c14..a1a7747 100644 --- a/script/Inventory.gd +++ b/script/Inventory.gd @@ -34,6 +34,10 @@ func _process(delta): if Input.is_action_just_pressed("inventory"): set_open(!open) +func _input(event): + if event.is_action_pressed("ui_end"): + set_open(false) + func set_open(new): if open != new: if new == true: