mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-12 05:22:23 +02:00
Merge branch 'devRefactor' of https://github.com/creyD/ludum_dare_46 into devRefactor
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Overlap/Stats/Stats.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://Boss/Boss_template.gd" type="Script" id=4]
|
||||
[ext_resource path="res://testSprites/white_boss_dog.png" type="Texture" id=5]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=6]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 18.0
|
||||
@@ -21,6 +22,8 @@ height = 15.0
|
||||
[node name="Boss_template" type="KinematicBody2D"]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 6 )]
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 3.13451, -20.1418 )
|
||||
scale = Vector2( 2, 2 )
|
||||
|
||||
27
src/Effects/Debris/SplashEffect.tscn
Normal file
27
src/Effects/Debris/SplashEffect.tscn
Normal file
@@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Effects/Debris/debris-splash.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "__INIT__"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath(".:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
|
||||
}
|
||||
|
||||
[node name="SplashEffect" type="Sprite"]
|
||||
texture = ExtResource( 1 )
|
||||
vframes = 3
|
||||
hframes = 3
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
autoplay = "__INIT__"
|
||||
anims/__INIT__ = SubResource( 1 )
|
||||
31
src/Effects/Fire/FireEffect.tscn
Normal file
31
src/Effects/Fire/FireEffect.tscn
Normal file
@@ -0,0 +1,31 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Effects/Fire/fire-particle.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="Gradient" id=1]
|
||||
offsets = PoolRealArray( 0.488889, 1 )
|
||||
colors = PoolColorArray( 1, 1, 1, 1, 0, 0, 0, 0 )
|
||||
|
||||
[sub_resource type="GradientTexture" id=2]
|
||||
gradient = SubResource( 1 )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=3]
|
||||
lifetime_randomness = 0.12
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 3.0
|
||||
flag_disable_z = true
|
||||
gravity = Vector3( 0, -20, 0 )
|
||||
orbit_velocity = 0.0
|
||||
orbit_velocity_random = 0.0
|
||||
radial_accel = 9.2
|
||||
scale = 0.25
|
||||
scale_random = 0.15
|
||||
color_ramp = SubResource( 2 )
|
||||
hue_variation = 0.18
|
||||
|
||||
[node name="FireEffect" type="Particles2D"]
|
||||
amount = 10
|
||||
lifetime = 1.2
|
||||
speed_scale = 1.3
|
||||
process_material = SubResource( 3 )
|
||||
texture = ExtResource( 1 )
|
||||
124
src/Maps/Grid.gd
Normal file
124
src/Maps/Grid.gd
Normal file
@@ -0,0 +1,124 @@
|
||||
extends Node
|
||||
|
||||
const Kind = preload("res://Overlap/Kind.gd") # Relative path
|
||||
|
||||
|
||||
var object_grid : Array = []
|
||||
var prio_grid : Array = []
|
||||
var used_grid : Array = []
|
||||
var time_passed := 0.0
|
||||
var offset
|
||||
export(float,0,42.0) var refresh_rate = 5.0
|
||||
|
||||
|
||||
func _draw_object_grid():
|
||||
for y in range(7):
|
||||
var stri = ""
|
||||
for x in range(14):
|
||||
stri += str(object_grid[x][y]) + " "
|
||||
print(stri)
|
||||
print()
|
||||
|
||||
func _draw_prio_grid():
|
||||
for y in range(7):
|
||||
var stri = ""
|
||||
for x in range(14):
|
||||
stri += str(prio_grid[x][y]) + " "
|
||||
print(stri)
|
||||
print()
|
||||
|
||||
func _reset_grids():
|
||||
for x in range(14):
|
||||
for y in range(7):
|
||||
var lulul = object_grid[x][y].back()
|
||||
while (object_grid[x][y].back()!=Kind.FIELD) and (Kind.WALL != object_grid[x][y].back()):
|
||||
object_grid[x][y].pop_back()
|
||||
while (prio_grid[x][y].back()!=Kind.TERMINAL_SYMBOL):
|
||||
prio_grid[x][y].pop_back()
|
||||
|
||||
func _ready():
|
||||
var walls = get_tree().current_scene.get_child(1)
|
||||
offset = walls.global_position
|
||||
#todo put in grid_lul
|
||||
for x in range(14):
|
||||
object_grid.push_back([])
|
||||
prio_grid.push_back([])
|
||||
used_grid.push_back([])
|
||||
for y in range(7):
|
||||
object_grid[x].push_back([Kind.FIELD])
|
||||
prio_grid[x].push_back([Kind.TERMINAL_SYMBOL])
|
||||
used_grid[x].push_back(false)
|
||||
|
||||
for tile in walls.get_used_cells():
|
||||
if(_is_in_grid(tile)):
|
||||
object_grid[tile.x][tile.y][0] = Kind.WALL
|
||||
|
||||
_update_grid()
|
||||
|
||||
|
||||
func reset_history():
|
||||
for x in range(14):
|
||||
for y in range(7):
|
||||
used_grid[x][y] = false
|
||||
|
||||
func countTargets(table):
|
||||
for x in range(14):
|
||||
for y in range(7):
|
||||
for i in prio_grid[x][y]:
|
||||
if i == Kind.TERMINAL_SYMBOL:
|
||||
continue
|
||||
table[i]+=1
|
||||
return table
|
||||
|
||||
func _pixel_to_grid_coords(pixel : Vector2) -> Vector2:
|
||||
var new_coords : Vector2
|
||||
new_coords.x = floor((pixel.x-offset.x)/32.0)
|
||||
new_coords.y = floor((pixel.y-offset.y)/32.0)
|
||||
return new_coords
|
||||
|
||||
func _is_in_grid(grid_coords : Vector2) -> bool:
|
||||
if(grid_coords.x<0):
|
||||
return false
|
||||
if(grid_coords.x>13):
|
||||
return false
|
||||
if(grid_coords.y<0):
|
||||
return false
|
||||
if(grid_coords.y>6):
|
||||
return false
|
||||
return true
|
||||
|
||||
func get_nearest(position, kind):
|
||||
var list = []
|
||||
for x in range(14):
|
||||
for y in range(7):
|
||||
for i in prio_grid[x][y]:
|
||||
if(i == kind):
|
||||
list.append([x,y])
|
||||
var dist = []
|
||||
for field in list:
|
||||
var tmp = sqrt(pow(position[0]-field[0],2)+pow(position[1]-field[1],2))
|
||||
dist.append(tmp)
|
||||
var mini = 0
|
||||
for i in range(1, dist.size()):
|
||||
if(dist[i]<dist[mini]):
|
||||
mini = i
|
||||
return list[mini]
|
||||
|
||||
func _update_grid():
|
||||
_reset_grids()
|
||||
var world = get_tree().current_scene.get_child(2)
|
||||
for node in world.get_children():
|
||||
var node_kind = node.get_child(0)
|
||||
var grid_corrds = _pixel_to_grid_coords(node.global_position)
|
||||
if (_is_in_grid(grid_corrds)):
|
||||
if(node_kind.general!=Kind.FIELD and node_kind.general!=Kind.WALL):
|
||||
object_grid[grid_corrds.x][grid_corrds.y].push_back(node_kind.general)
|
||||
prio_grid[grid_corrds.x][grid_corrds.y].push_back(node_kind.kind)
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
if(time_passed > refresh_rate):
|
||||
time_passed -= refresh_rate
|
||||
_update_grid()
|
||||
time_passed += delta
|
||||
|
||||
6
src/Maps/Grid.tscn
Normal file
6
src/Maps/Grid.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Maps/Grid.gd" type="Script" id=1]
|
||||
|
||||
[node name="Grid" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Banana/Bannana.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/bannane.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 7.54726
|
||||
@@ -11,6 +12,10 @@ height = 12.1493
|
||||
[node name="Banana" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
general = 2
|
||||
kind = 10
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 1.54256, -4.73786 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Barrel/Barrel.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/Fass.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 10.7634
|
||||
@@ -15,6 +16,10 @@ height = 8.78242
|
||||
[node name="Barrel" type="StaticBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
general = 1
|
||||
kind = 9
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.244171, -10.0111 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Bonfire/Bonfire.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/Bonfire.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 7.76762
|
||||
@@ -19,6 +20,10 @@ radius = 32.0
|
||||
[node name="Bonfire" type="StaticBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 5 )]
|
||||
general = 1
|
||||
kind = 8
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.22036, -4.18694 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Heart/Heart.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/Herz.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 7.43707
|
||||
@@ -11,6 +12,10 @@ height = 2.89399
|
||||
[node name="Heart" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
general = 1
|
||||
kind = 7
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.22036, -4.18694 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Rubies/Rubies.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/blue_Rubi.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 7.43707
|
||||
@@ -11,6 +12,10 @@ height = 2.89399
|
||||
[node name="Blue" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
general = 1
|
||||
kind = 5
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.22036, -4.18694 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Rubies/Rubies.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/green_Rubi.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 7.43707
|
||||
@@ -11,6 +12,10 @@ height = 2.89399
|
||||
[node name="Green" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
general = 1
|
||||
kind = 6
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.22036, -4.18694 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Rubies/Rubies.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/red_Rubi.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 7.43707
|
||||
@@ -11,6 +12,10 @@ height = 2.89399
|
||||
[node name="Red" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
general = 1
|
||||
kind = 4
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.22036, -4.18694 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://testSprites/slime.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 16, 16 )
|
||||
|
||||
[node name="Slime" type="Node2D"]
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 3 )]
|
||||
general = 2
|
||||
kind = 10
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
extends StaticBody2D
|
||||
extends Node2D
|
||||
|
||||
export(int, 1, 5) var lifePoints = 3
|
||||
export(int, 1, 30) var spawnRate = 5
|
||||
@@ -7,13 +7,14 @@ var elapsedTime = 0.0
|
||||
|
||||
func _physics_process(delta):
|
||||
elapsedTime += delta
|
||||
if(elapsedTime>=spawnRate):
|
||||
elapsedTime-=spawnRate
|
||||
var Minion = load("")
|
||||
var world = get_tree().current_scene.get_child(2)
|
||||
var minion = Minion.instance()
|
||||
world.add_child(minion)
|
||||
minion.global_position = global_position
|
||||
#if(elapsedTime>=spawnRate):
|
||||
# elapsedTime-=spawnRate
|
||||
# var Minion = load("")
|
||||
# var world = get_tree().current_scene.get_child(2)
|
||||
# #TODO minions
|
||||
# var minion = Minion.instance()
|
||||
# world.add_child(minion)
|
||||
# minion.global_position = global_position
|
||||
|
||||
|
||||
func _on_Hurtbox_area_entered(area):
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://testSprites/fackel.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Objects/Torch/Torch.gd" type="Script" id=3]
|
||||
[ext_resource path="res://Effects/Fire/FireEffect.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 8.0
|
||||
height = 12.0
|
||||
|
||||
[node name="Torch" type="StaticBody2D"]
|
||||
[node name="Torch" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="FireEffect" parent="." instance=ExtResource( 4 )]
|
||||
position = Vector2( 1.88936, -12.4698 )
|
||||
[node name="Kind" parent="." instance=ExtResource( 5 )]
|
||||
general = 4
|
||||
kind = 2
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -8 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://testSprites/flame.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
@@ -8,6 +9,9 @@ height = 6.36237
|
||||
|
||||
[node name="Flame" type="Node2D"]
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 2 )]
|
||||
kind = 10
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.44072, -6.06005 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Banana/Bannana.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/Spike.png" type="Texture" id=3]
|
||||
|
||||
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
height = 6.36237
|
||||
@@ -12,6 +11,9 @@ height = 6.36237
|
||||
[node name="Spike" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
kind = 10
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.220352, -3.63603 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Banana/Bannana.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/Sting.png" type="Texture" id=3]
|
||||
|
||||
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 6.77597
|
||||
@@ -13,6 +12,9 @@ height = 6.36237
|
||||
[node name="Sting" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 4 )]
|
||||
kind = 10
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.44072, -9.03499 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Objects/Traps/Bear.gd" type="Script" id=2]
|
||||
[ext_resource path="res://testSprites/falle.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Objects/Traps/Bear.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://testSprites/falle.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
height = 9.0
|
||||
@@ -12,20 +13,23 @@ height = 9.0
|
||||
height = 9.0
|
||||
|
||||
[node name="Bear_trap" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 3 )]
|
||||
kind = 10
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( -7.62939e-06, 0 )
|
||||
texture = ExtResource( 3 )
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="Hitbox" parent="." instance=ExtResource( 1 )]
|
||||
[node name="Hitbox" parent="." instance=ExtResource( 2 )]
|
||||
collision_layer = 16
|
||||
|
||||
[node name="CollisionShape2D" parent="Hitbox" index="0"]
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Hurtbox" parent="." instance=ExtResource( 4 )]
|
||||
[node name="Hurtbox" parent="." instance=ExtResource( 5 )]
|
||||
collision_layer = 32
|
||||
collision_mask = 0
|
||||
|
||||
|
||||
245
src/Overlap/AI/AI_Hero.gd
Normal file
245
src/Overlap/AI/AI_Hero.gd
Normal file
@@ -0,0 +1,245 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
class_name Hero
|
||||
|
||||
const PrioQueue = preload("prio_queue.gd") # Relative path
|
||||
const Grid = preload("res://Maps/Grid.gd")
|
||||
|
||||
var grid
|
||||
|
||||
enum{
|
||||
LENGTH,
|
||||
WAY
|
||||
}
|
||||
|
||||
enum{
|
||||
STEP,
|
||||
ROLL,
|
||||
NOTHING
|
||||
}
|
||||
|
||||
enum{
|
||||
EXECUTING,
|
||||
AI_MOVE
|
||||
}
|
||||
|
||||
var ExecutionState = AI_MOVE
|
||||
var movmentState = NOTHING
|
||||
|
||||
var numbers = [0,0,0,0,0,0,0,0,0,0]
|
||||
var prios = [7,0,6,5,4,3,2,1,1,4]
|
||||
|
||||
var totalPrioTurn = 0
|
||||
var executesTurn = false
|
||||
var abortProb = 0.01
|
||||
|
||||
var targetField = [0,0]
|
||||
var targetFieldUsed = false
|
||||
#calculates the sum of all present prios
|
||||
func calcTotalPrio():
|
||||
var sum = 0
|
||||
var i = Grid.Kind.BOSS
|
||||
while i != Grid.Kind.TERMINAL_SYMBOL:
|
||||
if(numbers[i]>0):
|
||||
sum += prios[i]
|
||||
i += 1
|
||||
return sum
|
||||
|
||||
#calculates the relative porio
|
||||
func calcRelPrio(index, sum) -> float:
|
||||
if(sum==0):
|
||||
return 0.0
|
||||
return float(prios[index])/float(sum)
|
||||
|
||||
#calucaltes the prio table of all enemies[0,1)
|
||||
func calcPrioTable():
|
||||
var table = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
numbers = grid.countTargets(numbers)
|
||||
var lower = 0.0
|
||||
var sum = calcTotalPrio()
|
||||
|
||||
var i = 0;
|
||||
while i != Grid.Kind.TERMINAL_SYMBOL:
|
||||
if(numbers[i]!=0):
|
||||
lower += calcRelPrio(i, sum)
|
||||
table[i] = lower
|
||||
i += 1
|
||||
|
||||
return table
|
||||
|
||||
#updates heart and bonfire prio
|
||||
func adjustPrio(currentHealth, maxHealth):
|
||||
var prioVal = 1000 - (float(currentHealth)/float(maxHealth))*1000
|
||||
var bonfire = prioVal
|
||||
var hearts = prioVal - 1
|
||||
if(hearts < 0):
|
||||
hearts = 0
|
||||
prios[Grid.Kind.BONFIRE]=bonfire
|
||||
prios[Grid.Kind.HEART]=hearts
|
||||
|
||||
#return the enemie which will be attacked
|
||||
func calcEnemyKind():
|
||||
var table = calcPrioTable()
|
||||
var number = randf()
|
||||
var i = 0
|
||||
while i!=Grid.Kind.TERMINAL_SYMBOL and table[i] <= number:
|
||||
i += 1
|
||||
return i
|
||||
|
||||
#returns a move
|
||||
func getMoveDescription(myPosition : Vector2, targetPositions):
|
||||
return AStar(myPosition, targetPositions)
|
||||
|
||||
|
||||
func getCost(field):
|
||||
var cost = 0
|
||||
for i in grid.prio_grid[field.x][field.y]:
|
||||
match i:
|
||||
Grid.Kind.DAMAGE:
|
||||
cost += prios[Grid.Kind.BONFIRE] * 6
|
||||
Grid.Kind.SLOW:
|
||||
cost += 2
|
||||
return cost
|
||||
|
||||
#return an heurestic of distance
|
||||
# curr - current position
|
||||
# targ - a target position
|
||||
func h(curr, target):
|
||||
return min(abs(target[0]-curr[0]),abs(target[0]-curr[0]))
|
||||
|
||||
# currCost - currentCost
|
||||
# target - position of the field to move to
|
||||
func g(currCost, target):
|
||||
return currCost + getCost(target)
|
||||
|
||||
# Returns the list of adjacent nodes
|
||||
func adjacent(currentPosition, can_roll = false):
|
||||
var adj := []
|
||||
#adj.append([STEP, Vector2(0,0)])
|
||||
var p = currentPosition
|
||||
var pot_adj_step = [[p[0]-1, p[1]-1], [p[0]-1, p[1]-0], [p[0]-1, p[1]+1],
|
||||
[p[0]+0, p[1]-1], [p[0]+0, p[1]+1],
|
||||
[p[0]+1, p[1]-1], [p[0]+1, p[1]+0], [p[0]+1, p[1]+1]]
|
||||
|
||||
var pot_adj_roll = [[p[0]-2, p[1]-2], [p[0]-2, p[1]-0], [p[0]-2, p[1]+2],
|
||||
[p[0]+0, p[1]-2], [p[0]+0, p[1]+2],
|
||||
[p[0]+2, p[1]-2], [p[0]+2, p[1]+0], [p[0]+2, p[1]+2]]
|
||||
|
||||
for next in pot_adj_step:
|
||||
if(next[0]<0):
|
||||
continue
|
||||
if(next[0]>13):
|
||||
continue
|
||||
if(next[1]<0):
|
||||
continue
|
||||
if(next[1]>6):
|
||||
continue
|
||||
if(grid.used_grid[next[0]][next[1]]):
|
||||
continue
|
||||
if(grid.object_grid[next[0]][next[1]][0]!=Grid.Kind.WALL):
|
||||
adj.append([STEP, Vector2(next[0],next[1])])
|
||||
|
||||
if not can_roll:
|
||||
return adj
|
||||
|
||||
for next in pot_adj_roll:
|
||||
if(next[0]<0):
|
||||
continue
|
||||
if(next[0]>13):
|
||||
continue
|
||||
if(next[1]<0):
|
||||
continue
|
||||
if(next[1]>6):
|
||||
continue
|
||||
if(grid.used_grid[next[0]][next[1]]):
|
||||
continue
|
||||
if(grid.object_grid[next[0]][next[1]][0]!=Grid.Kind.WALL):
|
||||
adj.append([ROLL, Vector2(next[0],next[1])])
|
||||
|
||||
return adj
|
||||
|
||||
|
||||
func AStar(source, target):
|
||||
#swap rtarget and source, when target source istr reached, do inversxse step
|
||||
# node layout [g+h(x), g(x), current, from, kind]
|
||||
var tmp = source
|
||||
source = target
|
||||
target = tmp
|
||||
|
||||
var Q = PrioQueue.new()
|
||||
Q.insert([0,0, [source[0], source[1]], [source[0], source[1]], NOTHING] )
|
||||
while !Q.empty():
|
||||
var node = Q.delMin()
|
||||
|
||||
# Check if reached
|
||||
if(node[2][0] == target[0] and node[2][1] == target[1]):
|
||||
return [node[4], node[3]] # 4 is kind | 3 is from
|
||||
|
||||
# Set flag
|
||||
grid.used_grid[node[2][0]][node[2][1]] = true
|
||||
var adj_list = adjacent(node[2])
|
||||
for i in adj_list:
|
||||
var move_cost = 0
|
||||
if (i[0] == STEP):
|
||||
move_cost = 1
|
||||
else:
|
||||
move_cost = 2
|
||||
|
||||
var g_val = g(node[1]+move_cost, i[1])
|
||||
var h_val = h(i[1], target)
|
||||
|
||||
#[g+h(x), g(x), current, from, kind]
|
||||
var new_node = [g_val+h_val, g_val,i[1], node[2], i[0]]
|
||||
Q.insert(new_node)
|
||||
|
||||
return [NOTHING, [0,0]]
|
||||
|
||||
func makeMove(delta):
|
||||
if ExecutionState == AI_MOVE:
|
||||
var currentPosition = grid._pixel_to_grid_coords(global_position)
|
||||
var enemyKind = calcEnemyKind()
|
||||
if(enemyKind==Grid.Kind.TERMINAL_SYMBOL):
|
||||
return
|
||||
var target = grid.get_nearest(currentPosition, enemyKind)
|
||||
var MoveAdvice = getMoveDescription(currentPosition, target)
|
||||
target = MoveAdvice[1]
|
||||
if(MoveAdvice[0]==STEP):
|
||||
run(Vector2(target[0]-currentPosition[0], target[1]-currentPosition[1]), delta*10)
|
||||
targetField = target
|
||||
targetFieldUsed = true
|
||||
movmentState = STEP
|
||||
elif(MoveAdvice[0]==ROLL):
|
||||
roll(Vector2(target[0]-currentPosition[0], target[1]-currentPosition[1]), delta*10)
|
||||
targetFieldUsed = true
|
||||
targetField = target
|
||||
ExecutionState = EXECUTING
|
||||
grid.reset_history()
|
||||
elif ExecutionState == EXECUTING:
|
||||
if(targetFieldUsed):
|
||||
var cur = grid._pixel_to_grid_coords(global_position)
|
||||
var distance = sqrt(pow(cur[0]-targetField[0],2)+ pow(cur[1]-targetField[1],2))
|
||||
if(distance<0.01):
|
||||
targetFieldUsed = false
|
||||
ExecutionState = AI_MOVE
|
||||
else:
|
||||
var currentPosition = grid._pixel_to_grid_coords(global_position)
|
||||
if(movmentState==STEP):
|
||||
run(Vector2(targetField[0]-currentPosition[0], targetField[1]-currentPosition[1]), delta*10)
|
||||
elif(movmentState==ROLL):
|
||||
roll(Vector2(targetField[0]-currentPosition[0], targetField[1]-currentPosition[1]), delta*10)
|
||||
else:
|
||||
ExecutionState = AI_MOVE
|
||||
pass
|
||||
|
||||
|
||||
# API Interface for ai_hero -> methods are handled in player.gd
|
||||
func attac(direction, delta):
|
||||
pass
|
||||
|
||||
|
||||
func roll(direction, delta):
|
||||
pass
|
||||
|
||||
|
||||
func run(direction, delta):
|
||||
pass
|
||||
53
src/Overlap/AI/prio_queue.gd
Normal file
53
src/Overlap/AI/prio_queue.gd
Normal file
@@ -0,0 +1,53 @@
|
||||
extends Node
|
||||
|
||||
# Priority Queue implementation with binary heap
|
||||
var heaplist
|
||||
var currentSize
|
||||
|
||||
# node layout [g+h(x), g(x), position]
|
||||
|
||||
func _init():
|
||||
heaplist = [[0]]
|
||||
currentSize = 0
|
||||
|
||||
func percUp(i):
|
||||
while floor(i / 2) > 0:
|
||||
if heaplist[i][0] < heaplist[floor(i / 2)][0]:
|
||||
var tmp = heaplist[floor(i / 2)]
|
||||
heaplist[floor(i / 2)] = heaplist[i]
|
||||
heaplist[i] = tmp
|
||||
i = floor(i / 2)
|
||||
|
||||
func insert(k):
|
||||
heaplist.append(k)
|
||||
currentSize += 1
|
||||
percUp(currentSize)
|
||||
|
||||
func percDown(i):
|
||||
while (i * 2) <= currentSize:
|
||||
var mc = minChild(i)
|
||||
if heaplist[i][0] > heaplist[mc][0]:
|
||||
var tmp = heaplist[i]
|
||||
heaplist[i] = heaplist[mc]
|
||||
heaplist[mc] = tmp
|
||||
i = mc
|
||||
|
||||
func minChild(i):
|
||||
if i * 2 + 1 > currentSize:
|
||||
return i * 2
|
||||
else:
|
||||
if heaplist[i*2][0] < heaplist[i*2+1][0]:
|
||||
return i * 2
|
||||
else:
|
||||
return i * 2 + 1
|
||||
|
||||
func delMin():
|
||||
var retval = heaplist[1]
|
||||
heaplist[1] = heaplist[currentSize]
|
||||
heaplist.remove(currentSize - 1)
|
||||
currentSize -= 1
|
||||
percDown(1)
|
||||
return retval
|
||||
|
||||
func empty():
|
||||
return currentSize < 1
|
||||
28
src/Overlap/Kind.gd
Normal file
28
src/Overlap/Kind.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends Node
|
||||
|
||||
enum {
|
||||
BOSS = 0,
|
||||
PLAYER,
|
||||
TORCH,
|
||||
MINION,
|
||||
RED,
|
||||
BLUE,
|
||||
GREEN,
|
||||
HEART,
|
||||
BONFIRE,
|
||||
BARREL,
|
||||
TERMINAL_SYMBOL
|
||||
}
|
||||
|
||||
enum{
|
||||
DAMAGE = 0,
|
||||
HEALING,
|
||||
SLOW,
|
||||
WALL,
|
||||
FIELD
|
||||
}
|
||||
|
||||
export(int, "DAMAGE","HEALING","SLOW","WALL","FIELD") var general = DAMAGE
|
||||
export(int,"BOSS","PLAYER","TORCH","MINION","RED","BLUE","GREEN","HEART","BONFIRE","BARREL","TERMINAL_SYMBOL") var kind = BOSS
|
||||
|
||||
|
||||
6
src/Overlap/Kind.tscn
Normal file
6
src/Overlap/Kind.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/Kind.gd" type="Script" id=1]
|
||||
|
||||
[node name="Kind" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
@@ -1,97 +0,0 @@
|
||||
extends Node
|
||||
|
||||
enum{
|
||||
BOSS,
|
||||
TORCH,
|
||||
MINION,
|
||||
RED,
|
||||
BLUE,
|
||||
GREEN,
|
||||
HEART,
|
||||
BONFIRE,
|
||||
BARREL,
|
||||
TERMINAL_SYMBOL
|
||||
}
|
||||
|
||||
enum{
|
||||
LENGTH,
|
||||
WAY
|
||||
}
|
||||
|
||||
var numbers = [0,0,0,0,0,0,0,0,0]
|
||||
var prios = [7,6,5,4,3,2,0,0,4]
|
||||
|
||||
var totalPrioTurn = 0
|
||||
var executesTurn = false
|
||||
var abortProb = 0.01
|
||||
|
||||
func calcTotalPrio():
|
||||
var sum = 0
|
||||
var i = BOSS
|
||||
while i != TERMINAL_SYMBOL:
|
||||
if(numbers[i]>0):
|
||||
sum += prios[i]
|
||||
i=i+1
|
||||
return sum
|
||||
|
||||
func calcRelPrio(index, sum):
|
||||
return prios[index]/sum
|
||||
|
||||
func calcPrioTable():
|
||||
var table = [0,0,0,0,0,0,0,0,0]
|
||||
var lower = 0
|
||||
var sum = calcTotalPrio()
|
||||
|
||||
var i = 0;
|
||||
while i != TERMINAL_SYMBOL:
|
||||
lower += calcRelPrio(i, sum)
|
||||
table[i] = lower
|
||||
i = i+1
|
||||
|
||||
return table
|
||||
|
||||
func adjustPrio(currentHealth, maxHealth):
|
||||
var prioVal = 10 - (currentHealth/maxHealth)*10
|
||||
var bonfire = prioVal
|
||||
var hearts = prioVal -1
|
||||
if(hearts < 0):
|
||||
hearts = 0
|
||||
prios[BONFIRE]=bonfire
|
||||
prios[HEART]=hearts
|
||||
|
||||
func calcEnemie():
|
||||
var table = calcPrioTable()
|
||||
var number = randf()
|
||||
var i = TERMINAL_SYMBOL-1
|
||||
while table[i] > number:
|
||||
i=i-1
|
||||
return i
|
||||
|
||||
func getMoveDescription(myPosition : Vector2, targetPositions):
|
||||
var way = AStar(myPosition, targetPositions[0])
|
||||
|
||||
for i in range(1, targetPositions.size()):
|
||||
var tmp_way = AStar(myPosition, targetPositions[i])
|
||||
if(tmp_way[LENGTH] < way[LENGTH]):
|
||||
way = tmp_way
|
||||
return way[WAY]
|
||||
|
||||
func h(curr, targ):
|
||||
return sqrt(pow(curr,2)+pow(targ,2))
|
||||
|
||||
func h(curr, position):
|
||||
|
||||
|
||||
func AStar(source, target):
|
||||
pass
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
prios[BOSS] = 1
|
||||
|
||||
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
@@ -1,4 +1,4 @@
|
||||
extends KinematicBody2D
|
||||
extends Hero
|
||||
class_name Player
|
||||
"""
|
||||
This is an example player controller script created by Paul
|
||||
@@ -27,7 +27,8 @@ export(String, FILE, "*.tscn,*.scn") var title_scene = ""
|
||||
enum moveState{
|
||||
MOVE,
|
||||
ROLL,
|
||||
HIT
|
||||
HIT,
|
||||
IDLE
|
||||
}
|
||||
|
||||
|
||||
@@ -43,35 +44,77 @@ var experience := 0.0
|
||||
func _debug_update():
|
||||
debug_label.text = str(player_stats.health) + "/" + str(player_stats.max_health) + " HP\n" + str(currency) + " €"
|
||||
|
||||
func _ready():
|
||||
grid = get_tree().current_scene.get_child(3)
|
||||
|
||||
func _physics_process(delta):
|
||||
totaldamage+=(damage_per_second - heal_per_second)*delta
|
||||
player_stats.speed+=10*delta
|
||||
while(totaldamage>1):
|
||||
totaldamage-=1
|
||||
totaldamage -= 1
|
||||
player_stats.health-=1
|
||||
while(totaldamage<-1):
|
||||
while(totaldamage < -1):
|
||||
totaldamage+=1
|
||||
player_stats.health+=1
|
||||
#adjustPrio(player_stats.health, player_stats.max_health)
|
||||
_debug_update()
|
||||
if debug == true:
|
||||
match movementState:
|
||||
moveState.MOVE:
|
||||
movement_move(delta)
|
||||
moveState.IDLE:
|
||||
movement_move(delta)
|
||||
moveState.ROLL:
|
||||
movement_roll()
|
||||
moveState.HIT:
|
||||
movement_hit()
|
||||
|
||||
$"Effects/HealEffect".emitting = heal_per_second > 0
|
||||
else:
|
||||
if movementState == moveState.ROLL:
|
||||
movement_roll()
|
||||
elif movementState == moveState.HIT:
|
||||
movement_hit()
|
||||
elif movementState == moveState.IDLE:
|
||||
movement_idle()
|
||||
else:
|
||||
movement_run(Vector2(0,0), delta)
|
||||
makeMove(delta)
|
||||
move()
|
||||
$"Effects/HealEffect".emitting = heal_per_second > 0
|
||||
|
||||
# IMPORTANT: If you are using move_and_slide don't multiply by delta
|
||||
# Godots physics system does that internally
|
||||
# In move_and_collide(...) you have to multiply by delta.
|
||||
func move():
|
||||
move_and_slide(velocity)
|
||||
|
||||
|
||||
# API Interface for ai_hero
|
||||
func attac(direction, delta):
|
||||
direction = direction.normalized()
|
||||
rollvector = direction
|
||||
movementState = moveState.HIT
|
||||
|
||||
|
||||
# API Interface for ai_hero
|
||||
func roll(direction, delta):
|
||||
direction = direction.normalized()
|
||||
rollvector = direction
|
||||
movementState = moveState.ROLL
|
||||
|
||||
|
||||
# API Interface for ai_hero
|
||||
func run(direction, delta):
|
||||
direction = direction.normalized()
|
||||
rollvector = direction
|
||||
movementState = moveState.MOVE
|
||||
velocity = velocity.move_toward(player_stats.speed * rollvector, ACCELERATION * delta)
|
||||
|
||||
if direction == Vector2.ZERO:
|
||||
animation_state.change_state("idle")
|
||||
else:
|
||||
animation_state.change_state("run")
|
||||
|
||||
|
||||
func movement_move(delta):
|
||||
|
||||
var input_vector = Vector2.ZERO
|
||||
@@ -89,21 +132,23 @@ func movement_move(delta):
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
rollvector = input_vector
|
||||
animation_state.change_state("run")
|
||||
|
||||
animation_state.change_state("run")
|
||||
velocity = velocity.move_toward(player_stats.speed * input_vector, ACCELERATION * delta)
|
||||
if Input.is_action_just_pressed("roll"):
|
||||
movementState = moveState.ROLL
|
||||
elif Input.is_action_just_pressed("attack"):
|
||||
movementState = moveState.HIT
|
||||
|
||||
|
||||
|
||||
func movement_hit():
|
||||
velocity = Vector2.ZERO
|
||||
animation_state.change_state("attack")
|
||||
|
||||
func hit_finished():
|
||||
movementState = moveState.MOVE
|
||||
|
||||
movementState = moveState.IDLE
|
||||
ExecutionState = AI_MOVE
|
||||
|
||||
|
||||
func movement_roll():
|
||||
velocity = rollvector * ROLL_SPEED
|
||||
animation_state.change_state("roll")
|
||||
@@ -116,10 +161,11 @@ func movement_roll():
|
||||
func update():
|
||||
owner.velocity = rollvector * ROLL_SPEED
|
||||
"""
|
||||
|
||||
ExecutionState = EXECUTING
|
||||
|
||||
func roll_finished():
|
||||
movementState = moveState.MOVE
|
||||
movementState = moveState.IDLE
|
||||
ExecutionState = AI_MOVE
|
||||
|
||||
|
||||
func _on_Hurtbox_area_entered(area):
|
||||
@@ -142,12 +188,20 @@ func _on_Hurtbox_area_exited(area):
|
||||
|
||||
func _on_Stats_no_health():
|
||||
queue_free()
|
||||
get_tree().change_scene(title_scene)
|
||||
get_tree().change_scene("res://Menus/TitleScreen/TitleScreen.tscn")
|
||||
|
||||
|
||||
func _on_Hitbox_area_entered(area):
|
||||
currency += area.currency_value
|
||||
player_stats.health = player_stats.health+area.health_value
|
||||
player_stats.speed -= area.slowdown_value
|
||||
|
||||
|
||||
|
||||
|
||||
func movement_run(direction, delta):
|
||||
run(direction, delta)
|
||||
|
||||
|
||||
func movement_idle():
|
||||
movementState = moveState.IDLE
|
||||
velocity = Vector2.ZERO
|
||||
animation_state.travel("idle")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=62 format=2]
|
||||
[gd_scene load_steps=63 format=2]
|
||||
|
||||
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Player/player.png" type="Texture" id=2]
|
||||
@@ -6,7 +6,8 @@
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Overlap/Stats/Stats.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://Fonts/Harmonic/Harmonic.ttf" type="DynamicFontData" id=6]
|
||||
[ext_resource path="res://Effects/Heal/HealEffect.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://Effects/Heal/HealEffect.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://Player/States/Idle.gd" type="Script" id=12]
|
||||
[ext_resource path="res://Player/States/Run.gd" type="Script" id=13]
|
||||
[ext_resource path="res://Player/States/Attack.gd" type="Script" id=14]
|
||||
@@ -626,7 +627,9 @@ font_data = ExtResource( 6 )
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
FRICTION = 270
|
||||
title_scene = "res://Menus/TitleScreen/TitleScreen.tscn"
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 7 )]
|
||||
kind = 1
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.273621, 3.88423 )
|
||||
@@ -688,7 +691,7 @@ shape = SubResource( 47 )
|
||||
|
||||
[node name="Pivot" type="Position2D" parent="."]
|
||||
position = Vector2( 0, -4.16248 )
|
||||
rotation = 1.5708
|
||||
rotation = 3.14159
|
||||
__meta__ = {
|
||||
"_gizmo_extents_": 20.0
|
||||
}
|
||||
@@ -736,7 +739,7 @@ script = ExtResource( 16 )
|
||||
|
||||
[node name="Effects" type="Node2D" parent="."]
|
||||
|
||||
[node name="HealEffect" parent="Effects" instance=ExtResource( 7 )]
|
||||
[node name="HealEffect" parent="Effects" instance=ExtResource( 8 )]
|
||||
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
||||
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
||||
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
|
||||
|
||||
130
src/World.tscn
130
src/World.tscn
@@ -1,41 +1,32 @@
|
||||
[gd_scene load_steps=21 format=2]
|
||||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://World.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Maps/Tilesets/Room/tileset_room.tres" type="TileSet" id=3]
|
||||
[ext_resource path="res://testSprites/dark.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Objects/Traps/Bear.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://Objects/Banana/Banana.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://Objects/Bonfire/Bonfire.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://Objects/Traps/Sting.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://Objects/Rubies/Blue.tscn" type="PackedScene" id=9]
|
||||
[ext_resource path="res://Objects/Barrel/Barrel.tscn" type="PackedScene" id=10]
|
||||
[ext_resource path="res://Objects/Heart/Heart.tscn" type="PackedScene" id=11]
|
||||
[ext_resource path="res://Objects/Rubies/Red.tscn" type="PackedScene" id=12]
|
||||
[ext_resource path="res://Objects/Rubies/Green.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://Objects/Traps/Flame.tscn" type="PackedScene" id=14]
|
||||
[ext_resource path="res://Objects/Traps/Spike.tscn" type="PackedScene" id=15]
|
||||
[ext_resource path="res://Objects/Slime/Slime.tscn" type="PackedScene" id=16]
|
||||
[ext_resource path="res://Boss/Boss_template.tscn" type="PackedScene" id=17]
|
||||
[ext_resource path="res://Boss/SlimeBoss/SlimeBoss.tscn" type="PackedScene" id=18]
|
||||
[ext_resource path="res://Menus/DialogueBox/DialogueBox.tscn" type="PackedScene" id=19]
|
||||
[ext_resource path="res://Menus/DragNDrop/DragNDropUI.tscn" type="PackedScene" id=20]
|
||||
[ext_resource path="res://Menus/DragNDrop/DragNDropUI.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://Menus/DialogueBox/DialogueBox.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://Boss/Boss_template.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://Objects/Bonfire/Bonfire.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://Maps/Grid.tscn" type="PackedScene" id=18]
|
||||
|
||||
[sub_resource type="AnimationNodeStateMachinePlayback" id=1]
|
||||
|
||||
[node name="World" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="WallSprite" type="Sprite" parent="."]
|
||||
position = Vector2( 357.587, 175.62 )
|
||||
position = Vector2( 355.382, 175.62 )
|
||||
texture = ExtResource( 4 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 1280, 720 )
|
||||
|
||||
[node name="FloorTileMap" type="TileMap" parent="."]
|
||||
position = Vector2( -16, 16 )
|
||||
position = Vector2( 16, 16 )
|
||||
tile_set = ExtResource( 3 )
|
||||
cell_size = Vector2( 32, 32 )
|
||||
format = 1
|
||||
tile_data = PoolIntArray( -65537, 47, 0, -131072, 47, 1, -131071, 47, 1, -131070, 47, 1, -131069, 47, 1, -131068, 47, 1, -131067, 47, 1, -131066, 47, 1, -131065, 47, 1, -131064, 47, 1, -131063, 47, 1, -131062, 47, 1, -131061, 47, 1, -131060, 47, 1, -131059, 47, 1, -131058, 47, 1, -131057, 47, 1, -131056, 47, 2, -1, 47, 65536, -65536, 47, 65541, -65535, 47, 131073, -65534, 47, 131073, -65533, 47, 131073, -65532, 47, 131073, -65531, 47, 131073, -65530, 47, 131073, -65529, 47, 131073, -65528, 47, 131073, -65527, 47, 131073, -65526, 47, 65544, -65525, 47, 131073, -65524, 47, 131073, -65523, 47, 131073, -65522, 47, 131073, -65521, 47, 65542, -65520, 47, 65538, 65535, 47, 65536, 0, 47, 65538, 10, 47, 65539, 15, 47, 65536, 16, 47, 65538, 131071, 47, 65536, 65536, 47, 65538, 65546, 47, 65539, 65549, 47, 3, 65551, 47, 65536, 65552, 47, 65538, 196607, 47, 65536, 131072, 47, 65538, 131077, 47, 3, 131082, 47, 65539, 131085, 47, 65539, 131087, 47, 65536, 131088, 47, 65538, 262143, 47, 65536, 196608, 47, 65538, 196612, 47, 196608, 196613, 47, 262152, 196614, 47, 196610, 196618, 47, 65539, 196621, 47, 196612, 196622, 47, 196609, 196623, 47, 262150, 196624, 47, 65538, 327679, 47, 65536, 262144, 47, 65538, 262149, 47, 131075, 262154, 47, 65539, 262159, 47, 65536, 262160, 47, 65538, 393215, 47, 65536, 327680, 47, 65538, 327690, 47, 196612, 327691, 47, 196610, 327695, 47, 65536, 327696, 47, 65538, 458751, 47, 65536, 393216, 47, 65538, 393231, 47, 65536, 393232, 47, 65538, 524287, 47, 65536, 458752, 47, 131077, 458753, 47, 1, 458754, 47, 1, 458755, 47, 1, 458756, 47, 1, 458757, 47, 1, 458758, 47, 1, 458759, 47, 1, 458760, 47, 1, 458761, 47, 1, 458762, 47, 1, 458763, 47, 1, 458764, 47, 1, 458765, 47, 1, 458766, 47, 1, 458767, 47, 131078, 458768, 47, 65538, 589823, 47, 131072, 524288, 47, 131073, 524289, 47, 131073, 524290, 47, 131073, 524291, 47, 131073, 524292, 47, 131073, 524293, 47, 131073, 524294, 47, 131073, 524295, 47, 131073, 524296, 47, 131073, 524297, 47, 131073, 524298, 47, 131073, 524299, 47, 131073, 524300, 47, 131073, 524301, 47, 131073, 524302, 47, 131073, 524303, 47, 131073, 524304, 47, 131074 )
|
||||
tile_data = PoolIntArray( -1, 47, 4, -65536, 47, 196609, -65535, 47, 196609, -65534, 47, 196609, -65533, 47, 196609, -65532, 47, 196609, -65531, 47, 196609, -65530, 47, 196609, -65529, 47, 196609, -65528, 47, 196609, -65527, 47, 196609, -65526, 47, 196609, -65525, 47, 196609, -65524, 47, 196609, -65523, 47, 196609, -65522, 47, 7, 65535, 47, 65539, 14, 47, 65539, 131071, 47, 65539, 65545, 47, 4, 65546, 47, 196609, 65547, 47, 196610, 65550, 47, 65539, 196607, 47, 65539, 131081, 47, 65539, 131086, 47, 65539, 262143, 47, 65539, 196617, 47, 196612, 196618, 47, 196609, 196619, 47, 7, 196622, 47, 65539, 327679, 47, 65539, 262155, 47, 65539, 262158, 47, 65539, 393215, 47, 65539, 327689, 47, 196608, 327690, 47, 196609, 327691, 47, 196615, 327694, 47, 65539, 458751, 47, 65539, 393230, 47, 65539, 524287, 47, 196612, 458752, 47, 196609, 458753, 47, 196609, 458754, 47, 196609, 458755, 47, 196609, 458756, 47, 196609, 458757, 47, 196609, 458758, 47, 196609, 458759, 47, 196609, 458760, 47, 196609, 458761, 47, 196609, 458762, 47, 196609, 458763, 47, 196609, 458764, 47, 196609, 458765, 47, 196609, 458766, 47, 196615 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true,
|
||||
"_edit_lock_": true
|
||||
@@ -44,98 +35,29 @@ __meta__ = {
|
||||
[node name="YSort" type="YSort" parent="."]
|
||||
position = Vector2( 152, 120 )
|
||||
|
||||
[node name="SlimeBoss" parent="YSort" instance=ExtResource( 18 )]
|
||||
position = Vector2( 88, 75.4221 )
|
||||
|
||||
[node name="Boss_template" parent="YSort" instance=ExtResource( 17 )]
|
||||
position = Vector2( -107.855, -54.5179 )
|
||||
|
||||
[node name="minion" parent="YSort" instance=ExtResource( 17 )]
|
||||
position = Vector2( 88, 24 )
|
||||
scale = Vector2( 0.3, 0.3 )
|
||||
collision_layer = 8
|
||||
|
||||
[node name="Bear_trap" parent="YSort" instance=ExtResource( 5 )]
|
||||
position = Vector2( 68.1447, -38.5179 )
|
||||
|
||||
[node name="Slime" parent="YSort" instance=ExtResource( 16 )]
|
||||
position = Vector2( 68.1447, 57.4821 )
|
||||
|
||||
[node name="Flame" parent="YSort" instance=ExtResource( 14 )]
|
||||
position = Vector2( 124.145, 65.4821 )
|
||||
|
||||
[node name="Spike" parent="YSort" instance=ExtResource( 15 )]
|
||||
position = Vector2( 272, 88 )
|
||||
|
||||
[node name="Sting" parent="YSort" instance=ExtResource( 8 )]
|
||||
position = Vector2( 132.145, 17.4821 )
|
||||
|
||||
[node name="Heart" parent="YSort" instance=ExtResource( 11 )]
|
||||
position = Vector2( -43.8553, 65.4821 )
|
||||
|
||||
[node name="Blue" parent="YSort" instance=ExtResource( 9 )]
|
||||
position = Vector2( -3.8553, 81.4821 )
|
||||
|
||||
[node name="Red" parent="YSort" instance=ExtResource( 12 )]
|
||||
position = Vector2( -51.8553, 41.4821 )
|
||||
|
||||
[node name="Green" parent="YSort" instance=ExtResource( 13 )]
|
||||
position = Vector2( -19.8553, 73.4821 )
|
||||
|
||||
[node name="Barrel" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( 8.00002, -32 )
|
||||
|
||||
[node name="Barrel5" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( 8.00002, -96 )
|
||||
|
||||
[node name="Barrel6" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( -128, 16 )
|
||||
|
||||
[node name="Barrel7" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( -56, 16 )
|
||||
|
||||
[node name="Barrel8" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( -72, 16 )
|
||||
|
||||
[node name="Barrel9" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( -88, 16 )
|
||||
|
||||
[node name="Barrel10" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( -104, 16 )
|
||||
|
||||
[node name="Barrel11" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( -120, 16 )
|
||||
|
||||
[node name="Barrel2" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( 8.00002, -48 )
|
||||
|
||||
[node name="Barrel3" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( 8.00002, -64 )
|
||||
|
||||
[node name="Barrel4" parent="YSort" instance=ExtResource( 10 )]
|
||||
position = Vector2( 8.00002, -80 )
|
||||
|
||||
[node name="Banana" parent="YSort" instance=ExtResource( 6 )]
|
||||
position = Vector2( -107.855, 73.4821 )
|
||||
|
||||
[node name="Player" parent="YSort" instance=ExtResource( 1 )]
|
||||
position = Vector2( 96, -69.5179 )
|
||||
position = Vector2( 176, 112 )
|
||||
scale = Vector2( 2, 2 )
|
||||
debug = true
|
||||
FRICTION = 200
|
||||
|
||||
[node name="Bonfire" parent="YSort" instance=ExtResource( 7 )]
|
||||
position = Vector2( 296, -16 )
|
||||
[node name="AnimationTree" parent="YSort/Player" index="4"]
|
||||
parameters/playback = SubResource( 1 )
|
||||
|
||||
[node name="Boss_template" parent="YSort" instance=ExtResource( 7 )]
|
||||
position = Vector2( -67.0889, 2.27742 )
|
||||
|
||||
[node name="Bonfire" parent="YSort" instance=ExtResource( 8 )]
|
||||
position = Vector2( 214.647, -24.9932 )
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="DragNDropUI" parent="CanvasLayer" instance=ExtResource( 20 )]
|
||||
[node name="DialogueBox" parent="CanvasLayer" instance=ExtResource( 6 )]
|
||||
visible = false
|
||||
|
||||
[node name="DragNDropUI" parent="CanvasLayer" instance=ExtResource( 5 )]
|
||||
ObjectParent = NodePath("../..")
|
||||
|
||||
[node name="DialogueBox" parent="CanvasLayer" instance=ExtResource( 19 )]
|
||||
anchor_bottom = 0.0
|
||||
margin_bottom = 31.0
|
||||
[node name="Grid" parent="." instance=ExtResource( 18 )]
|
||||
|
||||
[editable path="YSort/minion"]
|
||||
|
||||
[editable path="YSort/minion/Hurtbox"]
|
||||
[editable path="YSort/Player"]
|
||||
|
||||
@@ -20,6 +20,11 @@ _global_script_classes=[ {
|
||||
"path": "res://Menus/DialogueBox/DialogueBox.gd"
|
||||
}, {
|
||||
"base": "KinematicBody2D",
|
||||
"class": "Hero",
|
||||
"language": "GDScript",
|
||||
"path": "res://Overlap/AI/AI_Hero.gd"
|
||||
}, {
|
||||
"base": "Hero",
|
||||
"class": "Player",
|
||||
"language": "GDScript",
|
||||
"path": "res://Player/Player.gd"
|
||||
@@ -42,6 +47,7 @@ _global_script_classes=[ {
|
||||
_global_script_class_icons={
|
||||
"Boss": "",
|
||||
"DialougeBox": "",
|
||||
"Hero": "",
|
||||
"Player": "",
|
||||
"SlimeBoss": "",
|
||||
"TitleSceenButton": "",
|
||||
|
||||
Reference in New Issue
Block a user