ai adaptation

This commit is contained in:
Jonas Mucke
2020-04-20 13:15:24 +02:00
parent b8b026d063
commit 3ec908f6c3
12 changed files with 399 additions and 93 deletions

View File

@@ -1,4 +1,4 @@
extends KinematicBody2D
extends Minion
var velocity := Vector2.ZERO
@@ -12,9 +12,14 @@ onready var debug_label := $DebugLabel
var damage_per_second := 0.0
var totaldamage := 0.0
var rollvector = Vector2.ZERO
func _debug_update():
debug_label.text = str(player_stats.health) + "/" + str(player_stats.max_health) + " HP\n"
func _ready():
grid = get_tree().current_scene.get_node("Grid")
# 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.
@@ -31,6 +36,9 @@ func _physics_process(delta):
totaldamage += 1
player_stats.health += 1
_debug_update()
run(Vector2.ZERO, delta)
makeMove(delta)
move()
@@ -45,3 +53,14 @@ func _on_Hurtbox_area_entered(area):
func _on_Hurtbox_area_exited(area):
damage_per_second -= area.damage
# API Interface for ai_hero
func run(direction, delta):
direction = direction.normalized()
rollvector = direction
velocity = velocity.move_toward(player_stats.speed * rollvector, ACCELERATION * delta)
if direction == Vector2.ZERO:
pass
else:
pass

View File

@@ -12,14 +12,15 @@ radius = 6.0
[sub_resource type="CapsuleShape2D" id=2]
radius = 11.0
height = 11.0
height = 1.0
[sub_resource type="CapsuleShape2D" id=3]
radius = 11.0
height = 11.0
height = 1.0
[node name="Minion" type="KinematicBody2D"]
script = ExtResource( 6 )
ACCELERATION = 500
[node name="Kind" parent="." instance=ExtResource( 3 )]
kind = 3
@@ -37,7 +38,7 @@ collision_layer = 0
collision_mask = 65
[node name="CollisionShape2D" parent="Hitbox" index="0"]
position = Vector2( 0, -9 )
position = Vector2( 0.110184, -4.81305 )
shape = SubResource( 2 )
[node name="Hurtbox" parent="." groups=[
@@ -47,7 +48,7 @@ collision_layer = 8
collision_mask = 128
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 0, -9 )
position = Vector2( 0.110184, -4.81305 )
shape = SubResource( 3 )
[node name="DebugLabel" type="Label" parent="."]
@@ -62,6 +63,7 @@ __meta__ = {
[node name="Stats" parent="." instance=ExtResource( 4 )]
max_health = 2
max_speed = 80.0
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]

View File

@@ -7,7 +7,7 @@ var prio_grid : Array = []
var used_grid : Array = []
var time_passed := 0.0
var offset
export(float, 0, 42.0) var refresh_rate = 1
export(float, 0, 42.0) var refresh_rate = 0.0
func _draw_object_grid():

View File

@@ -1,9 +1,9 @@
extends StaticBody2D
export(int,1,10) var health = 1
var GreenDrop = 0.5
var BlueDrop = 0.4
var RedDrop = 0.2
var GreenDrop = 0.4
var BlueDrop = 0.5
var RedDrop = 0.8
var Heart = 0.2
func offset_vec():

View File

@@ -11,9 +11,10 @@ extents = Vector2( 16, 16 )
[node name="Kind" parent="." instance=ExtResource( 3 )]
general = 2
kind = 2
kind = 10
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, 1.90735e-06 )
texture = ExtResource( 1 )
[node name="Hurtbox" parent="." instance=ExtResource( 2 )]

View File

@@ -1,7 +1,7 @@
extends Node2D
export(int, 1, 5) var lifePoints = 3
export(int, 1, 30) var spawnRate = 5.0
export(float, 0, 30) var spawnRate = 5.0
var Minion = load("res://Boss/Minion.tscn")
var elapsedTime = 0.0

View File

@@ -7,12 +7,6 @@ const Grid = preload("res://Maps/Grid.gd")
var grid
enum{
LENGTH,
WAY
}
enum{
STEP,
ROLL,
@@ -31,10 +25,6 @@ var ai_movement_state = 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 targetFieldCur = [0,0]
var targetFieldUsed = false
@@ -43,8 +33,9 @@ var actionFieldUsed = false
var areaRefList = []
var threadTime = 0.4
var threadTime = 0.6
var threadDelta = 0.0
#calculates the sum of all present prios
func calcTotalPrio():
var sum = 0
@@ -79,7 +70,7 @@ func calcPrioTable():
#14+7 0.999
#updates heart and bonfire prio
func adjustPrio(currentHealth, maxHealth):
var prioVal = 40.0 - (float(currentHealth)/float(maxHealth))*40.0
var prioVal = 10.0 - (float(currentHealth)/float(maxHealth))*10.0
var bonfire = prioVal + 1
var hearts = prioVal
if(hearts < 0):
@@ -106,16 +97,16 @@ func getCost(field):
for i in grid.object_grid[field.x][field.y]:
match i:
Grid.Kind.DAMAGE:
cost += prios[Grid.Kind.BONFIRE] * 32
cost += 100
Grid.Kind.SLOW:
cost += 1
cost += 1
return cost
#return an heurestic of distance
# curr - current position
# targ - a target position
func h_fn(curr, target):
return sqrt(pow(target[0]-curr[0],2)+pow(target[0]-curr[0],2))
return 0
# currCost - currentCost
# target - position of the field to move to
@@ -127,13 +118,13 @@ func adjacent(currentPosition, can_roll = true):
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_step = [[p[0]-1, 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]+0],
[p[0]-1, p[1]+1], [p[0]+0, p[1]+1], [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]]
var pot_adj_roll = [[p[0]-0, p[1]-2],
[p[0]-2, p[1]-0],[p[0]+2, p[1]+0],
[p[0]+0, p[1]+2]]
for i in range(pot_adj_step.size()):
@@ -148,6 +139,8 @@ func adjacent(currentPosition, can_roll = true):
continue
if(grid.used_grid[next[0]][next[1]]):
continue
if(grid._is_in_grid(Vector2(next[0], next[1])) ==false):
continue
if(grid.object_grid[next[0]][next[1]][0]!=Grid.Kind.WALL):
if(i==0):
if(grid.object_grid[pot_adj_step[1][0]][pot_adj_step[1][1]][0]!=Grid.Kind.WALL &&
@@ -172,6 +165,7 @@ func adjacent(currentPosition, can_roll = true):
adj.append([STEP, Vector2(next[0],next[1]),1.0])
for i in range(pot_adj_roll.size()):
var next = pot_adj_roll[i]
if(next[0]<0):
@@ -184,49 +178,21 @@ func adjacent(currentPosition, can_roll = true):
continue
if(grid.used_grid[next[0]][next[1]]):
continue
if(grid.object_grid[next[0]][next[1]][0]!=Grid.Kind.WALL):
continue
if(grid._is_in_grid(Vector2(next[0], next[1])) == false):
continue
if(grid.object_grid[next[0]][next[1]][0]!=Grid.Kind.WALL):
if(i==0):
if(grid.object_grid[next[0]+0][next[1]+1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+1][next[1]+0][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+1][next[1]+1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+1][next[1]+2][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+2][next[1]+1][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.1])
if(i==1):
if(grid.object_grid[next[0]+0][next[1]+1][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.0])
if(i==2):
if(grid.object_grid[next[0]-0][next[1]+1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-1][next[1]+0][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-1][next[1]+1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-1][next[1]+2][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-2][next[1]+1][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.1])
if(i==3):
adj.append([ROLL, Vector2(next[0],next[1]),1.0])
if(i==1):
if(grid.object_grid[next[0]+1][next[1]+0][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.0])
if(i==4):
adj.append([ROLL, Vector2(next[0],next[1]),1.0])
if(i==2):
if(grid.object_grid[next[0]-1][next[1]+0][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.0])
if(i==5):
if(grid.object_grid[next[0]+0][next[1]-1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+1][next[1]-0][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+1][next[1]-1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+1][next[1]-2][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]+2][next[1]-1][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.1])
if(i==6):
adj.append([ROLL, Vector2(next[0],next[1]),1.0])
if(i==3):
if(grid.object_grid[next[0]+0][next[1]-1][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.0])
if(i==7):
if(grid.object_grid[next[0]-0][next[1]-1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-1][next[1]-0][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-1][next[1]-1][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-1][next[1]-2][0]!=Grid.Kind.WALL &&
grid.object_grid[next[0]-2][next[1]-1][0]!=Grid.Kind.WALL):
adj.append([ROLL, Vector2(next[0],next[1]),2.1])
adj.append([ROLL, Vector2(next[0],next[1]),1.0])
return adj
@@ -250,6 +216,7 @@ func AStar(source, target):
# Set flag
grid.used_grid[node[2][0]][node[2][1]] = true
var adj_list = adjacent(node[2])
var current_field = node[2]
for i in adj_list:
var move_cost = i[2]
@@ -267,7 +234,9 @@ func movement_calulcaotr():
var currentPosition = grid._pixel_to_grid_coords(global_position)
var enemyKind
if(actionFieldUsed==false):
numbers = grid.countTargets(numbers)
if(actionKind == grid.Kind.TERMINAL_SYMBOL || numbers[actionKind]==0 || actionFieldUsed==false):
enemyKind = calcEnemyKind()
actionKind = enemyKind
actionFieldUsed = true
@@ -291,21 +260,19 @@ func is_hittable():
var length = areaRefList.size()
if length == 0:
return null
var randomNumber = randi()%length
return instance_from_id(areaRefList[randomNumber]).global_position
return instance_from_id(areaRefList[0]).global_position
func hit_or_miss(target, current, delta):
attac(Vector2(target[0]-current[0], target[1]-current[1]), delta*4)
func movement_decider_ai(target, kindOfStep, delta):
var currentPosition = grid._pixel_to_grid_coords(global_position)
var field_of_movement = target
var currentPixel = global_position
var hitPixelTarget = is_hittable()
if hitPixelTarget!=null:
hit_or_miss(hitPixelTarget, currentPixel, delta*4)
actionFieldUsed = false
else:
if(kindOfStep==STEP):
run(Vector2(target[0]-currentPosition[0], target[1]-currentPosition[1]), delta*4)
@@ -321,6 +288,13 @@ func movement_decider_ai(target, kindOfStep, delta):
func movement_execution(delta):
var currentPixel = global_position
var hitPixelTarget = is_hittable()
if hitPixelTarget!=null:
hit_or_miss(hitPixelTarget, currentPixel, delta*4)
return
if(targetFieldUsed):
var cur = grid._pixel_to_grid_coords(global_position)
var distance = sqrt(pow(cur[0]-targetFieldCur[0],2)+ pow(cur[1]-targetFieldCur[1],2))
@@ -346,13 +320,7 @@ func reset_exeution_state(delta):
func makeMove(delta):
#if(actionFieldUsed==true):
# var random = randf()
# if(random < mindChangeProbability):
# ExecutionState = AI_MOVE
func makeMove(delta):
if ExecutionState == AI_MOVE:
threadDelta = 0
var MoveAdvice = movement_calulcaotr()

265
src/Overlap/AI/AI_Minion.gd Normal file
View File

@@ -0,0 +1,265 @@
extends KinematicBody2D
class_name Minion
const PrioQueue = preload("prio_queue.gd") # Relative path
const Grid = preload("res://Maps/Grid.gd")
var grid
enum{
STEP,
NOTHING
}
enum{
EXECUTING,
AI_MOVE
}
var ExecutionState = AI_MOVE
var ai_movement_state = NOTHING
var numbers = [0,0,0,0,0,0,0,0,0,0]
var prios = [0,6,0,0,0,0,0,0,4,0]
var targetFieldCur = [0,0]
var targetFieldUsed = false
var actionKind = Grid.Kind.TERMINAL_SYMBOL
var actionFieldUsed = false
var threadTime = 0.4
var threadDelta = 0.0
#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
#14+7 0.999
#updates heart and bonfire prio
func adjustPrio(currentHealth, maxHealth):
return
#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):
return 0
#return an heurestic of distance
# curr - current position
# targ - a target position
func h_fn(curr, target):
return sqrt(pow(target[0]-curr[0],2)+pow(target[0]-curr[0],2))
# currCost - currentCost
# target - position of the field to move to
func g_fn(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]]
for i in range(pot_adj_step.size()):
var next = pot_adj_step[i]
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):
if(i==0):
if(grid.object_grid[pot_adj_step[1][0]][pot_adj_step[1][1]][0]!=Grid.Kind.WALL &&
grid.object_grid[pot_adj_step[3][0]][pot_adj_step[3][1]][0]!=Grid.Kind.WALL):
adj.append([STEP, Vector2(next[0],next[1]),1.1])
continue
if(i==2):
if(grid.object_grid[pot_adj_step[1][0]][pot_adj_step[1][1]][0]!=Grid.Kind.WALL &&
grid.object_grid[pot_adj_step[4][0]][pot_adj_step[4][1]][0]!=Grid.Kind.WALL):
adj.append([STEP, Vector2(next[0],next[1]),1.1])
continue
if(i==5):
if(grid.object_grid[pot_adj_step[3][0]][pot_adj_step[3][1]][0]!=Grid.Kind.WALL &&
grid.object_grid[pot_adj_step[6][0]][pot_adj_step[6][1]][0]!=Grid.Kind.WALL):
adj.append([STEP, Vector2(next[0],next[1]),1.1])
continue
if(i==7):
if(grid.object_grid[pot_adj_step[4][0]][pot_adj_step[4][1]][0]!=Grid.Kind.WALL &&
grid.object_grid[pot_adj_step[6][0]][pot_adj_step[6][1]][0]!=Grid.Kind.WALL):
adj.append([STEP, Vector2(next[0],next[1]),1.1])
continue
adj.append([STEP, Vector2(next[0],next[1]),1.0])
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 = i[2]
var g_val = g_fn(node[1]+move_cost, i[1])
var h_val = h_fn(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 movement_calulcaotr():
var currentPosition = grid._pixel_to_grid_coords(global_position)
var enemyKind
if(actionFieldUsed==false):
enemyKind = calcEnemyKind()
actionKind = enemyKind
actionFieldUsed = true
else:
enemyKind = actionKind
if(enemyKind==Grid.Kind.TERMINAL_SYMBOL):
return
var targetField = grid.get_nearest(currentPosition, enemyKind)
if(targetField==[-1,-1]):
return
var MoveAdvice = getMoveDescription(currentPosition, targetField)
grid.reset_history()
return MoveAdvice
func movement_decider_ai(target, kindOfStep, delta):
var currentPosition = grid._pixel_to_grid_coords(global_position)
var field_of_movement = target
var currentPixel = global_position
if(kindOfStep==STEP):
run(Vector2(target[0]-currentPosition[0], target[1]-currentPosition[1]), delta*4)
targetFieldCur = target
targetFieldUsed = true
ai_movement_state = STEP
ExecutionState = EXECUTING
func movement_execution(delta):
if(targetFieldUsed):
var cur = grid._pixel_to_grid_coords(global_position)
var distance = sqrt(pow(cur[0]-targetFieldCur[0],2)+ pow(cur[1]-targetFieldCur[1],2))
if(distance<0.1):
targetFieldUsed = false
ExecutionState = AI_MOVE
var actionField = grid.get_nearest(cur, actionKind)
if(targetFieldCur[0]==actionField[0]&&targetFieldCur[1]==actionField[1]):
actionFieldUsed = false
else:
var currentPosition = grid._pixel_to_grid_coords(global_position)
if(ai_movement_state==STEP):
run(Vector2(targetFieldCur[0]-currentPosition[0], targetFieldCur[1]-currentPosition[1]), delta*4)
func reset_exeution_state(delta):
threadDelta = threadDelta + delta
if(threadDelta>threadTime):
ExecutionState = AI_MOVE
actionFieldUsed = false
func makeMove(delta):
if ExecutionState == AI_MOVE:
threadDelta = 0
var MoveAdvice = movement_calulcaotr()
if(MoveAdvice==null):
return
var target = MoveAdvice[1]
movement_decider_ai(target, MoveAdvice[0], delta)
elif ExecutionState == EXECUTING:
movement_execution(delta)
reset_exeution_state(delta)
# API Interface for ai_hero -> methods are handled in player.gd
func run(direction, delta):
pass
#todo

View File

@@ -4,7 +4,7 @@ class_name Player
This is an example player controller script created by Paul
"""
var velocity := Vector2.ZERO
var rollvector := Vector2.ZERO
var rollvector := Vector2(-1,0)
# This is how you export variables with ranges to the editor window
export(bool) var debug := false
@@ -77,7 +77,7 @@ func _physics_process(delta):
elif movementState == moveState.IDLE:
movement_idle()
else:
movement_run(Vector2(0,0), delta)
movement_run(Vector2.ZERO, delta)
makeMove(delta)
move()
$"Effects/HealEffect".emitting = heal_per_second > 0
@@ -148,9 +148,11 @@ func movement_hit():
func hit_finished():
grid._update_grid()
movementState = moveState.IDLE
ai_movement_state = STEP
ExecutionState = EXECUTING
actionFieldUsed = false
func movement_roll():
@@ -179,15 +181,19 @@ func _on_Hurtbox_area_entered(area):
if area.damage > 0:
damage_per_second += area.damage
pass
else:
heal_per_second += abs(area.damage)
pass
func _on_Hurtbox_area_exited(area):
if area.damage > 0:
damage_per_second -= area.damage
pass
else:
heal_per_second -= abs(area.damage)
pass
func _on_Stats_no_health():

View File

@@ -617,10 +617,10 @@ height = 0.2
[sub_resource type="CapsuleShape2D" id=48]
radius = 4.03497
height = 6.99104
height = 9.42006
[sub_resource type="CircleShape2D" id=51]
radius = 14.7132
radius = 13.3924
[sub_resource type="DynamicFont" id=50]
size = 12
@@ -629,6 +629,7 @@ font_data = ExtResource( 6 )
[node name="Player" type="KinematicBody2D"]
scale = Vector2( 1.1, 1.1 )
script = ExtResource( 1 )
ROLL_SPEED = 120
FRICTION = 270
[node name="Kind" parent="." instance=ExtResource( 7 )]

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=2]
[gd_scene load_steps=16 format=2]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://World.gd" type="Script" id=2]
@@ -8,10 +8,15 @@
[ext_resource path="res://Menus/DialogueBox/DialogueBox.tscn" type="PackedScene" id=6]
[ext_resource path="res://Objects/Torch/Torch.tscn" type="PackedScene" id=7]
[ext_resource path="res://Objects/Barrel/Barrel.tscn" type="PackedScene" id=8]
[ext_resource path="res://Boss/Minion.tscn" type="PackedScene" id=9]
[ext_resource path="res://Objects/Bonfire/Bonfire.tscn" type="PackedScene" id=10]
[ext_resource path="res://Objects/Slime/Slime.tscn" type="PackedScene" id=11]
[ext_resource path="res://Objects/Traps/Sting.tscn" type="PackedScene" id=12]
[ext_resource path="res://Boss/Boss_template.tscn" type="PackedScene" id=17]
[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 )
@@ -26,7 +31,7 @@ position = Vector2( 16, 16 )
tile_set = ExtResource( 3 )
cell_size = Vector2( 32, 32 )
format = 1
tile_data = PoolIntArray( -131059, 47, 0, -131058, 47, 2, -1, 47, 4, -65536, 47, 196609, -65535, 47, 196609, -65534, 47, 196609, -65533, 47, 196609, -65532, 47, 196609, -65531, 47, 196609, -65530, 47, 8, -65529, 47, 196609, -65528, 47, 8, -65527, 47, 196609, -65526, 47, 196609, -65525, 47, 196609, -65524, 47, 196609, -65523, 47, 196614, -65522, 47, 196618, -65521, 47, 196610, 65535, 47, 65539, 6, 47, 131075, 8, 47, 131075, 14, 47, 65539, 131071, 47, 65539, 65541, 47, 196611, 65550, 47, 65539, 196607, 47, 65539, 131075, 47, 196608, 131076, 47, 196610, 131086, 47, 65539, 262143, 47, 65539, 196614, 47, 196611, 196622, 47, 65539, 327679, 47, 65539, 262147, 47, 196611, 262149, 47, 196611, 262158, 47, 65539, 393215, 47, 65539, 327684, 47, 196611, 327688, 47, 196611, 327694, 47, 65539, 458751, 47, 65539, 393221, 47, 3, 393225, 47, 3, 393230, 47, 65539, 524287, 47, 196612, 458752, 47, 196609, 458753, 47, 196609, 458754, 47, 196609, 458755, 47, 196609, 458756, 47, 196609, 458757, 47, 196616, 458758, 47, 196609, 458759, 47, 196609, 458760, 47, 196609, 458761, 47, 196616, 458762, 47, 196609, 458763, 47, 196609, 458764, 47, 196609, 458765, 47, 196609, 458766, 47, 196615 )
tile_data = PoolIntArray( -131059, 47, 0, -131058, 47, 2, -1, 47, 4, -65536, 47, 196609, -65535, 47, 196609, -65534, 47, 196609, -65533, 47, 196609, -65532, 47, 196609, -65531, 47, 196609, -65530, 47, 8, -65529, 47, 196609, -65528, 47, 8, -65527, 47, 196609, -65526, 47, 196609, -65525, 47, 196609, -65524, 47, 196609, -65523, 47, 196614, -65522, 47, 196618, -65521, 47, 196610, 65535, 47, 65539, 6, 47, 131075, 8, 47, 131075, 14, 47, 65539, 131071, 47, 65539, 65541, 47, 196611, 65550, 47, 65539, 196607, 47, 65539, 131075, 47, 196608, 131076, 47, 196610, 131086, 47, 65539, 262143, 47, 65539, 196614, 47, 196611, 196622, 47, 65539, 327679, 47, 65539, 262147, 47, 196611, 262149, 47, 196611, 262158, 47, 65539, 393215, 47, 65539, 327684, 47, 196611, 327694, 47, 65539, 458751, 47, 65539, 393221, 47, 3, 393230, 47, 65539, 524287, 47, 196612, 458752, 47, 196609, 458753, 47, 196609, 458754, 47, 196609, 458755, 47, 196609, 458756, 47, 196609, 458757, 47, 196616, 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
@@ -36,24 +41,53 @@ __meta__ = {
position = Vector2( 152, 120 )
[node name="Player" parent="YSort" instance=ExtResource( 1 )]
position = Vector2( 200, 8 )
position = Vector2( 136, 112 )
scale = Vector2( 2, 2 )
ROLL_SPEED = 140
FRICTION = 200
[node name="AnimationTree" parent="YSort/Player" index="4"]
parameters/playback = SubResource( 1 )
[node name="Stats" parent="YSort/Player" index="9"]
max_health = 20
[node name="Boss_template" parent="YSort" instance=ExtResource( 17 )]
position = Vector2( -56, 8 )
debug = true
[node name="Bonfire" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( 288, 104 )
[node name="Torch" parent="YSort" instance=ExtResource( 7 )]
position = Vector2( 264, -24 )
[node name="Barrel" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 40, 8 )
[node name="Torch" parent="YSort" instance=ExtResource( 7 )]
position = Vector2( -112, -72 )
spawnRate = 2.039
[node name="Minion" parent="YSort" instance=ExtResource( 9 )]
position = Vector2( 240, -40 )
[node name="Minion2" parent="YSort" instance=ExtResource( 9 )]
position = Vector2( 96, -80 )
[node name="Slime" parent="YSort" instance=ExtResource( 11 )]
position = Vector2( 104, 104 )
[node name="Slime2" parent="YSort" instance=ExtResource( 11 )]
position = Vector2( 168, 104 )
[node name="Slime3" parent="YSort" instance=ExtResource( 11 )]
position = Vector2( 136, 72 )
[node name="Slime4" parent="YSort" instance=ExtResource( 11 )]
position = Vector2( 168, 72 )
[node name="Slime5" parent="YSort" instance=ExtResource( 11 )]
position = Vector2( 104, 72 )
[node name="Sting" parent="YSort" instance=ExtResource( 12 )]
position = Vector2( 136, 48 )
[node name="Grid" parent="." instance=ExtResource( 18 )]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
@@ -62,6 +96,10 @@ position = Vector2( 40, 8 )
visible = false
[node name="DragNDropUI" parent="CanvasLayer" instance=ExtResource( 5 )]
margin_left = 0.0
margin_right = 0.0
ObjectParent = NodePath("../..")
[editable path="YSort/Player"]
[editable path="YSort/Bonfire"]

View File

@@ -24,6 +24,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://Overlap/AI/AI_Hero.gd"
}, {
"base": "KinematicBody2D",
"class": "Minion",
"language": "GDScript",
"path": "res://Overlap/AI/AI_Minion.gd"
}, {
"base": "Hero",
"class": "Player",
"language": "GDScript",
@@ -48,6 +53,7 @@ _global_script_class_icons={
"Boss": "",
"DialougeBox": "",
"Hero": "",
"Minion": "",
"Player": "",
"SlimeBoss": "",
"TitleSceenButton": "",