9.25上午
This commit is contained in:
parent
f0a6e44f61
commit
0bf7090291
@ -171,6 +171,7 @@ func _ready() -> void:
|
||||
load_script_data()
|
||||
load_event_data()
|
||||
load_scene_data()
|
||||
load_card_data()
|
||||
load_character_data()
|
||||
load_map_data()
|
||||
load_npc_data()
|
||||
|
@ -1,6 +1,17 @@
|
||||
{
|
||||
"card_01":{
|
||||
"name":"测试卡01",
|
||||
"icon":"?"
|
||||
}
|
||||
"name":"测试卡01(友方目标)",
|
||||
"icon":"?",
|
||||
"target_queue":0
|
||||
},
|
||||
"card_02":{
|
||||
"name":"测试卡02(不需要目标)",
|
||||
"icon":"?",
|
||||
|
||||
},
|
||||
"card_03":{
|
||||
"name":"测试卡03(敌方目标)",
|
||||
"icon":"?",
|
||||
"target_queue":1
|
||||
},
|
||||
}
|
||||
|
@ -54,3 +54,8 @@ mouse_right={
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(242, 15),"global_position":Vector2(251, 61),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
2d_physics/layer_1="队伍0"
|
||||
2d_physics/layer_2="队伍1"
|
||||
|
@ -2,10 +2,13 @@ extends Control
|
||||
class_name Card
|
||||
@onready var state_machine: StateMachine = $state_machine
|
||||
@onready var fight_card: TextureRect = $fight_card
|
||||
@onready var arrow: card_arrow = $arrow
|
||||
var target_queue:int=-1
|
||||
var scale_multiple:float=1.1
|
||||
func _ready() -> void:
|
||||
state_machine.launch()
|
||||
|
||||
|
||||
func _on_fight_card_mouse_entered() -> void:
|
||||
state_machine.send_message("mouse_enter")
|
||||
pass # Replace with function body.
|
||||
@ -16,10 +19,22 @@ func _on_fight_card_mouse_exited() -> void:
|
||||
state_machine.send_message("mouse_exit")
|
||||
pass # Replace with function body.
|
||||
var data:Dictionary
|
||||
##设置卡牌信息
|
||||
func set_data(id:String):
|
||||
|
||||
|
||||
var d=Global.get_card_data(id)
|
||||
print(d)
|
||||
if d!=null:
|
||||
data=d
|
||||
fight_card.set_data(d)
|
||||
if data.has("target_queue"):
|
||||
target_queue=data["target_queue"]
|
||||
pass
|
||||
##该卡牌是否需要选择目标
|
||||
func need_target():
|
||||
return target_queue!=-1
|
||||
##获取该卡牌的目标
|
||||
func get_target()->int:
|
||||
return target_queue
|
||||
var last_move_tween:Tween
|
||||
func move_to(from_pos:Vector2,to_pos:Vector2,time:float=0.5):
|
||||
if last_move_tween!=null:
|
||||
@ -54,3 +69,9 @@ func get_self_index_position():
|
||||
|
||||
func request_resize():
|
||||
state_machine.send_message("resize")
|
||||
func open_arrow():
|
||||
arrow.start()
|
||||
func close_arrow():
|
||||
arrow.stop()
|
||||
func set_arrow_queue(q:int):
|
||||
arrow.set_select_queue(q)
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://8a2mwnnmnecl"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://8a2mwnnmnecl"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://chowelwcfnsxs" path="res://scene/fight_card.tscn" id="1_nmkht"]
|
||||
[ext_resource type="Script" path="res://scene/card.gd" id="1_wc0x3"]
|
||||
@ -8,8 +8,11 @@
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/focus.gd" id="6_3e38c"]
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/selected.gd" id="7_ugr71"]
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/selected_back.gd" id="8_adb0l"]
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/select_target.gd" id="8_kik8t"]
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/queue.gd" id="8_y4vrd"]
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/exe.gd" id="9_40m88"]
|
||||
[ext_resource type="PackedScene" uid="uid://c7vtcaeg4nkbu" path="res://scene/card_state_machine/arrow.tscn" id="11_gjfgy"]
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/discard.gd" id="12_sl7jh"]
|
||||
|
||||
[node name="card" type="Control"]
|
||||
layout_direction = 1
|
||||
@ -44,6 +47,9 @@ script = ExtResource("6_3e38c")
|
||||
[node name="selected" type="Node" parent="state_machine"]
|
||||
script = ExtResource("7_ugr71")
|
||||
|
||||
[node name="select_target" type="Node" parent="state_machine"]
|
||||
script = ExtResource("8_kik8t")
|
||||
|
||||
[node name="selected_back" type="Node" parent="state_machine"]
|
||||
script = ExtResource("8_adb0l")
|
||||
|
||||
@ -53,5 +59,10 @@ script = ExtResource("8_y4vrd")
|
||||
[node name="exe" type="Node" parent="state_machine"]
|
||||
script = ExtResource("9_40m88")
|
||||
|
||||
[node name="discard" type="Node" parent="state_machine"]
|
||||
script = ExtResource("12_sl7jh")
|
||||
|
||||
[node name="arrow" parent="." instance=ExtResource("11_gjfgy")]
|
||||
|
||||
[connection signal="mouse_entered" from="fight_card" to="." method="_on_fight_card_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="fight_card" to="." method="_on_fight_card_mouse_exited"]
|
||||
|
@ -10,6 +10,11 @@ class_name card_arrow
|
||||
@export var arrowImageRotate:float=PI/2
|
||||
##箭头图片容器场景
|
||||
@export var arrowImageScene:PackedScene
|
||||
|
||||
|
||||
##用来检测目标的
|
||||
@onready var area: Area2D = $Area2D
|
||||
|
||||
##是否开启
|
||||
@export var is_start:bool=false
|
||||
@export_group("缩放")
|
||||
@ -19,7 +24,19 @@ class_name card_arrow
|
||||
@export var max_scale:float=2
|
||||
##图片节点队列
|
||||
var texture_array:Array[arrowImage]=[]
|
||||
|
||||
##设置选择目标的对象
|
||||
func set_select_queue(q:int):
|
||||
match q:
|
||||
0:
|
||||
area.set_collision_layer(1)
|
||||
area.set_collision_mask(1)
|
||||
1:
|
||||
area.set_collision_layer(2)
|
||||
area.set_collision_mask(2)
|
||||
pass
|
||||
func _ready():
|
||||
|
||||
curve.bake()
|
||||
for i in range(texture_num):
|
||||
var new_texture=arrowImageScene.instantiate()
|
||||
@ -29,7 +46,8 @@ func _ready():
|
||||
new_texture.hide()
|
||||
texture_array[texture_num-1].set_image(texture_arrow,2)
|
||||
func replace_texture():
|
||||
var mouse_pos=(get_viewport().get_mouse_position()-self.global_position)
|
||||
var mouse_pos=(get_global_mouse_position()-self.global_position)
|
||||
area.global_position=get_global_mouse_position()
|
||||
texture_array[0].rotation=texture_array[1].rotation
|
||||
for i in range(1,texture_array.size()):
|
||||
var t=logWithBase(float(i)/(texture_array.size()-1)+1,2)
|
||||
@ -55,8 +73,13 @@ func logWithBase(value, base)->float:
|
||||
func start():
|
||||
for i in texture_array:
|
||||
i.show()
|
||||
area.monitoring=true
|
||||
area.monitorable=true
|
||||
is_start=true
|
||||
func stop():
|
||||
for i in texture_array:
|
||||
i.hide()
|
||||
area.position=Vector2.ZERO
|
||||
is_start=false
|
||||
area.monitoring=false
|
||||
area.monitorable=false
|
||||
|
@ -1,10 +1,49 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c7vtcaeg4nkbu"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://c7vtcaeg4nkbu"]
|
||||
|
||||
[ext_resource type="Script" path="res://scene/card_state_machine/arrow.gd" id="1_oqukl"]
|
||||
[ext_resource type="PackedScene" uid="uid://dg27pietgq7qd" path="res://scene/card_state_machine/arrowImg.tscn" id="2_ba6kg"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_7pfi1"]
|
||||
offsets = PackedFloat32Array(0, 0.466667, 0.509804)
|
||||
colors = PackedColorArray(0, 0.463205, 0.823238, 1, 0, 0.462745, 0.823529, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_qscu6"]
|
||||
gradient = SubResource("Gradient_7pfi1")
|
||||
fill = 1
|
||||
fill_from = Vector2(0.5, 0.5)
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_8a280"]
|
||||
offsets = PackedFloat32Array(0, 0.278431, 0.305882)
|
||||
colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_t54e3"]
|
||||
gradient = SubResource("Gradient_8a280")
|
||||
fill = 2
|
||||
fill_from = Vector2(0.517094, 1)
|
||||
|
||||
[sub_resource type="Curve" id="Curve_035f2"]
|
||||
_data = [Vector2(0, 0.600293), 0.0, 0.0, 0, 0, Vector2(1e-05, 0.581259), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_cys1g"]
|
||||
radius = 11.1803
|
||||
|
||||
[node name="arrow" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_oqukl")
|
||||
texture_circle = SubResource("GradientTexture2D_qscu6")
|
||||
texture_arrow = SubResource("GradientTexture2D_t54e3")
|
||||
texture_num = 20
|
||||
arrowImageScene = ExtResource("2_ba6kg")
|
||||
curve = SubResource("Curve_035f2")
|
||||
max_scale = 1.0
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 0
|
||||
monitoring = false
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("CircleShape2D_cys1g")
|
||||
|
@ -1,8 +1,11 @@
|
||||
extends Control
|
||||
class_name CardMachine
|
||||
const CARD = preload("res://scene/card.tscn")
|
||||
var rand_release:float=20
|
||||
@export var release_card_pos:Control
|
||||
var distance:float=100
|
||||
var card_arr:Array[Card]=[]
|
||||
var queue_card:Array[Card]=[]
|
||||
func get_index_position(index:int)->Vector2:
|
||||
var center=size/2
|
||||
var left=center-Vector2(distance*card_arr.size()/2,0)
|
||||
@ -15,11 +18,27 @@ func get_put_pos():
|
||||
return size/2
|
||||
|
||||
func add_card(card_id:String,num:int):
|
||||
var data=Global.get_card_data(card_id)
|
||||
for i in num:
|
||||
var new_card=CARD.instantiate()
|
||||
var new_card=CARD.instantiate() as Card
|
||||
add_child(new_card)
|
||||
new_card.set_data(card_id)
|
||||
card_arr.append(new_card)
|
||||
for j in card_arr:
|
||||
j.request_resize()
|
||||
|
||||
pass
|
||||
#获取释放位置
|
||||
func get_release_pos()->Vector2:
|
||||
var pos:Vector2
|
||||
if release_card_pos!=null:
|
||||
pos=release_card_pos.position
|
||||
else:
|
||||
pos=Vector2.ZERO
|
||||
var rand:Vector2=Vector2(randf_range(-rand_release,rand_release),randf_range(-rand_release,rand_release))
|
||||
return pos+rand
|
||||
|
||||
func add_to_queue(card:Card):
|
||||
|
||||
if queue_card.size()==0:
|
||||
queue_card.append(card)
|
||||
card.send("your_turn")
|
||||
|
1
scene/card_state_machine/discard.gd
Normal file
1
scene/card_state_machine/discard.gd
Normal file
@ -0,0 +1 @@
|
||||
extends State
|
30
scene/card_state_machine/select_target.gd
Normal file
30
scene/card_state_machine/select_target.gd
Normal file
@ -0,0 +1,30 @@
|
||||
extends State
|
||||
var init_position:Vector2
|
||||
var target_y:float=200
|
||||
func enter_state(n):
|
||||
init_position=n
|
||||
get_player().open_arrow()
|
||||
func update_state(delta):
|
||||
if Input.is_action_just_released("mouse_left"):
|
||||
change_to_state("selected_back")
|
||||
return
|
||||
if Input.is_action_just_pressed("mouse_right"):
|
||||
change_to_state("selected_back")
|
||||
return
|
||||
pass
|
||||
var change_y=(init_position-get_player().get_parent().get_local_mouse_position()).y
|
||||
if change_y<target_y:
|
||||
change_to_state("selected",init_position)
|
||||
return
|
||||
func update_state_phy(delta):
|
||||
pass
|
||||
func exit_state():
|
||||
get_player().close_arrow()
|
||||
pass
|
||||
|
||||
func time_out():
|
||||
pass
|
||||
func process_message(type:String,n):
|
||||
|
||||
|
||||
pass
|
@ -1,6 +1,13 @@
|
||||
extends State
|
||||
var init_position:Vector2=Vector2.ZERO
|
||||
var target_y:float=200
|
||||
var need_target:bool=false
|
||||
func enter_state(n):
|
||||
get_player().up()
|
||||
need_target=get_player().need_target()
|
||||
init_position=get_player().position
|
||||
if n is Vector2:
|
||||
init_position=n
|
||||
pass
|
||||
func update_state(delta):
|
||||
get_player().position=get_player().get_parent().get_local_mouse_position()
|
||||
@ -10,6 +17,10 @@ func update_state(delta):
|
||||
if Input.is_action_just_pressed("mouse_right"):
|
||||
change_to_state("selected_back")
|
||||
return
|
||||
var change_y=(init_position-get_player().get_parent().get_local_mouse_position()).y
|
||||
if need_target and change_y>target_y:
|
||||
change_to_state("select_target",init_position)
|
||||
return
|
||||
pass
|
||||
func update_state_phy(delta):
|
||||
pass
|
||||
|
@ -7,9 +7,6 @@ func enter_state(n):
|
||||
pass
|
||||
func update_state(delta):
|
||||
get_player().position=get_player().get_parent().get_local_mouse_position()
|
||||
if Input.is_action_just_released("mouse_left"):
|
||||
change_to_state("focus")
|
||||
return
|
||||
|
||||
pass
|
||||
func update_state_phy(delta):
|
||||
|
@ -12,5 +12,7 @@ func _process(delta: float) -> void:
|
||||
|
||||
|
||||
func _on_tool_button_pressed() -> void:
|
||||
%card_machine.add_card("xxx",1)
|
||||
%card_machine.add_card("card_01",1)
|
||||
%card_machine.add_card("card_02",1)
|
||||
%card_machine.add_card("card_03",1)
|
||||
pass # Replace with function body.
|
||||
|
@ -4,8 +4,8 @@ extends TextureRect
|
||||
@onready var icon: TextureRect = $icon
|
||||
|
||||
var data:Dictionary
|
||||
func set_card(id:String):
|
||||
data=Global.get_card_data(id)
|
||||
icon.texture=Global.get_texture(data["icon"])
|
||||
func set_data(_data:Dictionary):
|
||||
data=_data
|
||||
icon.texture=Global.get_texture(_data["icon"])
|
||||
n.text=data["name"]
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user