mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-20 12:33:46 +00:00
New Modifier
This commit is contained in:
parent
50c111ee28
commit
019f7d7ca0
18 changed files with 423 additions and 45 deletions
48
Resources/BossPhases/Rumia_SP1.tres
Normal file
48
Resources/BossPhases/Rumia_SP1.tres
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
[gd_resource type="Resource" script_class="BossPhase" load_steps=9 format=3 uid="uid://ccj0cqbveey8c"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dohakkayqj4w2" path="res://Scenes/Weapons/Bullets/enemyBullet_green.tscn" id="1_o4um1"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Resources/SpeedModifier.cs" id="2_8gbml"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="2_7268a"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="3_o6234"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://by2rk6gx67f7e" path="res://Scenes/Weapons/Bullets/enemyBullet_yellow.tscn" id="4_ruawj"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_l3ln6"]
|
||||||
|
script = ExtResource("2_8gbml")
|
||||||
|
ModifierType = 1
|
||||||
|
Easing = 0
|
||||||
|
Invert = false
|
||||||
|
MinimumSpeed = 10.0
|
||||||
|
ScalingFactor = 10.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_0v4v8"]
|
||||||
|
script = ExtResource("2_7268a")
|
||||||
|
BulletScene = ExtResource("1_o4um1")
|
||||||
|
bulletSpeed = 80.0
|
||||||
|
bulletCount = 9
|
||||||
|
rotationSpeed = 0.0
|
||||||
|
_rotationOffset = 50.0
|
||||||
|
duration = 1.0
|
||||||
|
burstInterval = 1.0
|
||||||
|
spread = 180.0
|
||||||
|
owner = 2
|
||||||
|
_modifier = SubResource("Resource_l3ln6")
|
||||||
|
WaitForCompletion = true
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_7yi74"]
|
||||||
|
script = ExtResource("2_7268a")
|
||||||
|
BulletScene = ExtResource("4_ruawj")
|
||||||
|
bulletSpeed = 80.0
|
||||||
|
bulletCount = 9
|
||||||
|
rotationSpeed = 0.0
|
||||||
|
_rotationOffset = -50.0
|
||||||
|
duration = 1.0
|
||||||
|
burstInterval = 1.0
|
||||||
|
spread = 180.0
|
||||||
|
owner = 2
|
||||||
|
_modifier = SubResource("Resource_l3ln6")
|
||||||
|
WaitForCompletion = true
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("3_o6234")
|
||||||
|
Threshold = 800
|
||||||
|
Patterns = Array[Resource]([SubResource("Resource_0v4v8"), SubResource("Resource_7yi74")])
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_resource type="Resource" script_class="TargetedPattern" load_steps=5 format=3 uid="uid://csudslb5tliw4"]
|
[gd_resource type="Resource" script_class="TargetedPattern" load_steps=5 format=3 uid="uid://csudslb5tliw4"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://by2rk6gx67f7e" path="res://Scenes/Weapons/Bullets/enemyBullet_yellow.tscn" id="1_pocps"]
|
[ext_resource type="PackedScene" uid="uid://bi3f14klscvlw" path="res://Scenes/Weapons/Bullets/enemyBullet_mid_red.tscn" id="1_aif45"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Resources/DecreasingSpeedModifier.cs" id="2_wxqq0"]
|
[ext_resource type="Script" path="res://Scripts/Resources/DecreasingSpeedModifier.cs" id="2_wxqq0"]
|
||||||
[ext_resource type="Script" path="res://Scripts/AttackPatterns/TargetedPattern.cs" id="3_ht3k1"]
|
[ext_resource type="Script" path="res://Scripts/AttackPatterns/TargetedPattern.cs" id="3_ht3k1"]
|
||||||
|
|
||||||
|
|
@ -10,10 +10,10 @@ decreaseRate = 4.0
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("3_ht3k1")
|
script = ExtResource("3_ht3k1")
|
||||||
BulletScene = ExtResource("1_pocps")
|
BulletScene = ExtResource("1_aif45")
|
||||||
bulletSpeed = 50.0
|
bulletSpeed = 70.0
|
||||||
duration = 4.0
|
duration = 3.0
|
||||||
burstInterval = 0.4
|
burstInterval = 0.3
|
||||||
bulletsPerShot = 10
|
bulletsPerShot = 10
|
||||||
spread = 0.0
|
spread = 0.0
|
||||||
owner = 2
|
owner = 2
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
[gd_resource type="Resource" script_class="PatternGroup" load_steps=8 format=3 uid="uid://du2kuv125vbrx"]
|
[gd_resource type="Resource" script_class="PatternGroup" load_steps=8 format=3 uid="uid://du2kuv125vbrx"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://b0clsnefjsohc" path="res://Scenes/Weapons/Bullets/enemyBullet_mid.tscn" id="1_tt36x"]
|
[ext_resource type="PackedScene" uid="uid://dre2wvw4pa3hc" path="res://Scenes/Weapons/Bullets/enemyBullet_mid_blue.tscn" id="1_4xpdn"]
|
||||||
[ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="2_ee42k"]
|
[ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="2_ee42k"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dohakkayqj4w2" path="res://Scenes/Weapons/Bullets/enemyBullet_green.tscn" id="3_gr7a3"]
|
[ext_resource type="PackedScene" uid="uid://dohakkayqj4w2" path="res://Scenes/Weapons/Bullets/enemyBullet_green.tscn" id="3_gr7a3"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Resources/PatternGroup.cs" id="3_jvysx"]
|
[ext_resource type="Script" path="res://Scripts/Resources/PatternGroup.cs" id="3_jvysx"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_ne4q3"]
|
[sub_resource type="Resource" id="Resource_ne4q3"]
|
||||||
script = ExtResource("2_ee42k")
|
script = ExtResource("2_ee42k")
|
||||||
BulletScene = ExtResource("1_tt36x")
|
BulletScene = ExtResource("1_4xpdn")
|
||||||
bulletSpeed = 20.0
|
bulletSpeed = 20.0
|
||||||
bulletCount = 10
|
bulletCount = 10
|
||||||
rotationSpeed = 120.0
|
rotationSpeed = 120.0
|
||||||
duration = 4.0
|
_rotationOffset = 0.0
|
||||||
|
duration = 1.0
|
||||||
burstInterval = 2.0
|
burstInterval = 2.0
|
||||||
spread = 360.0
|
spread = 360.0
|
||||||
owner = 2
|
owner = 2
|
||||||
|
|
@ -22,8 +23,9 @@ script = ExtResource("2_ee42k")
|
||||||
BulletScene = ExtResource("3_gr7a3")
|
BulletScene = ExtResource("3_gr7a3")
|
||||||
bulletSpeed = 20.0
|
bulletSpeed = 20.0
|
||||||
bulletCount = 16
|
bulletCount = 16
|
||||||
rotationSpeed = 120.0
|
rotationSpeed = 60.0
|
||||||
duration = 4.0
|
_rotationOffset = 0.0
|
||||||
|
duration = 1.0
|
||||||
burstInterval = 2.0
|
burstInterval = 2.0
|
||||||
spread = 360.0
|
spread = 360.0
|
||||||
owner = 2
|
owner = 2
|
||||||
|
|
@ -31,10 +33,11 @@ WaitForCompletion = true
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_depjj"]
|
[sub_resource type="Resource" id="Resource_depjj"]
|
||||||
script = ExtResource("2_ee42k")
|
script = ExtResource("2_ee42k")
|
||||||
BulletScene = ExtResource("1_tt36x")
|
BulletScene = ExtResource("1_4xpdn")
|
||||||
bulletSpeed = 30.0
|
bulletSpeed = 20.0
|
||||||
bulletCount = 10
|
bulletCount = 10
|
||||||
rotationSpeed = 120.0
|
rotationSpeed = 60.0
|
||||||
|
_rotationOffset = 0.0
|
||||||
duration = 4.0
|
duration = 4.0
|
||||||
burstInterval = 2.0
|
burstInterval = 2.0
|
||||||
spread = 360.0
|
spread = 360.0
|
||||||
|
|
@ -43,5 +46,5 @@ WaitForCompletion = true
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("3_jvysx")
|
script = ExtResource("3_jvysx")
|
||||||
patterns = Array[Resource]([SubResource("Resource_ne4q3"), SubResource("Resource_kohuh"), SubResource("Resource_depjj")])
|
patterns = Array[Resource]([SubResource("Resource_ne4q3"), SubResource("Resource_kohuh"), SubResource("Resource_kohuh"), SubResource("Resource_depjj"), SubResource("Resource_depjj"), SubResource("Resource_kohuh"), SubResource("Resource_depjj")])
|
||||||
WaitForCompletion = true
|
WaitForCompletion = true
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,6 @@ lifetime = 0.8
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = ExtResource("2_k58t7")
|
sprite_frames = ExtResource("2_k58t7")
|
||||||
animation = &"Default"
|
animation = &"Default"
|
||||||
frame_progress = 0.580599
|
frame_progress = 0.462812
|
||||||
|
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,13 @@
|
||||||
[gd_scene load_steps=12 format=4 uid="uid://bu5fvatj2j08j"]
|
[gd_scene load_steps=8 format=4 uid="uid://bu5fvatj2j08j"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_paetl"]
|
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_paetl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d1rlw6ddpmrn8" path="res://Scenes/Actors/Rumia.tscn" id="2_47q21"]
|
[ext_resource type="PackedScene" uid="uid://d1rlw6ddpmrn8" path="res://Scenes/Actors/Rumia.tscn" id="2_47q21"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_f17ts"]
|
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_f17ts"]
|
||||||
[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="3_cyhmq"]
|
[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="3_cyhmq"]
|
||||||
[ext_resource type="Resource" uid="uid://ks6fypeil6gk" path="res://Resources/BossPhases/TestBoss1.tres" id="5_jkuab"]
|
[ext_resource type="Resource" uid="uid://ks6fypeil6gk" path="res://Resources/BossPhases/TestBoss1.tres" id="5_jkuab"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dohakkayqj4w2" path="res://Scenes/Weapons/Bullets/enemyBullet_green.tscn" id="6_8e062"]
|
[ext_resource type="Resource" uid="uid://ccj0cqbveey8c" path="res://Resources/BossPhases/Rumia_SP1.tres" id="6_1uicx"]
|
||||||
[ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="7_pi1kp"]
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="8_jya7d"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bdp710abe10s5" path="res://Scenes/Interactable/AreaTrigger.tscn" id="9_xhf0g"]
|
[ext_resource type="PackedScene" uid="uid://bdp710abe10s5" path="res://Scenes/Interactable/AreaTrigger.tscn" id="9_xhf0g"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_0v4v8"]
|
|
||||||
script = ExtResource("7_pi1kp")
|
|
||||||
BulletScene = ExtResource("6_8e062")
|
|
||||||
bulletSpeed = 40.0
|
|
||||||
bulletCount = 30
|
|
||||||
rotationSpeed = 200.0
|
|
||||||
duration = 8.0
|
|
||||||
burstInterval = 0.5
|
|
||||||
spread = 180.0
|
|
||||||
owner = 2
|
|
||||||
WaitForCompletion = true
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_rasgx"]
|
|
||||||
script = ExtResource("8_jya7d")
|
|
||||||
Threshold = 600
|
|
||||||
Patterns = Array[Resource]([SubResource("Resource_0v4v8")])
|
|
||||||
|
|
||||||
[node name="GameScene" type="Node2D" node_paths=PackedStringArray("PlayerSpawnMarker")]
|
[node name="GameScene" type="Node2D" node_paths=PackedStringArray("PlayerSpawnMarker")]
|
||||||
script = ExtResource("1_paetl")
|
script = ExtResource("1_paetl")
|
||||||
PlayerTemplate = ExtResource("2_f17ts")
|
PlayerTemplate = ExtResource("2_f17ts")
|
||||||
|
|
@ -49,8 +30,8 @@ tile_map_data = PackedByteArray("AAAIAAAAAAAAAAIAAAAJAAAAAAAAAAIAAAAOAAAAAAAAAAI
|
||||||
tile_set = ExtResource("3_cyhmq")
|
tile_set = ExtResource("3_cyhmq")
|
||||||
|
|
||||||
[node name="Rumia" parent="." instance=ExtResource("2_47q21")]
|
[node name="Rumia" parent="." instance=ExtResource("2_47q21")]
|
||||||
position = Vector2(178, 63)
|
position = Vector2(176, 44)
|
||||||
Phases = Array[Resource]([ExtResource("5_jkuab"), SubResource("Resource_rasgx")])
|
Phases = Array[Resource]([ExtResource("6_1uicx"), ExtResource("5_jkuab")])
|
||||||
|
|
||||||
[node name="PlayerStartPosition" type="Marker2D" parent="."]
|
[node name="PlayerStartPosition" type="Marker2D" parent="."]
|
||||||
position = Vector2(178, 115)
|
position = Vector2(178, 115)
|
||||||
|
|
|
||||||
27
Scenes/Weapons/Bullets/enemyBullet_mid_blue.tscn
Normal file
27
Scenes/Weapons/Bullets/enemyBullet_mid_blue.tscn
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dre2wvw4pa3hc"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Bullet.cs" id="1_p8khg"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dooyhu8vt63vm" path="res://Sprites/Bullets/mid_bullet_blue.png" id="2_0v242"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||||
|
radius = 2.23607
|
||||||
|
|
||||||
|
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
||||||
|
collision_layer = 128
|
||||||
|
collision_mask = 71
|
||||||
|
script = ExtResource("1_p8khg")
|
||||||
|
Speed = 200.0
|
||||||
|
Owner = 2
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("2_0v242")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("CircleShape2D_jxptd")
|
||||||
|
|
||||||
|
[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"]
|
||||||
27
Scenes/Weapons/Bullets/enemyBullet_mid_red.tscn
Normal file
27
Scenes/Weapons/Bullets/enemyBullet_mid_red.tscn
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://bi3f14klscvlw"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Bullet.cs" id="1_jnw2a"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cfldr7l7dearo" path="res://Sprites/Bullets/mid_bullet_red.png" id="2_4q6eb"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||||
|
radius = 2.23607
|
||||||
|
|
||||||
|
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
||||||
|
collision_layer = 128
|
||||||
|
collision_mask = 71
|
||||||
|
script = ExtResource("1_jnw2a")
|
||||||
|
Speed = 200.0
|
||||||
|
Owner = 2
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("2_4q6eb")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("CircleShape2D_jxptd")
|
||||||
|
|
||||||
|
[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"]
|
||||||
|
|
@ -11,11 +11,13 @@ public partial class SpiralPattern : AttackPattern
|
||||||
[Export] public PackedScene BulletScene;
|
[Export] public PackedScene BulletScene;
|
||||||
[Export] private float bulletSpeed = 5f;
|
[Export] private float bulletSpeed = 5f;
|
||||||
[Export] private int bulletCount = 16;
|
[Export] private int bulletCount = 16;
|
||||||
[Export] private float rotationSpeed = 90f;
|
[Export] private float rotationSpeed = 0f;
|
||||||
|
[Export] private float _rotationOffset = 0f;
|
||||||
[Export] private float duration = 5f;
|
[Export] private float duration = 5f;
|
||||||
[Export] private float burstInterval = 0.5f;
|
[Export] private float burstInterval = 0.5f;
|
||||||
[Export] private float spread = 360f;
|
[Export] private float spread = 360f;
|
||||||
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
||||||
|
[Export] private Resource _modifier;
|
||||||
|
|
||||||
private double timer;
|
private double timer;
|
||||||
private double burstTimer;
|
private double burstTimer;
|
||||||
|
|
@ -35,7 +37,22 @@ public partial class SpiralPattern : AttackPattern
|
||||||
burstTimer += delta;
|
burstTimer += delta;
|
||||||
if (timer < duration && burstTimer >= burstInterval)
|
if (timer < duration && burstTimer >= burstInterval)
|
||||||
{
|
{
|
||||||
spawner.SpawnSpiralPattern(Boss.GlobalPosition, bulletSpeed, owner, bulletCount, rotationSpeed, timer, spread, BulletScene);
|
float angleOffset = (float)(rotationSpeed * timer);
|
||||||
|
|
||||||
|
spawner.SpawnBullet(new BulletInfo()
|
||||||
|
{
|
||||||
|
Position = Boss.GlobalPosition,
|
||||||
|
Direction = Vector2.Right,
|
||||||
|
Speed = bulletSpeed,
|
||||||
|
Owner = owner,
|
||||||
|
BulletCount = bulletCount,
|
||||||
|
Spread = spread,
|
||||||
|
BulletScene = BulletScene,
|
||||||
|
RotationOffset = _rotationOffset,
|
||||||
|
Modifier = _modifier as IBulletModifier,
|
||||||
|
});
|
||||||
|
|
||||||
|
// spawner.SpawnSpiralPattern(Boss.GlobalPosition, bulletSpeed, owner, bulletCount, rotationSpeed, timer, spread, BulletScene);
|
||||||
burstTimer = 0;
|
burstTimer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Cirno.Scripts.Resources;
|
using System;
|
||||||
|
using Cirno.Scripts.Resources;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Cirno.Scripts.Components;
|
namespace Cirno.Scripts.Components;
|
||||||
|
|
@ -12,6 +13,32 @@ public partial class BulletSpawner : Node2D
|
||||||
{
|
{
|
||||||
_gameManager = GetNode<GameManager>("/root/GameScene");
|
_gameManager = GetNode<GameManager>("/root/GameScene");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SpawnBullet(BulletInfo bulletInfo)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < bulletInfo.BulletCount; i++)
|
||||||
|
{
|
||||||
|
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, bulletInfo.BulletScene ?? BulletScene, bulletInfo.Position);
|
||||||
|
|
||||||
|
//var bullet = BulletScene.Instantiate<Bullet>();
|
||||||
|
bullet.Position = bulletInfo.Position;
|
||||||
|
bullet.Owner = bulletInfo.Owner;
|
||||||
|
//bullet.Speed = speed;
|
||||||
|
|
||||||
|
float modifiedSpeed = bulletInfo.Modifier?.ModifySpeed(bulletInfo.Speed, i, bulletInfo.BulletCount) ?? bulletInfo.Speed;
|
||||||
|
bullet.Speed = modifiedSpeed;
|
||||||
|
|
||||||
|
Vector2 baseDirection = bulletInfo.Direction == Vector2.Zero ? Vector2.Right : bulletInfo.Direction.Normalized();
|
||||||
|
float baseAngle = Mathf.Atan2(baseDirection.Y, baseDirection.X);
|
||||||
|
//float angle = angleOffset + (360 / count) * i;
|
||||||
|
float angle = baseAngle + Mathf.DegToRad(bulletInfo.RotationOffset + (bulletInfo.Spread / bulletInfo.BulletCount) * i);
|
||||||
|
Vector2 bulletDirection = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));
|
||||||
|
//Vector2 bulletDirection = new Vector2(Mathf.Cos(Mathf.DegToRad(angle)), Mathf.Sin(Mathf.DegToRad(angle)));
|
||||||
|
|
||||||
|
bullet.SetDirection(bulletDirection);
|
||||||
|
//GetParent().AddChild(bullet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SpawnBullet(Vector2 position, Vector2 direction, float speed, BulletOwner owner, int count = 1, float angleOffset = 0, float spread = 0, PackedScene bulletScene = null, IBulletModifier modifier = null)
|
public void SpawnBullet(Vector2 position, Vector2 direction, float speed, BulletOwner owner, int count = 1, float angleOffset = 0, float spread = 0, PackedScene bulletScene = null, IBulletModifier modifier = null)
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +51,7 @@ public partial class BulletSpawner : Node2D
|
||||||
bullet.Owner = owner;
|
bullet.Owner = owner;
|
||||||
//bullet.Speed = speed;
|
//bullet.Speed = speed;
|
||||||
|
|
||||||
float modifiedSpeed = modifier?.ModifySpeed(speed, i) ?? speed;
|
float modifiedSpeed = modifier?.ModifySpeed(speed, i, count) ?? speed;
|
||||||
bullet.Speed = modifiedSpeed;
|
bullet.Speed = modifiedSpeed;
|
||||||
|
|
||||||
Vector2 baseDirection = direction == Vector2.Zero ? Vector2.Right : direction.Normalized();
|
Vector2 baseDirection = direction == Vector2.Zero ? Vector2.Right : direction.Normalized();
|
||||||
|
|
@ -44,10 +71,26 @@ public partial class BulletSpawner : Node2D
|
||||||
Vector2 direction = (target - position).Normalized();
|
Vector2 direction = (target - position).Normalized();
|
||||||
SpawnBullet(position, direction, speed, owner, burstCount, spread: spread, bulletScene: bulletScene, modifier: modifier);
|
SpawnBullet(position, direction, speed, owner, burstCount, spread: spread, bulletScene: bulletScene, modifier: modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
public void SpawnSpiralPattern(Vector2 position, float speed, BulletOwner owner, int bulletCount, float rotationSpeed, double time, float spread, PackedScene bulletScene = null)
|
public void SpawnSpiralPattern(Vector2 position, float speed, BulletOwner owner, int bulletCount, float rotationSpeed, double time, float spread, PackedScene bulletScene = null)
|
||||||
{
|
{
|
||||||
float angleOffset = (float)(rotationSpeed * time);
|
float angleOffset = (float)(rotationSpeed * time);
|
||||||
SpawnBullet(position, Vector2.Right, speed, owner, bulletCount, angleOffset, spread, bulletScene: bulletScene);
|
SpawnBullet(position, Vector2.Right, speed, owner, bulletCount, angleOffset, spread, bulletScene: bulletScene);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BulletInfo
|
||||||
|
{
|
||||||
|
public Vector2 Position { get; set; }
|
||||||
|
public Vector2 Direction { get; set; }
|
||||||
|
public float Speed { get; set; }
|
||||||
|
public BulletOwner Owner { get; set; }
|
||||||
|
public int BulletCount { get; set; }
|
||||||
|
public float RotationSpeed { get; set; }
|
||||||
|
public float RotationOffset { get; set; }
|
||||||
|
//public double Time { get; set; }
|
||||||
|
public float Spread { get; set; }
|
||||||
|
public PackedScene BulletScene { get; set; }
|
||||||
|
public IBulletModifier Modifier { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ public partial class DecreasingSpeedModifier : Resource, IBulletModifier
|
||||||
{
|
{
|
||||||
[Export] private float decreaseRate = 0.1f;
|
[Export] private float decreaseRate = 0.1f;
|
||||||
|
|
||||||
public float ModifySpeed(float baseSpeed, int bulletIndex)
|
public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||||
{
|
{
|
||||||
return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex));
|
return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
public interface IBulletModifier
|
public interface IBulletModifier
|
||||||
{
|
{
|
||||||
float ModifySpeed(float baseSpeed, int bulletIndex);
|
float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets);
|
||||||
}
|
}
|
||||||
152
Scripts/Resources/SpeedModifier.cs
Normal file
152
Scripts/Resources/SpeedModifier.cs
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Resources;
|
||||||
|
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class SpeedModifier : Resource, IBulletModifier
|
||||||
|
{
|
||||||
|
[Export] public SpeedModifierType ModifierType;
|
||||||
|
[Export] public EasingType Easing;
|
||||||
|
[Export] public bool Invert = false;
|
||||||
|
[Export] public float MinimumSpeed = 10f;
|
||||||
|
[Export] public float ScalingFactor = 10.0f;
|
||||||
|
|
||||||
|
public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||||
|
{
|
||||||
|
if (totalBullets <= 1)
|
||||||
|
return baseSpeed;
|
||||||
|
|
||||||
|
float t = (float)bulletIndex / (totalBullets - 1); // Normalize to [0,1]
|
||||||
|
t = ApplyEasing(t);
|
||||||
|
|
||||||
|
return Mathf.Lerp(MinimumSpeed, baseSpeed, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float ApplyEasing(float t)
|
||||||
|
{
|
||||||
|
switch (ModifierType)
|
||||||
|
{
|
||||||
|
case SpeedModifierType.Linear:
|
||||||
|
return t;
|
||||||
|
case SpeedModifierType.Quad:
|
||||||
|
return Easing == EasingType.In ? t * t : Easing == EasingType.Out ? 1 - (1 - t) * (1 - t) : (t < 0.5f ? 2 * t * t : 1 - Mathf.Pow(-2 * t + 2, 2) / 2);
|
||||||
|
case SpeedModifierType.Sine:
|
||||||
|
return Easing == EasingType.In ? 1 - Mathf.Cos((t * Mathf.Pi) / 2) : Easing == EasingType.Out ? Mathf.Sin((t * Mathf.Pi) / 2) : -(Mathf.Cos(Mathf.Pi * t) - 1) / 2;
|
||||||
|
case SpeedModifierType.Exponential:
|
||||||
|
return Easing == EasingType.In ? Mathf.Pow(2, 10 * (t - 1)) : Easing == EasingType.Out ? 1 - Mathf.Pow(2, -10 * t) : (t < 0.5f ? Mathf.Pow(2, 10 * (2 * t - 1)) / 2 : (2 - Mathf.Pow(2, -10 * (2 * t - 1))) / 2);
|
||||||
|
case SpeedModifierType.Quint:
|
||||||
|
return Easing == EasingType.In ? t * t * t * t * t : Easing == EasingType.Out ? 1 - Mathf.Pow(1 - t, 5) : (t < 0.5f ? 16 * t * t * t * t * t : 1 - Mathf.Pow(-2 * t + 2, 5) / 2);
|
||||||
|
case SpeedModifierType.Circ:
|
||||||
|
return Easing == EasingType.In ? 1 - Mathf.Sqrt(1 - t * t) : Easing == EasingType.Out ? Mathf.Sqrt(1 - Mathf.Pow(t - 1, 2)) : (t < 0.5f ? (1 - Mathf.Sqrt(1 - 4 * t * t)) / 2 : (Mathf.Sqrt(1 - Mathf.Pow(-2 * t + 2, 2)) + 1) / 2);
|
||||||
|
case SpeedModifierType.Cubic:
|
||||||
|
return Easing == EasingType.In ? t * t * t : Easing == EasingType.Out ? 1 - Mathf.Pow(1 - t, 3) : (t < 0.5f ? 4 * t * t * t : 1 - Mathf.Pow(-2 * t + 2, 3) / 2);
|
||||||
|
case SpeedModifierType.Quart:
|
||||||
|
return Easing == EasingType.In ? t * t * t * t : Easing == EasingType.Out ? 1 - Mathf.Pow(1 - t, 4) : (t < 0.5f ? 8 * t * t * t * t : 1 - Mathf.Pow(-2 * t + 2, 4) / 2);
|
||||||
|
case SpeedModifierType.Elastic:
|
||||||
|
return Easing == EasingType.In ? (t == 0 ? 0 : t == 1 ? 1 : -Mathf.Pow(2, 10 * t - 10) * Mathf.Sin((t * 10 - 10.75f) * ((2 * Mathf.Pi) / 3))) : Easing == EasingType.Out ? (t == 0 ? 0 : t == 1 ? 1 : Mathf.Pow(2, -10 * t) * Mathf.Sin((t * 10 - 0.75f) * ((2 * Mathf.Pi) / 3)) + 1) : (t < 0.5f ? -(Mathf.Pow(2, 20 * t - 10) * Mathf.Sin((20 * t - 11.125f) * ((2 * Mathf.Pi) / 3))) / 2 : (Mathf.Pow(2, -20 * t + 10) * Mathf.Sin((20 * t - 11.125f) * ((2 * Mathf.Pi) / 3))) / 2 + 1);
|
||||||
|
case SpeedModifierType.Back:
|
||||||
|
float c1 = 1.70158f;
|
||||||
|
float c2 = c1 * 1.525f;
|
||||||
|
return Easing == EasingType.In ? (c1 + 1) * t * t * t - c1 * t * t : Easing == EasingType.Out ? 1 + (c1 + 1) * Mathf.Pow(t - 1, 3) + c1 * Mathf.Pow(t - 1, 2) : (t < 0.5f ? (Mathf.Pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2 : (Mathf.Pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2);
|
||||||
|
case SpeedModifierType.Bounce:
|
||||||
|
return Easing == EasingType.In ? 1 - ApplyEasing(1 - t) : Easing == EasingType.Out ? BounceEaseOut(t) : (t < 0.5f ? (1 - BounceEaseOut(1 - 2 * t)) / 2 : (1 + BounceEaseOut(2 * t - 1)) / 2);
|
||||||
|
default:
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float BounceEaseOut(float t)
|
||||||
|
{
|
||||||
|
if (t < 1 / 2.75f) return 7.5625f * t * t;
|
||||||
|
else if (t < 2 / 2.75f) return 7.5625f * (t -= 1.5f / 2.75f) * t + 0.75f;
|
||||||
|
else if (t < 2.5f / 2.75f) return 7.5625f * (t -= 2.25f / 2.75f) * t + 0.9375f;
|
||||||
|
else return 7.5625f * (t -= 2.625f / 2.75f) * t + 0.984375f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float ApplyModifier(float baseSpeed, float factor)
|
||||||
|
{
|
||||||
|
float easedFactor = factor;
|
||||||
|
|
||||||
|
switch (Easing)
|
||||||
|
{
|
||||||
|
case EasingType.In:
|
||||||
|
easedFactor = factor * factor;
|
||||||
|
break;
|
||||||
|
case EasingType.Out:
|
||||||
|
easedFactor = 1 - Mathf.Pow(1 - factor, 2);
|
||||||
|
break;
|
||||||
|
case EasingType.InOut:
|
||||||
|
easedFactor = factor < 0.5f ? 2 * factor * factor : 1 - Mathf.Pow(-2 * factor + 2, 2) / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
float speedRange = baseSpeed - MinimumSpeed;
|
||||||
|
float modifiedSpeed = MinimumSpeed + speedRange * easedFactor;
|
||||||
|
|
||||||
|
switch (ModifierType)
|
||||||
|
{
|
||||||
|
case SpeedModifierType.Sine:
|
||||||
|
modifiedSpeed *= Mathf.Sin(easedFactor * Mathf.Pi * 0.5f);
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Quad:
|
||||||
|
modifiedSpeed *= easedFactor * easedFactor;
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Exponential:
|
||||||
|
modifiedSpeed *= Mathf.Pow(2, easedFactor) - 1;
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Quint:
|
||||||
|
modifiedSpeed *= easedFactor * easedFactor * easedFactor * easedFactor * easedFactor;
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Circ:
|
||||||
|
modifiedSpeed *= 1 - Mathf.Sqrt(1 - easedFactor * easedFactor);
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Cubic:
|
||||||
|
modifiedSpeed *= easedFactor * easedFactor * easedFactor;
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Linear:
|
||||||
|
modifiedSpeed *= easedFactor;
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Quart:
|
||||||
|
modifiedSpeed *= easedFactor * easedFactor * easedFactor * easedFactor;
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Elastic:
|
||||||
|
modifiedSpeed *= Mathf.Sin(13 * easedFactor * Mathf.Pi) * Mathf.Pow(2, 10 * (easedFactor - 1));
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Back:
|
||||||
|
modifiedSpeed *= easedFactor * easedFactor * (2.70158f * easedFactor - 1.70158f);
|
||||||
|
break;
|
||||||
|
case SpeedModifierType.Bounce:
|
||||||
|
modifiedSpeed *= Mathf.Abs(Mathf.Sin(6.28f * (easedFactor + 1) * (easedFactor + 1)) * (1 - easedFactor));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Invert)
|
||||||
|
{
|
||||||
|
modifiedSpeed = baseSpeed + (baseSpeed - modifiedSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Mathf.Max(modifiedSpeed, MinimumSpeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SpeedModifierType
|
||||||
|
{
|
||||||
|
Sine,
|
||||||
|
Quad,
|
||||||
|
Exponential,
|
||||||
|
Quint,
|
||||||
|
Circ,
|
||||||
|
Cubic,
|
||||||
|
Linear,
|
||||||
|
Quart,
|
||||||
|
Elastic,
|
||||||
|
Back,
|
||||||
|
Bounce
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EasingType
|
||||||
|
{
|
||||||
|
In,
|
||||||
|
Out,
|
||||||
|
InOut
|
||||||
|
}
|
||||||
BIN
Sprites/Bullets/mid_bullet_blue.aseprite
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/mid_bullet_blue.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Sprites/Bullets/mid_bullet_blue.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/mid_bullet_blue.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Bullets/mid_bullet_blue.png.import
Normal file
34
Sprites/Bullets/mid_bullet_blue.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dooyhu8vt63vm"
|
||||||
|
path="res://.godot/imported/mid_bullet_blue.png-7dedada0d0ba94d6aea4a296c5a19e63.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/Bullets/mid_bullet_blue.png"
|
||||||
|
dest_files=["res://.godot/imported/mid_bullet_blue.png-7dedada0d0ba94d6aea4a296c5a19e63.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
|
||||||
BIN
Sprites/Bullets/mid_bullet_red.aseprite
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/mid_bullet_red.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Sprites/Bullets/mid_bullet_red.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Bullets/mid_bullet_red.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Bullets/mid_bullet_red.png.import
Normal file
34
Sprites/Bullets/mid_bullet_red.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cfldr7l7dearo"
|
||||||
|
path="res://.godot/imported/mid_bullet_red.png-5bc1e79f4456468a638cf530366492d7.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/Bullets/mid_bullet_red.png"
|
||||||
|
dest_files=["res://.godot/imported/mid_bullet_red.png-5bc1e79f4456468a638cf530366492d7.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