FABIOOO
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
[gd_scene load_steps=6 format=3 uid="uid://uoyiei4wyig3"]
 | 
			
		||||
[gd_scene load_steps=7 format=3 uid="uid://uoyiei4wyig3"]
 | 
			
		||||
 | 
			
		||||
[ext_resource type="Script" path="res://Scripts/level.gd" id="1_0nmok"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://b8s2seg2lf7wo" path="res://Scenes/Tilemaps/tileset_1.tscn" id="1_4n82n"]
 | 
			
		||||
[ext_resource type="PackedScene" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"]
 | 
			
		||||
[ext_resource type="PackedScene" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"]
 | 
			
		||||
@@ -7,6 +8,7 @@
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://0onqgygm832d" path="res://Scenes/Player/player.tscn" id="5_ik47y"]
 | 
			
		||||
 | 
			
		||||
[node name="Level1" type="Node2D"]
 | 
			
		||||
script = ExtResource("1_0nmok")
 | 
			
		||||
 | 
			
		||||
[node name="TileSet1" parent="." instance=ExtResource("1_4n82n")]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -403,6 +403,9 @@ color = Color(0.623529, 0, 0, 0.729412)
 | 
			
		||||
wait_time = 2.0
 | 
			
		||||
autostart = true
 | 
			
		||||
 | 
			
		||||
[node name="Death" type="Timer" parent="."]
 | 
			
		||||
one_shot = true
 | 
			
		||||
 | 
			
		||||
[node name="LvlUp" type="CPUParticles2D" parent="."]
 | 
			
		||||
emitting = false
 | 
			
		||||
amount = 14
 | 
			
		||||
@@ -460,6 +463,8 @@ skew = -0.0837758
 | 
			
		||||
shape = SubResource("CapsuleShape2D_qykhm")
 | 
			
		||||
debug_color = Color(0.956863, 0.203922, 0, 0.419608)
 | 
			
		||||
 | 
			
		||||
[connection signal="animation_finished" from="Sprite" to="." method="_on_sprite_animation_finished"]
 | 
			
		||||
[connection signal="animation_looped" from="Sprite" to="." method="_on_sprite_animation_looped"]
 | 
			
		||||
[connection signal="timeout" from="Atk_cooldown" to="." method="_on_atk_cooldown_timeout"]
 | 
			
		||||
[connection signal="timeout" from="Death" to="." method="_on_death_timeout"]
 | 
			
		||||
[connection signal="body_entered" from="AttackArea" to="." method="_on_attack_area_body_entered"]
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,7 @@ func remove_foe(foe):
 | 
			
		||||
 | 
			
		||||
# Called when the node enters the scene tree for the first time.
 | 
			
		||||
func _ready():
 | 
			
		||||
	setLevel(8)
 | 
			
		||||
	atk1l.set_disabled(true)
 | 
			
		||||
	atk1r.set_disabled(true)
 | 
			
		||||
	atk2l.set_disabled(true)
 | 
			
		||||
@@ -48,6 +49,15 @@ func _ready():
 | 
			
		||||
 | 
			
		||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
 | 
			
		||||
func _process(delta):
 | 
			
		||||
	if hp <= 0 && !is_dying:
 | 
			
		||||
		$Death.start()
 | 
			
		||||
		$Atk_cooldown.stop()
 | 
			
		||||
		setAnimState("Die")
 | 
			
		||||
		is_attacking = false
 | 
			
		||||
		is_dying = true
 | 
			
		||||
		
 | 
			
		||||
	if is_dying:
 | 
			
		||||
		pass
 | 
			
		||||
	if abs(velocity.x) < 0.2 && abs(velocity.y) < 0.2 && !is_attacking:
 | 
			
		||||
		setAnimState("Idle")
 | 
			
		||||
	elif !is_attacking:
 | 
			
		||||
@@ -88,28 +98,31 @@ func _process(delta):
 | 
			
		||||
	if !hitanim.is_emitting():
 | 
			
		||||
		anim.modulate.a = 1
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	move_and_slide()
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
func processAI(objs):
 | 
			
		||||
	var vec: Vector2 = Vector2(0,0)
 | 
			
		||||
	var weight: int = 0
 | 
			
		||||
	if hp <= 0:
 | 
			
		||||
		return vec
 | 
			
		||||
	for obj in objs:
 | 
			
		||||
		if !obj || !obj.isAlive:
 | 
			
		||||
			continue
 | 
			
		||||
		if position.distance_to(obj.position) > 10:
 | 
			
		||||
		if position.distance_to(obj.position) > 50:
 | 
			
		||||
			weight = abs(obj.priority) * position.distance_to(obj.position)
 | 
			
		||||
			vec += weight * position.direction_to(obj.position)
 | 
			
		||||
		else:
 | 
			
		||||
			weight = obj.priority * position.distance_to(obj.position) * ((maxhp + 1) / hp)
 | 
			
		||||
			vec += weight * -position.direction_to(obj.position)
 | 
			
		||||
			vec = weight * -position.direction_to(obj.position)
 | 
			
		||||
			attack()
 | 
			
		||||
	
 | 
			
		||||
	if vec.length() < 5 && objs.size() > 1:
 | 
			
		||||
		vec.y *= 3
 | 
			
		||||
	
 | 
			
		||||
	if velocity.length() < 95 && objs.size() > 1:
 | 
			
		||||
		vec.y += 10
 | 
			
		||||
		#vec.x -= vec.x * .2
 | 
			
		||||
		
 | 
			
		||||
	return vec.normalized() * 100
 | 
			
		||||
	
 | 
			
		||||
@@ -133,7 +146,6 @@ func stop_attack():
 | 
			
		||||
func setAnimState(newstate):
 | 
			
		||||
	anim.animation = newstate
 | 
			
		||||
	anim.flip_h = !is_facing_left
 | 
			
		||||
	
 | 
			
		||||
	state = newstate
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
@@ -143,11 +155,6 @@ func receive_damage(dmg):
 | 
			
		||||
	hp -= dmg
 | 
			
		||||
	hitanim.restart()
 | 
			
		||||
	anim.modulate.a = 0.5
 | 
			
		||||
	if hp < 0:
 | 
			
		||||
		velocity = Vector2(0,0)
 | 
			
		||||
		setAnimState("Die")
 | 
			
		||||
		state = "Die"
 | 
			
		||||
		is_dying = true
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
func receive_exp(x):
 | 
			
		||||
@@ -197,12 +204,18 @@ func _on_sprite_animation_looped():
 | 
			
		||||
			attack()
 | 
			
		||||
		else:
 | 
			
		||||
			currAtks = maxAtks
 | 
			
		||||
	if (is_dying):
 | 
			
		||||
		queue_free()
 | 
			
		||||
	else:
 | 
			
		||||
		is_dying = false
 | 
			
		||||
	is_dying = false
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
func _on_attack_area_body_entered(body):
 | 
			
		||||
	if typeof(body) == typeof(TemplateSpawnable):
 | 
			
		||||
		body.receive_damage(damage)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func _on_death_timeout():
 | 
			
		||||
	pass
 | 
			
		||||
 | 
			
		||||
func _on_sprite_animation_finished():
 | 
			
		||||
	$"..".win_screen()
 | 
			
		||||
	queue_free()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								Scripts/level.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Scripts/level.gd
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
extends Node2D
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Called when the node enters the scene tree for the first time.
 | 
			
		||||
func _ready():
 | 
			
		||||
	pass # Replace with function body.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
 | 
			
		||||
func _process(delta):
 | 
			
		||||
	pass
 | 
			
		||||
 | 
			
		||||
func win_screen():
 | 
			
		||||
	get_tree().change_scene_to_file("res://Scenes/start_menu.tscn")
 | 
			
		||||
	
 | 
			
		||||
		Reference in New Issue
	
	Block a user