.
This commit is contained in:
parent
2adb900957
commit
fe1a7efd37
7 changed files with 46 additions and 13 deletions
|
|
@ -39,3 +39,5 @@ func _input(event):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,14 @@
|
||||||
[ext_resource type="Resource" uid="uid://dfbgxc6nlcjct" path="res://allegiance/bad.tres" id="4_sitmf"]
|
[ext_resource type="Resource" uid="uid://dfbgxc6nlcjct" path="res://allegiance/bad.tres" id="4_sitmf"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_riqys"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_riqys"]
|
||||||
size = Vector2(98, 100)
|
size = Vector2(99, 97.67441)
|
||||||
|
|
||||||
[node name="CharacterBody2D" type="CharacterBody2D" unique_id=1581641385]
|
[node name="CharacterBody2D" type="CharacterBody2D" unique_id=1581641385]
|
||||||
|
scale = Vector2(0.215, 0.215)
|
||||||
script = ExtResource("1_xfhet")
|
script = ExtResource("1_xfhet")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1841709482]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1841709482]
|
||||||
position = Vector2(50, 49)
|
position = Vector2(50.500004, 48.837223)
|
||||||
shape = SubResource("RectangleShape2D_riqys")
|
shape = SubResource("RectangleShape2D_riqys")
|
||||||
|
|
||||||
[node name="MemberSprite" parent="." unique_id=283117283 instance=ExtResource("2_v0at3")]
|
[node name="MemberSprite" parent="." unique_id=283117283 instance=ExtResource("2_v0at3")]
|
||||||
|
|
|
||||||
|
|
@ -22,3 +22,6 @@ func _on_mouse_exited() -> void:
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
UserContext.select_focused_member()
|
UserContext.select_focused_member()
|
||||||
|
|
||||||
|
func get_allegiance():
|
||||||
|
return allegiance.kingdom_name
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
[gd_resource type="Resource" script_class="SentientCurrency" format=3 uid="uid://dv834343s36af"]
|
[gd_resource type="Resource" script_class="SentientCurrency" format=3 uid="uid://dv834343s36af"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_b07i1"]
|
[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_b07i1"]
|
||||||
|
[ext_resource type="Script" uid="uid://cn8rc6jyllrf0" path="res://command.gd" id="1_du6k0"]
|
||||||
[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_0dvy8"]
|
[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_0dvy8"]
|
||||||
[ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="2_j265y"]
|
[ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="2_j265y"]
|
||||||
|
[ext_resource type="Resource" uid="uid://u6lls6n0xw3n" path="res://commands/move_command.tres" id="2_tge1j"]
|
||||||
[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_0dvy8"]
|
[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_0dvy8"]
|
||||||
[ext_resource type="Resource" uid="uid://crnhu4w6lfopb" path="res://currency/inanimate/beer.tres" id="5_a7r6n"]
|
[ext_resource type="Resource" uid="uid://crnhu4w6lfopb" path="res://currency/inanimate/beer.tres" id="5_a7r6n"]
|
||||||
|
|
||||||
|
|
|
||||||
8
map.tscn
8
map.tscn
|
|
@ -170,14 +170,14 @@ currency = ExtResource("4_gqbix")
|
||||||
allegiance = ExtResource("5_71pa8")
|
allegiance = ExtResource("5_71pa8")
|
||||||
|
|
||||||
[node name="CharacterBody2D2" parent="." unique_id=559452664 instance=ExtResource("3_e0an3")]
|
[node name="CharacterBody2D2" parent="." unique_id=559452664 instance=ExtResource("3_e0an3")]
|
||||||
position = Vector2(628, 935)
|
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("4_iw27f")
|
||||||
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")]
|
||||||
position = Vector2(1129, 814)
|
position = Vector2(905, 42)
|
||||||
|
|
||||||
[node name="MemberSprite" parent="CharacterBody2D3" index="1" unique_id=283117283]
|
[node name="MemberSprite" parent="CharacterBody2D3" index="1" unique_id=283117283]
|
||||||
allegiance = ExtResource("5_71pa8")
|
allegiance = ExtResource("5_71pa8")
|
||||||
|
|
@ -242,13 +242,13 @@ position = Vector2(368, -1353)
|
||||||
currency = ExtResource("6_05x41")
|
currency = ExtResource("6_05x41")
|
||||||
|
|
||||||
[node name="CharacterBody2D12" parent="." unique_id=2114526449 instance=ExtResource("3_e0an3")]
|
[node name="CharacterBody2D12" parent="." unique_id=2114526449 instance=ExtResource("3_e0an3")]
|
||||||
position = Vector2(388, -1138)
|
position = Vector2(853, -17.999998)
|
||||||
|
|
||||||
[node name="MemberSprite" parent="CharacterBody2D12" index="1" unique_id=283117283]
|
[node name="MemberSprite" parent="CharacterBody2D12" index="1" unique_id=283117283]
|
||||||
currency = ExtResource("8_oysan")
|
currency = ExtResource("8_oysan")
|
||||||
|
|
||||||
[node name="CharacterBody2D13" parent="." unique_id=799583982 instance=ExtResource("3_e0an3")]
|
[node name="CharacterBody2D13" parent="." unique_id=799583982 instance=ExtResource("3_e0an3")]
|
||||||
position = Vector2(679, -1035)
|
position = Vector2(905.99994, -11.999985)
|
||||||
|
|
||||||
[node name="MemberSprite" parent="CharacterBody2D13" index="1" unique_id=283117283]
|
[node name="MemberSprite" parent="CharacterBody2D13" index="1" unique_id=283117283]
|
||||||
currency = ExtResource("4_iw27f")
|
currency = ExtResource("4_iw27f")
|
||||||
|
|
|
||||||
32
troup.gd
32
troup.gd
|
|
@ -1,11 +1,12 @@
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
|
||||||
const SPEED = 100.0
|
const SPEED = 700.0
|
||||||
const JUMP_VELOCITY = -400.0
|
const JUMP_VELOCITY = -400.0
|
||||||
@export var target : Node2D
|
@export var target : Node2D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
||||||
UserContext. set_target_for . connect(set_target_for)
|
UserContext. set_target_for . connect(set_target_for)
|
||||||
|
|
||||||
func set_target_for(who: CurrencyMemberSprite, t: Node2D):
|
func set_target_for(who: CurrencyMemberSprite, t: Node2D):
|
||||||
|
|
@ -19,23 +20,42 @@ func set_target_for(who: CurrencyMemberSprite, t: Node2D):
|
||||||
func removed_target():
|
func removed_target():
|
||||||
target = null
|
target = null
|
||||||
|
|
||||||
|
func combat(target):
|
||||||
|
var winner = randf_range(0,2)
|
||||||
|
print(winner)
|
||||||
|
if winner <= 1:
|
||||||
|
target.queue_free()
|
||||||
|
else:
|
||||||
|
var p := Production.new()
|
||||||
|
p.amount = -1
|
||||||
|
p.currency = %MemberSprite.currency
|
||||||
|
Economy.produce(p)
|
||||||
|
|
||||||
|
self.queue_free()
|
||||||
|
|
||||||
#func _Direction() -> Vector2:
|
#func _Direction() -> Vector2:
|
||||||
#self.position = self.position.move_toward(target.transform.position, speed * delta)
|
#self.position = self.position.move_toward(target.transform.position, speed * delta)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
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)
|
#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 (num > Vector2(2,2)):
|
||||||
if (self.global_position.distance_to(target.global_position) > 0.2):
|
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)
|
#self.global_position = self.global_position.move_toward(target.global_position, SPEED * delta)
|
||||||
elif (target.is_class("SentientCurrency")):
|
elif (target.is_class("CharacterBody2D")):
|
||||||
pass
|
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() ):
|
||||||
|
#print("different Allegience: "+ target.get_node("CurrencyMemberSprite").alligence)
|
||||||
|
combat(target)
|
||||||
|
removed_target()
|
||||||
else:
|
else:
|
||||||
pass
|
print("Removed Target")
|
||||||
|
removed_target()
|
||||||
#target = null
|
#target = null
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ func select_focused_member():
|
||||||
selected_member_change.emit(selected_member)
|
selected_member_change.emit(selected_member)
|
||||||
UserContext.member_inspect.emit(selected_member)
|
UserContext.member_inspect.emit(selected_member)
|
||||||
|
|
||||||
|
func select_point(node : Node2D):
|
||||||
|
if modal_command is MoveCommand:
|
||||||
|
set_target_for.emit(selected_member, node)
|
||||||
|
|
||||||
|
|
||||||
func unselect_member():
|
func unselect_member():
|
||||||
if selected_member == null:
|
if selected_member == null:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue