.
This commit is contained in:
parent
bda8b1a747
commit
86f2ad29af
2 changed files with 15 additions and 16 deletions
7
map.tscn
7
map.tscn
|
|
@ -7,6 +7,7 @@
|
||||||
[ext_resource type="Resource" uid="uid://dlxnbyiurne1s" path="res://currency/sentient/calvary.tres" id="4_iw27f"]
|
[ext_resource type="Resource" uid="uid://dlxnbyiurne1s" path="res://currency/sentient/calvary.tres" id="4_iw27f"]
|
||||||
[ext_resource type="Resource" uid="uid://b7lxfjhx4qhts" path="res://allegiance/good.tres" id="5_71pa8"]
|
[ext_resource type="Resource" uid="uid://b7lxfjhx4qhts" path="res://allegiance/good.tres" id="5_71pa8"]
|
||||||
[ext_resource type="Resource" uid="uid://dn0c1pfq04obw" path="res://currency/sentient/farmer.tres" id="6_05x41"]
|
[ext_resource type="Resource" uid="uid://dn0c1pfq04obw" path="res://currency/sentient/farmer.tres" id="6_05x41"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dv834343s36af" path="res://currency/sentient/drunk.tres" id="6_gqbix"]
|
||||||
[ext_resource type="Resource" uid="uid://clx8tbrad4m7c" path="res://currency/sentient/dinosaur.tres" id="9_sb2pt"]
|
[ext_resource type="Resource" uid="uid://clx8tbrad4m7c" path="res://currency/sentient/dinosaur.tres" id="9_sb2pt"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bhunq"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bhunq"]
|
||||||
|
|
@ -66,9 +67,11 @@ limit_bottom = 1592
|
||||||
script = ExtResource("2_wijl4")
|
script = ExtResource("2_wijl4")
|
||||||
|
|
||||||
[node name="PlayerGates" type="Area2D" parent="." unique_id=1387700911]
|
[node name="PlayerGates" type="Area2D" parent="." unique_id=1387700911]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(968, 1498)
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerGates" unique_id=880212519]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerGates" unique_id=880212519]
|
||||||
position = Vector2(967, 1469)
|
position = Vector2(-1, -23)
|
||||||
shape = SubResource("RectangleShape2D_bhunq")
|
shape = SubResource("RectangleShape2D_bhunq")
|
||||||
|
|
||||||
[node name="EnemyGates" type="Area2D" parent="." unique_id=92129502]
|
[node name="EnemyGates" type="Area2D" parent="." unique_id=92129502]
|
||||||
|
|
@ -172,7 +175,7 @@ allegiance = ExtResource("5_71pa8")
|
||||||
position = Vector2(854, 34)
|
position = Vector2(854, 34)
|
||||||
|
|
||||||
[node name="MemberSprite" parent="CharacterBody2D2" index="1" unique_id=283117283]
|
[node name="MemberSprite" parent="CharacterBody2D2" index="1" unique_id=283117283]
|
||||||
currency = ExtResource("4_iw27f")
|
currency = ExtResource("6_gqbix")
|
||||||
allegiance = ExtResource("5_71pa8")
|
allegiance = ExtResource("5_71pa8")
|
||||||
|
|
||||||
[node name="CharacterBody2D3" parent="." unique_id=1323337635 instance=ExtResource("3_e0an3")]
|
[node name="CharacterBody2D3" parent="." unique_id=1323337635 instance=ExtResource("3_e0an3")]
|
||||||
|
|
|
||||||
20
troup.gd
20
troup.gd
|
|
@ -4,10 +4,12 @@ extends CharacterBody2D
|
||||||
const SPEED = 700.0
|
const SPEED = 700.0
|
||||||
const JUMP_VELOCITY = -400.0
|
const JUMP_VELOCITY = -400.0
|
||||||
@export var target : Node2D
|
@export var target : Node2D
|
||||||
|
@export var enemTarget : Node2D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
||||||
UserContext. set_target_for . connect(set_target_for)
|
UserContext. set_target_for . connect(set_target_for)
|
||||||
|
enemTarget = %PlayerGates
|
||||||
|
|
||||||
func set_target_for(who: CurrencyMemberSprite, t: Node2D):
|
func set_target_for(who: CurrencyMemberSprite, t: Node2D):
|
||||||
if %MemberSprite == who:
|
if %MemberSprite == who:
|
||||||
|
|
@ -43,29 +45,23 @@ func combat(target):
|
||||||
Economy.log.emit("A " + p.currency.name +" died in combat!")
|
Economy.log.emit("A " + p.currency.name +" died in combat!")
|
||||||
self.queue_free()
|
self.queue_free()
|
||||||
|
|
||||||
#func _Direction() -> Vector2:
|
|
||||||
#self.position = self.position.move_toward(target.transform.position, speed * delta)
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
if %MemberSprite.get_allegiance() == "Rivaldom" and %MemberSprite.get_combat() == true and target != enemTarget:
|
||||||
|
target = enemTarget
|
||||||
|
elif %MemberSprite.get_allegiance() == "You" and target == enemTarget:
|
||||||
|
removed_target()
|
||||||
|
|
||||||
if target != null:
|
if target != null:
|
||||||
#print(self.global_position.distance_to(target.global_position))
|
|
||||||
var _num = abs(abs(self.global_position) - abs(target.global_position))
|
var _num = abs(abs(self.global_position) - abs(target.global_position))
|
||||||
#print(num)
|
|
||||||
var direction = (target.global_position - self.global_position).normalized() * SPEED * delta
|
var direction = (target.global_position - self.global_position).normalized() * SPEED * delta
|
||||||
#if (num > Vector2(2,2)):
|
|
||||||
if (self.global_position.distance_to(target.global_position) > 25):
|
if (self.global_position.distance_to(target.global_position) > 25):
|
||||||
self.velocity = direction
|
self.velocity = direction
|
||||||
#self.global_position = self.global_position.move_toward(target.global_position, SPEED * delta)
|
|
||||||
elif (target.is_class("CharacterBody2D")):
|
elif (target.is_class("CharacterBody2D")):
|
||||||
print("is SentientCurrency")
|
|
||||||
print(target.name)
|
|
||||||
print(target.get_node("MemberSprite").get_allegiance())
|
|
||||||
if (target.get_node("MemberSprite").get_allegiance() != get_node("MemberSprite").get_allegiance() ):
|
if (target.get_node("MemberSprite").get_allegiance() != get_node("MemberSprite").get_allegiance() ):
|
||||||
#print("different Allegience: "+ target.get_node("CurrencyMemberSprite").alligence)
|
|
||||||
combat(target)
|
combat(target)
|
||||||
removed_target()
|
removed_target()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Removed Target")
|
|
||||||
removed_target()
|
removed_target()
|
||||||
#target = null
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue