Skip to content

Commit

Permalink
feat:add cthulhu shield
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jun 10, 2024
1 parent 325732d commit 3a97362
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions gdrust/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use derive::gen_debug;
use godot::engine::{Area2D, CharacterBody2D, GpuParticles2D, ICharacterBody2D, Timer};
use godot::obj::WithBaseField;
use godot::prelude::*;
use real_consts::PI;
use std::time::{Duration, Instant};

use crate::debug_check;
Expand Down Expand Up @@ -151,6 +152,7 @@ impl Player {
// 启动拖尾粒子
let mut particle = self.get_virtual_particle();
particle.set_emitting(true);
self.turn_on_shield();
}

#[debug]
Expand All @@ -164,6 +166,7 @@ impl Player {
particle.set_emitting(false);
self.status = Movement::Move;
self.click_type = Click::None;
self.turn_off_shield();
}

fn process_rush(&mut self, movement_name: StringName, click_type: Click) {
Expand Down Expand Up @@ -210,11 +213,30 @@ impl Player {
#[func]
fn turn_on_shield(&mut self) {
let mut shield = self.get_shield();
shield.set_rotation(self.cthulhu_rad());
shield.show();
}

/// 关闭克盾保护
#[func]
fn turn_off_shield(&mut self) {
let mut shield = self.get_shield();
shield.hide();
}

#[debug]
fn get_cthulhu_timer(&self) -> Gd<Timer> {
self.base().get_node_as::<Timer>("Cthulhu")
}

fn cthulhu_rad(&self) -> f32 {
match self.rush_type {
Click::Left => PI,
Click::Right => 0.0,
_ => {
let msg = format!("wrong movement {:?} when rush", self.click_type);
panic!("{}", &msg);
}
}
}
}
2 changes: 1 addition & 1 deletion scenes/fight.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ scale = Vector2(3.28571, 3.28571)
[node name="image" type="Sprite2D" parent="ZenithBegin"]
texture = ExtResource("3_2spkb")

[node name="StarWrath" parent="." instance=ExtResource("4_8ipx5")]
[node name="Star_Wrath" parent="." instance=ExtResource("4_8ipx5")]

[node name="Player" type="Player" parent="."]
position = Vector2(570, 414)
Expand Down

0 comments on commit 3a97362

Please sign in to comment.