Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/SkyUOI/Zenith into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wlywlywlywly committed Aug 22, 2024
2 parents e791d5e + 0aa0d1e commit d602592
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 197 deletions.
346 changes: 159 additions & 187 deletions gdrust/Cargo.lock

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions gdrust/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ pub async fn lib_main() -> Result<(), Box<dyn Error>> {
.accept_sockets(shutdown_sender_clone, shutdown_receiver_clone)
.await
});
let shutdown_sender_clone = shutdown_sender.clone();
tokio::spawn(async move {
match tokio::signal::ctrl_c().await {
Ok(()) => {
log::info!("Exiting now...");
shutdown_sender.send(())?;
shutdown_sender_clone.send(())?;
}
Err(err) => {
log::error!("Unable to listen for shutdown signal: {}", err);
shutdown_sender.send(())?;
log::error!("Unable to listen to shutdown signal: {}", err);
shutdown_sender_clone.send(())?;
}
}
anyhow::Ok(())
Expand Down Expand Up @@ -187,7 +188,9 @@ pub async fn lib_main() -> Result<(), Box<dyn Error>> {
anyhow::Ok(())
};
select! {
_ = input_loop => {},
_ = input_loop => {
shutdown_sender.send(())?;
},
_ = shutdown_receiver.recv() => {
log::info!("Command loop exited")
}
Expand Down
5 changes: 4 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ locale/translations_pot_files=PackedStringArray("res://scenes/multi_game.tscn")

[layer_names]

2d_render/layer_2="wall"
2d_render/layer_1="wall"
2d_render/layer_2="player"
2d_render/layer_3="sword"
2d_render/layer_4="bullet"

[rendering]

Expand Down
33 changes: 29 additions & 4 deletions scenes/bullets/star_wrath/laser_beam.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,66 @@ extends RayCast2D
@export var max_length = 1400.0
@export var growth_time = 0.5

# 标记是否发送
var is_casting = false
var tween
# 该线是两个点的,用于标记激光
@onready var fill = $Line2D
@onready var casting_particles = $CastingParticles
# 碰撞后产生的粒子效果
@onready var collision_particles = $CollisionParticles
# 激光产生的粒子
@onready var beam_particles = $BeamParticles
# 激光的宽度
@onready var line_width = fill.width
# 激光的方向
var direct: Vector2 = Vector2.RIGHT


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# 无激光绘制时关闭process减少性能开销
set_physics_process(false)
fill.points[1] = Vector2.ZERO
tween = create_tween()


func _physics_process(delta: float) -> void:
target_position = (target_position + Vector2.RIGHT * cast_speed * delta).limit_length(
max_length
)
target_position = (target_position + self.direct * cast_speed * delta).limit_length(max_length)
cast_beam()


# 初始化
func init(pos: Vector2):
self.global_position = pos


# 设置激光的方向
func set_direct(direct_arg: Vector2) -> void:
self.direct = direct_arg.normalized()


func cast_beam():
# 当前的终点
var cast_point = target_position
# 更新射线
force_raycast_update()
# 检测是否碰撞
var status = is_colliding()
# 如果碰撞,产生碰撞粒子
collision_particles.emitting = status
if status:
cast_point = to_local(get_collision_point())
# 让碰撞粒子旋转某个角度
collision_particles.global_rotation = get_collision_normal().angle()
# 让碰撞粒子移动到碰撞点
collision_particles.global_position = get_collision_point()
fill.points[1] = cast_point
beam_particles.position = cast_point * 0.5
beam_particles.process_material.emission_box_extents.x = cast_point.length() * 0.5


# 设置激光开启关闭
func set_is_casting(cast: bool) -> void:
is_casting = cast
if is_casting:
Expand All @@ -56,13 +79,15 @@ func set_is_casting(cast: bool) -> void:
casting_particles.emitting = is_casting


# 光柱渐渐出现
func appear():
tween.kill()
tween = create_tween()
tween.tween_property(fill, "width", line_width, growth_time * 2).from(0)


# 光柱消失
func disappear():
tween.kill()
tween = create_tween()
tween.tween_property(fill, "width", 0, growth_time).from(line_width)
tween.tween_property(fill, "width", 0, growth_time * 1.5).from(line_width)
2 changes: 2 additions & 0 deletions scenes/bullets/star_wrath/laser_beam.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ particle_flag_disable_z = true
gravity = Vector3(0, 98, 0)

[node name="LaserBeam" type="RayCast2D"]
collision_mask = 2
script = ExtResource("1_pxjff")

[node name="Line2D" type="Line2D" parent="."]
points = PackedVector2Array(0, 0, 100, 0)
closed = true
width = 20.0
default_color = Color(0.906203, 0.352697, 0.705898, 1)
texture_mode = 2
joint_mode = 2
Expand Down
2 changes: 2 additions & 0 deletions scenes/fight.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ rotation = 0.710345
[node name="Player" type="Player" parent="."]
position = Vector2(570, 414)
scale = Vector2(0.2, 0.2)
collision_layer = 2
collision_mask = 15
motion_mode = 1
floor_stop_on_slope = false
floor_block_on_wall = false
Expand Down
14 changes: 13 additions & 1 deletion scenes/weapons/star_wrath/star_wrath.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ extends StarWrath

@export var star_wrath_origin: PackedScene
var operation_idx = 0
var operations = [func(): self.fall_star_process(), func(): self.leave()]
# func(): self.fall_star_process(),
var operations = [func(): self.beam_shoot1(), func(): self.leave()]
@onready var animation_player = $AnimationPlayer
@onready var star_wrath = $StarWrath
var beam_scene: PackedScene = preload("res://scenes/bullets/star_wrath/laser_beam.tscn")


func next_operation():
Expand All @@ -23,6 +25,16 @@ func fall_star_process():
next_operation()


func beam_shoot1():
var beam = beam_scene.instantiate()
self.add_child(beam)
beam.init(Vector2(200, 450))
beam.set_is_casting(true)
beam.set_direct(beam.to_local(Vector2(300, 450)))
await get_tree().create_timer(10.0).timeout
beam.set_is_casting(false)


func leave():
await self.get_tree().create_timer(0.3).timeout
var tween = create_tween()
Expand Down
1 change: 1 addition & 0 deletions scenes/weapons/star_wrath/star_wrath.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ texture = ExtResource("4_ohxcu")
editor_description = "Debug"

[node name="CollisionShape2D" type="CollisionShape2D" parent="StarWrath"]
position = Vector2(-88.8015, -56.0204)
rotation = 2.30812
scale = Vector2(4.2, 1)
shape = SubResource("RectangleShape2D_qm46a")
Expand Down

0 comments on commit d602592

Please sign in to comment.