mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:15:45 +00:00
Delayed speed increase modifier
This commit is contained in:
parent
0e26056aa1
commit
97027ddc33
11 changed files with 145 additions and 9 deletions
|
|
@ -1,11 +1,25 @@
|
|||
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://bopwqpmxoy1rd"]
|
||||
[gd_resource type="Resource" script_class="BulletResource" load_steps=6 format=3 uid="uid://bopwqpmxoy1rd"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_i4nah"]
|
||||
[ext_resource type="PackedScene" uid="uid://eqppkegmt562" path="res://Scenes/Weapons/Bullets/Yin_Yan_Bullet.tscn" id="1_5pffv"]
|
||||
[ext_resource type="PackedScene" uid="uid://h11o0et1y54v" path="res://Scenes/Weapons/Bullets/explosion.tscn" id="2_26vvh"]
|
||||
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_dbvc7"]
|
||||
[ext_resource type="Script" uid="uid://ci2vjo54w7i18" path="res://Scripts/Resources/Modifiers/DelayedSpeedIncreaseModifier.cs" id="2_w7k7r"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_26vvh"]
|
||||
script = ExtResource("2_w7k7r")
|
||||
TransitionType = 2
|
||||
EaseType = 2
|
||||
Duration = 0.5
|
||||
TimeInSeconds = 0.0
|
||||
ModifierType = 0
|
||||
Value = 20.0
|
||||
Continuous = false
|
||||
metadata/_custom_type_script = "uid://ci2vjo54w7i18"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_dbvc7")
|
||||
BulletScene = ExtResource("1_i4nah")
|
||||
BulletScene = ExtResource("1_5pffv")
|
||||
DestructionParticlesScene = ExtResource("2_26vvh")
|
||||
BulletSpeed = 100.0
|
||||
Direction = Vector2(1, 0)
|
||||
BulletDamage = 50.0
|
||||
|
|
@ -13,5 +27,5 @@ LifeTime = 10.0
|
|||
DestroyOnCollision = true
|
||||
Owner = 1
|
||||
DamageType = 0
|
||||
Controllable = true
|
||||
TimeModifiers = null
|
||||
Controllable = false
|
||||
TimeModifiers = Array[Object]([SubResource("Resource_26vvh")])
|
||||
|
|
|
|||
19
Resources/Bullets/yin_yang_bullet.tres
Normal file
19
Resources/Bullets/yin_yang_bullet.tres
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[gd_resource type="Resource" script_class="BulletResource" load_steps=4 format=3 uid="uid://brfrxovsuxgts"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://eqppkegmt562" path="res://Scenes/Weapons/Bullets/Yin_Yan_Bullet.tscn" id="1_lfcuj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dfbmny3s4rili" path="res://Scenes/Particles/IceBulletParticle.tscn" id="2_mdq2b"]
|
||||
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="3_78iov"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("3_78iov")
|
||||
BulletScene = ExtResource("1_lfcuj")
|
||||
DestructionParticlesScene = ExtResource("2_mdq2b")
|
||||
BulletSpeed = 100.0
|
||||
Direction = Vector2(1, 0)
|
||||
BulletDamage = 4.0
|
||||
LifeTime = 10.0
|
||||
DestroyOnCollision = true
|
||||
Owner = 1
|
||||
DamageType = 1
|
||||
Controllable = false
|
||||
TimeModifiers = null
|
||||
29
Scenes/Weapons/Bullets/Yin_Yan_Bullet.tscn
Normal file
29
Scenes/Weapons/Bullets/Yin_Yan_Bullet.tscn
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://eqppkegmt562"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dsa4b75hdig8p" path="res://Scripts/Bullet.cs" id="1_lg4re"]
|
||||
[ext_resource type="Texture2D" uid="uid://cy86tmig4yx8k" path="res://Sprites/Bullets/mid_bullet_yinyang.png" id="2_smwha"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||
radius = 2.23607
|
||||
|
||||
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
||||
collision_layer = 8
|
||||
collision_mask = 85
|
||||
script = ExtResource("1_lg4re")
|
||||
Speed = 200.0
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_smwha")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_jxptd")
|
||||
|
||||
[node name="Node2D" type="Node2D" parent="."]
|
||||
editor_description = "Player Bullet"
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||
|
||||
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||
|
|
@ -59,9 +59,14 @@ public partial class Bullet : Area2D
|
|||
{
|
||||
modifier.Applied = true;
|
||||
modifier.TimeModifier.Start(this);
|
||||
modifier.Elapsed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
modifier.Elapsed += delta;
|
||||
}
|
||||
|
||||
modifier.TimeModifier.Update(this, delta);
|
||||
modifier.TimeModifier.Update(this, delta, modifier.Elapsed);
|
||||
|
||||
// switch (modifier.ModifierType)
|
||||
// {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Cirno.Scripts.Resources.Modifiers;
|
|||
[GlobalClass]
|
||||
public partial class DelayedContinuousRotationModifier : TimeModifier
|
||||
{
|
||||
public override void Update(Bullet bullet, double delta)
|
||||
public override void Update(Bullet bullet, double delta, double elapsed)
|
||||
{
|
||||
bullet.RotateSpriteDegrees((float)(Value * delta));
|
||||
}
|
||||
|
|
|
|||
26
Scripts/Resources/Modifiers/DelayedSpeedIncreaseModifier.cs
Normal file
26
Scripts/Resources/Modifiers/DelayedSpeedIncreaseModifier.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources.Modifiers;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DelayedSpeedIncreaseModifier : TimeModifier
|
||||
{
|
||||
|
||||
[Export] public Tween.TransitionType TransitionType { get; set; } = Tween.TransitionType.Linear;
|
||||
[Export] public Tween.EaseType EaseType { get; set; } = Tween.EaseType.InOut;
|
||||
|
||||
[Export] public float Duration { get; set; } = 1.0f;
|
||||
|
||||
public override void Update(Bullet bullet, double delta, double elapsed)
|
||||
{
|
||||
float easedValue = ApplyEasing(Value, elapsed);
|
||||
bullet.Speed += easedValue;
|
||||
}
|
||||
|
||||
private float ApplyEasing(float value, double time)
|
||||
{
|
||||
float t = Mathf.Clamp((float)time, 0f, 1f); // Ensure the value stays within range
|
||||
return (float)Tween.InterpolateValue(0f, value, t, Duration, TransitionType, EaseType);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ci2vjo54w7i18
|
||||
|
|
@ -17,7 +17,8 @@ public partial class TimeModifier : Resource
|
|||
return new ModifierWrapper()
|
||||
{
|
||||
TimeModifier = this,
|
||||
Applied = false
|
||||
Applied = false,
|
||||
Elapsed = 0.0,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ public partial class TimeModifier : Resource
|
|||
|
||||
}
|
||||
|
||||
public virtual void Update(Bullet bullet, double delta)
|
||||
public virtual void Update(Bullet bullet, double delta, double elapsed)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -41,6 +42,7 @@ public class ModifierWrapper
|
|||
{
|
||||
public TimeModifier TimeModifier { get; set; }
|
||||
public bool Applied { get; set; } = false;
|
||||
public double Elapsed { get; set; } = 0f;
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
|
|
|
|||
BIN
Sprites/Bullets/mid_bullet_yinyang.aseprite
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/mid_bullet_yinyang.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Sprites/Bullets/mid_bullet_yinyang.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/mid_bullet_yinyang.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Bullets/mid_bullet_yinyang.png.import
Normal file
34
Sprites/Bullets/mid_bullet_yinyang.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cy86tmig4yx8k"
|
||||
path="res://.godot/imported/mid_bullet_yinyang.png-308b67e1a7b40a14eae4073b5ef45a8d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Bullets/mid_bullet_yinyang.png"
|
||||
dest_files=["res://.godot/imported/mid_bullet_yinyang.png-308b67e1a7b40a14eae4073b5ef45a8d.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
|
||||
Loading…
Add table
Add a link
Reference in a new issue