mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
feat: 添加激光子弹功能,更新相关资源和着色器
This commit is contained in:
@@ -17,7 +17,7 @@ animations = [{
|
||||
|
||||
[node name="Diamond" instance=ExtResource("1_8udva")]
|
||||
script = ExtResource("2_yxtyj")
|
||||
lifeDistance = 500.0
|
||||
lifeTime = 5000.0
|
||||
|
||||
[node name="texture" parent="." index="0"]
|
||||
sprite_frames = SubResource("SpriteFrames_oj6iy")
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bvri0nv1jrigf"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_3u4op"]
|
||||
[ext_resource type="Shader" path="res://shaders/Laser.gdshader" id="2_h6cxi"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_yip5k"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_5n8cv"]
|
||||
shader = ExtResource("2_h6cxi")
|
||||
shader_parameter/color = Color(0.654902, 1, 1, 1)
|
||||
shader_parameter/laser_width = 0.01
|
||||
shader_parameter/soft_edge = 0.5
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_y85id"]
|
||||
height = 300.0
|
||||
|
||||
[node name="Laser" instance=ExtResource("1_3u4op")]
|
||||
fields = {
|
||||
0: 10,
|
||||
1: 5,
|
||||
2: 0
|
||||
}
|
||||
lifeTime = 100.0
|
||||
|
||||
[node name="texture" parent="." index="0"]
|
||||
rotation = 1.5708
|
||||
sprite_frames = SubResource("SpriteFrames_yip5k")
|
||||
|
||||
[node name="rect" type="ColorRect" parent="texture" index="0"]
|
||||
material = SubResource("ShaderMaterial_5n8cv")
|
||||
offset_left = -10.0
|
||||
offset_top = -300.0
|
||||
offset_right = 10.0
|
||||
|
||||
[node name="hitbox" parent="." index="1"]
|
||||
position = Vector2(150, 0)
|
||||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_y85id")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://becrg3g13ljxt"
|
||||
path="res://.godot/imported/laser.png-80aa0f0248a3e48158050bbd9850dd52.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/masks/laser.png"
|
||||
dest_files=["res://.godot/imported/laser.png-80aa0f0248a3e48158050bbd9850dd52.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -2,5 +2,6 @@ extends BulletBase
|
||||
class_name Diamond
|
||||
|
||||
func ai():
|
||||
rotation_degrees += 1
|
||||
if Time.get_ticks_msec() - spawnInWhen < 500: # 生成的前0.5秒可以追踪
|
||||
rotation = lerp_angle(rotation, position.angle_to_point(launcher.currentFocusedBoss.position), 0.1)
|
||||
forward(Vector2.from_angle(rotation))
|
||||
|
||||
@@ -3,8 +3,6 @@ class_name Chick
|
||||
|
||||
@onready var firepot = $"%firepot"
|
||||
|
||||
var angle = 0
|
||||
|
||||
func _ready():
|
||||
fields[FieldStore.Entity.MAX_HEALTH] = 1000
|
||||
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.1
|
||||
@@ -15,15 +13,20 @@ func ai():
|
||||
if currentFocusedBoss.position.distance_to(position) < 300:
|
||||
tryAttack(1)
|
||||
else:
|
||||
if tryAttack(0):
|
||||
angle += 20
|
||||
tryAttack(0)
|
||||
func attack(type):
|
||||
if type == 0:
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos, deg_to_rad(angle))
|
||||
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos, rotation + deg_to_rad(MathTool.randc_from([-90, 90])))
|
||||
elif type == 1:
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
var target = weaponPos.angle_to_point(currentFocusedBoss.position)
|
||||
firepot.global_rotation = target
|
||||
firepot.shot()
|
||||
BulletBase.generate(preload("res://components/Bullets/FireScan.tscn"), self, weaponPos, target)
|
||||
# elif type == 2:
|
||||
# var weaponPos = findWeaponAnchor("normal")
|
||||
# var target = weaponPos.angle_to_point(currentFocusedBoss.position)
|
||||
# firepot.global_rotation = target
|
||||
# firepot.shot()
|
||||
BulletBase.generate(preload("res://components/Bullets/Laser.tscn"), self, weaponPos, target)
|
||||
|
||||
@@ -13,7 +13,7 @@ static var countBoost: float = 0.1 # 每波增加的敌人数量百分比,指
|
||||
static var data: Array[Wave] = [
|
||||
# entity, minCount, maxCount, isBoss, from, to, per
|
||||
create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1),
|
||||
create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 8, INF, 1)
|
||||
create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 0, INF, 1)
|
||||
]
|
||||
|
||||
static func create(
|
||||
|
||||
@@ -25,7 +25,8 @@ func _process(_delta: float) -> void:
|
||||
if position.distance_to(spawnInWhere) >= lifeDistance:
|
||||
destroy()
|
||||
func _physics_process(_delta: float) -> void:
|
||||
ai()
|
||||
if is_instance_valid(launcher) and (launcher.isPlayer() or is_instance_valid(launcher.currentFocusedBoss)):
|
||||
ai()
|
||||
|
||||
func hit(target: Node):
|
||||
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
||||
|
||||
@@ -8,6 +8,6 @@ class_name ItemShow
|
||||
@onready var avatarTexture: TextureRect = $"%avatar"
|
||||
@onready var countLabel: Label = $"%count"
|
||||
|
||||
func _ready():
|
||||
func _physics_process(_delta):
|
||||
avatarTexture.texture = ItemStore.getTexture(type)
|
||||
countLabel.text = str(count)
|
||||
|
||||
@@ -6,4 +6,6 @@ static func randv2_range(offset: float):
|
||||
return Vector2(
|
||||
randf_range(-offset, offset),
|
||||
randf_range(-offset, offset)
|
||||
)
|
||||
)
|
||||
static func randc_from(array: Array):
|
||||
return array[randi() % array.size()]
|
||||
@@ -0,0 +1,12 @@
|
||||
shader_type canvas_item;
|
||||
uniform vec4 color: source_color;
|
||||
uniform float laser_width: hint_range(0.01, 1.0) = 0;
|
||||
uniform float soft_edge: hint_range(0.0, 0.5) = 0.5;
|
||||
void fragment() {
|
||||
float dist = abs(UV.x - 0.5);
|
||||
float core = 1.0 - smoothstep(0.0, laser_width, dist);
|
||||
float edge = 1.0 - smoothstep(laser_width, laser_width + soft_edge, dist);
|
||||
float alpha = max(core, edge);
|
||||
COLOR = color;
|
||||
COLOR.a = alpha;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
void fragment() {
|
||||
COLOR=vec4(vec2(textureSize(TEXTURE,0)),0,1);
|
||||
}
|
||||
Reference in New Issue
Block a user