mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:45:33 +00:00
Added offsets and remade modifiers system
This commit is contained in:
parent
881a4897da
commit
aab69fb609
16 changed files with 474 additions and 426 deletions
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=167 format=4 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=166 format=4 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"]
|
||||
|
|
@ -79,7 +79,6 @@
|
|||
[ext_resource type="Resource" uid="uid://btk4kojtepwv" path="res://Resources/Items/IceShotgun_Sawed_T1.tres" id="57_jm0wb"]
|
||||
[ext_resource type="Resource" uid="uid://ckfqrq8a0uj1t" path="res://Resources/Items/LaserWeapon.tres" id="57_uh0gg"]
|
||||
[ext_resource type="Resource" uid="uid://c57od7cpn5kwf" path="res://Resources/Items/IceShotgun_Sawed_T2.tres" id="58_dfo5i"]
|
||||
[ext_resource type="Script" uid="uid://b5fesrd4lv8t1" path="res://Scripts/Resources/Events/EventResource.cs" id="61_ldb17"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjskkeb3ppcs8" path="res://Scenes/Actors/Turret360.tscn" id="62_h0jm4"]
|
||||
[ext_resource type="Script" uid="uid://v57xjmhi28kw" path="res://Scripts/Resources/Events/ControlActorEvent.cs" id="64_rphi8"]
|
||||
[ext_resource type="PackedScene" uid="uid://b0gpbkxdfbnjh" path="res://Scenes/Actors/ForceField_Horizontal.tscn" id="66_nxn3h"]
|
||||
|
|
@ -298,7 +297,7 @@ ActivationType = 0
|
|||
Targets = Array[NodePath]([NodePath("../Rumia")])
|
||||
WaitForCompletion = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ldb17"]
|
||||
[sub_resource type="Resource" id="Resource_r7hyp"]
|
||||
resource_local_to_scene = true
|
||||
script = ExtResource("49_0si7g")
|
||||
Target = NodePath(".")
|
||||
|
|
@ -838,7 +837,7 @@ position = Vector2(-1210, -370)
|
|||
[node name="LaserTutorial" parent="Parallax2D/Factory Tilemaps/Part2" instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-1488, -298)
|
||||
scale = Vector2(1.455, 1.455)
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_uh0gg")])
|
||||
Events = [SubResource("Resource_uh0gg")]
|
||||
|
||||
[node name="LevelProps" type="Node2D" parent="Parallax2D/Factory Tilemaps"]
|
||||
y_sort_enabled = true
|
||||
|
|
@ -929,7 +928,7 @@ Invisible = true
|
|||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="ScriptableAreaTrigger" parent="Parallax2D/Factory Tilemaps/LevelProps/DebugTeleporter" instance=ExtResource("43_kf3qc")]
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_usuub")])
|
||||
Events = [SubResource("Resource_usuub")]
|
||||
|
||||
[node name="BlueKeycard2" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("35_rblsn")]
|
||||
position = Vector2(-1032, -317)
|
||||
|
|
@ -1125,7 +1124,7 @@ position = Vector2(-1423, -188)
|
|||
[node name="LevelStartTrigger" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-762, -129)
|
||||
scale = Vector2(1.455, 1.455)
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_5er5x"), SubResource("Resource_b25hy")])
|
||||
Events = [SubResource("Resource_5er5x"), SubResource("Resource_b25hy")]
|
||||
|
||||
[node name="AreaTrigger2" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Target") instance=ExtResource("28_6au4t")]
|
||||
position = Vector2(-435, -162)
|
||||
|
|
@ -1168,7 +1167,7 @@ metadata/_edit_group_ = true
|
|||
[node name="Script2" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer2"]
|
||||
position = Vector2(120, 25)
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_wma5c")])
|
||||
Events = [SubResource("Resource_wma5c")]
|
||||
|
||||
[node name="Computer8" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("31_243ec")]
|
||||
position = Vector2(-2073, -215)
|
||||
|
|
@ -1179,7 +1178,7 @@ metadata/_edit_group_ = true
|
|||
[node name="Script2" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer8"]
|
||||
position = Vector2(120, 25)
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_dferh")])
|
||||
Events = [SubResource("Resource_dferh")]
|
||||
|
||||
[node name="Computer6" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("31_243ec")]
|
||||
position = Vector2(-1113, -139)
|
||||
|
|
@ -1189,7 +1188,7 @@ metadata/_edit_group_ = true
|
|||
[node name="Script2" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer6"]
|
||||
position = Vector2(0, 1)
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_cxj4w")])
|
||||
Events = [SubResource("Resource_cxj4w")]
|
||||
|
||||
[node name="Computer7" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("31_243ec")]
|
||||
position = Vector2(-1175.36, 213.708)
|
||||
|
|
@ -1200,7 +1199,7 @@ metadata/_edit_group_ = true
|
|||
[node name="Computer7Script" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer7"]
|
||||
position = Vector2(0, 1)
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_tcc7d")])
|
||||
Events = [SubResource("Resource_tcc7d")]
|
||||
|
||||
[node name="Computer5" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("31_243ec")]
|
||||
position = Vector2(-1344, -251)
|
||||
|
|
@ -1208,7 +1207,7 @@ Targets = [NodePath("Computer5Script")]
|
|||
|
||||
[node name="Computer5Script" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer5"]
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_fasrq"), SubResource("Resource_mah4x"), SubResource("Resource_0bqta")])
|
||||
Events = [SubResource("Resource_fasrq"), SubResource("Resource_mah4x"), SubResource("Resource_0bqta")]
|
||||
|
||||
[node name="Computer3" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Target") instance=ExtResource("31_243ec")]
|
||||
position = Vector2(-612.57, -358.528)
|
||||
|
|
@ -1216,7 +1215,7 @@ Target = NodePath("Script")
|
|||
|
||||
[node name="Script" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer3"]
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_o2kpk")])
|
||||
Events = [SubResource("Resource_o2kpk")]
|
||||
|
||||
[node name="Computer4" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Target") instance=ExtResource("31_243ec")]
|
||||
position = Vector2(-791, -505)
|
||||
|
|
@ -1224,7 +1223,7 @@ Target = NodePath("Node2D")
|
|||
|
||||
[node name="Node2D" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer4"]
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_s3g2w")])
|
||||
Events = [SubResource("Resource_s3g2w")]
|
||||
|
||||
[node name="Label" type="Label" parent="Parallax2D/Factory Tilemaps/LevelProps/Computer4"]
|
||||
offset_left = -5.0
|
||||
|
|
@ -1241,11 +1240,11 @@ EnemyData = ExtResource("71_xhinl")
|
|||
[node name="BossBattleEndScript" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps"]
|
||||
position = Vector2(-1628.53, -477.628)
|
||||
script = ExtResource("42_wigyb")
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_068l7"), SubResource("Resource_l3nop")])
|
||||
Events = [SubResource("Resource_068l7"), SubResource("Resource_l3nop")]
|
||||
|
||||
[node name="BossBattleStartScript" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-1487, -396)
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_4f4id"), SubResource("Resource_s2o7m"), SubResource("Resource_b1dht"), SubResource("Resource_xrgpy"), SubResource("Resource_ldb17")])
|
||||
Events = [SubResource("Resource_4f4id"), SubResource("Resource_s2o7m"), SubResource("Resource_b1dht"), SubResource("Resource_xrgpy"), SubResource("Resource_r7hyp")]
|
||||
|
||||
[node name="Enemy13" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("47_u1ve6")]
|
||||
position = Vector2(-1657, -788)
|
||||
|
|
@ -1558,7 +1557,7 @@ position = Vector2(-2232, -203)
|
|||
|
||||
[node name="ScriptableAreaTrigger" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-2063, -232)
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_l476f"), SubResource("Resource_dskij")])
|
||||
Events = [SubResource("Resource_l476f"), SubResource("Resource_dskij")]
|
||||
|
||||
[node name="ShieldExtendPickup" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("103_0bqta")]
|
||||
position = Vector2(-1646, 38)
|
||||
|
|
@ -1686,7 +1685,7 @@ position = Vector2(-1633, 391)
|
|||
|
||||
[node name="MovementSensorLonger" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("112_j86ly")]
|
||||
position = Vector2(-1495, 516)
|
||||
Events = Array[ExtResource("61_ldb17")]([SubResource("Resource_uslvo")])
|
||||
Events = [SubResource("Resource_uslvo")]
|
||||
|
||||
[node name="WallEmitter" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("113_dferh")]
|
||||
position = Vector2(-1480, 451)
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.AttackPatterns;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PatternTest : AttackPattern
|
||||
{
|
||||
[Export] public PackedScene BulletScene;
|
||||
[Export] public float bulletSpeed = 5f;
|
||||
[Export] public int bulletCount = 12;
|
||||
[Export] public float duration = 3f;
|
||||
[Export] public float burstInterval = 0.5f;
|
||||
[Export] public BulletOwner owner = BulletOwner.Enemy;
|
||||
|
||||
public override IPatternMachine MakeMachine(Node2D parent)
|
||||
{
|
||||
return new PatternTestMachine(this, parent);
|
||||
}
|
||||
|
||||
public class PatternTestMachine(PatternTest pattern, Node2D parent) : IPatternMachine
|
||||
{
|
||||
public Node2D Parent => parent;
|
||||
private double timer;
|
||||
private double burstTimer;
|
||||
private BulletSpawner spawner;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
timer = 0;
|
||||
burstTimer = 0;
|
||||
spawner = Parent.GetNode<BulletSpawner>("BulletSpawner");
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta)
|
||||
{
|
||||
timer += delta;
|
||||
burstTimer += delta;
|
||||
if (timer < pattern.duration && burstTimer >= pattern.burstInterval)
|
||||
{
|
||||
spawner.SpawnBullet(Parent.GlobalPosition, Vector2.Right, pattern.bulletSpeed, pattern.owner, pattern.bulletCount, bulletScene: pattern.BulletScene);
|
||||
burstTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return timer >= pattern.duration;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://bay71pcaj4nj2
|
||||
|
|
@ -16,6 +16,8 @@ public partial class SpiralPattern : AttackPattern
|
|||
{
|
||||
[Export] public BulletResource BulletResource { get; set; }
|
||||
|
||||
[Export] public Vector2 EmitterOffset { get; set; } = Vector2.Zero;
|
||||
|
||||
//Export] public PackedScene BulletScene;
|
||||
//[Export] private float _bulletLifeTime = 20f; // Switch to res
|
||||
//[Export] private bool _destroyOnCollision = false; // Switch to res
|
||||
|
|
@ -242,7 +244,7 @@ public partial class SpiralPattern : AttackPattern
|
|||
}
|
||||
}
|
||||
|
||||
var bullet = pattern.MakeBullet(Parent.GlobalPosition, pattern.bulletCount,
|
||||
var bullet = pattern.MakeBullet(Parent.GlobalPosition + pattern.EmitterOffset, pattern.bulletCount,
|
||||
pattern.spread, angleOffset);
|
||||
|
||||
bullet.Direction = direction;
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
namespace Cirno.Scripts.AttackPatterns;
|
||||
|
||||
using Godot;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class TargetedPattern : AttackPattern
|
||||
{
|
||||
[Export] public PackedScene BulletScene;
|
||||
|
||||
[Export] private float bulletSpeed = 5f;
|
||||
[Export] private float duration = 3f;
|
||||
[Export] private float burstInterval = 0.5f;
|
||||
[Export] private int bulletsPerShot = 1;
|
||||
[Export] private float spread = 0f;
|
||||
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
||||
[Export] private BulletCreationModifier modifier;
|
||||
|
||||
public override IPatternMachine MakeMachine(Node2D parent)
|
||||
{
|
||||
return new TargetedPatternMachine(this, parent);
|
||||
}
|
||||
|
||||
public class TargetedPatternMachine(TargetedPattern pattern, Node2D parent) : IPatternMachine
|
||||
{
|
||||
public Node2D Parent => parent;
|
||||
|
||||
private double timer;
|
||||
private double burstTimer;
|
||||
private BulletSpawner spawner;
|
||||
//private Node2D player;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
timer = 0;
|
||||
burstTimer = 0;
|
||||
spawner = Parent.GetNode<BulletSpawner>("BulletSpawner");
|
||||
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta)
|
||||
{
|
||||
timer += delta;
|
||||
burstTimer += delta;
|
||||
if (timer < pattern.duration && burstTimer >= pattern.burstInterval && GameManager.Instance.PlayerPosition.HasValue)
|
||||
{
|
||||
spawner.SpawnTargetedBullet(Parent.GlobalPosition, GameManager.Instance.PlayerPosition.Value, pattern.bulletSpeed, pattern.owner, pattern.BulletScene, pattern.bulletsPerShot, pattern.spread, pattern.modifier);
|
||||
burstTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return timer >= pattern.duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://by0fm3opaexcs
|
||||
|
|
@ -51,6 +51,8 @@ public partial class Bullet : Area2D
|
|||
|
||||
_elapsedTime = 0f;
|
||||
|
||||
this.Speed = bulletInfo.Speed;
|
||||
|
||||
// Need to clone them here
|
||||
// _modifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone()).ToList();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,15 @@ public partial class BulletSpawner : Node2D
|
|||
|
||||
// var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, bulletInfo.BulletScene ?? BulletScene, bulletInfo.Position);
|
||||
|
||||
if (bulletInfo.Modifier is not null)
|
||||
{
|
||||
bulletInfo = bulletInfo.Modifier.ModifyBullet(bulletInfo, i, bulletInfo.BulletCount);
|
||||
}
|
||||
|
||||
bullet.Initialize(bulletInfo, _gameManager);
|
||||
|
||||
float modifiedSpeed = bulletInfo.Modifier?.ModifySpeed(bulletInfo.Speed, i, bulletInfo.BulletCount) ?? bulletInfo.Speed;
|
||||
bullet.Speed = modifiedSpeed;
|
||||
// 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);
|
||||
|
|
@ -50,40 +55,46 @@ public partial class BulletSpawner : Node2D
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, bulletScene ?? BulletScene, position);
|
||||
// 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)
|
||||
// {
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, bulletScene ?? BulletScene, position);
|
||||
//
|
||||
// //var bullet = BulletScene.Instantiate<Bullet>();
|
||||
// bullet.Position = position;
|
||||
// //bullet.Speed = speed;
|
||||
//
|
||||
// if (modifier is not null)
|
||||
// {
|
||||
// bullet.BulletInfo = modifier.ModifyBullet(bullet.BulletInfo, i, count);
|
||||
// }
|
||||
//
|
||||
// //float modifiedSpeed = modifier?.ModifySpeed(speed, i, count) ?? speed;
|
||||
// //bullet.Speed = modifiedSpeed;
|
||||
//
|
||||
// Vector2 baseDirection = direction == Vector2.Zero ? Vector2.Right : direction.Normalized();
|
||||
// float baseAngle = Mathf.Atan2(baseDirection.Y, baseDirection.X);
|
||||
// //float angle = angleOffset + (360 / count) * i;
|
||||
// float angle = baseAngle + Mathf.DegToRad(angleOffset + (spread / count) * 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
//var bullet = BulletScene.Instantiate<Bullet>();
|
||||
bullet.Position = position;
|
||||
//bullet.Speed = speed;
|
||||
|
||||
float modifiedSpeed = modifier?.ModifySpeed(speed, i, count) ?? speed;
|
||||
bullet.Speed = modifiedSpeed;
|
||||
|
||||
Vector2 baseDirection = direction == Vector2.Zero ? Vector2.Right : direction.Normalized();
|
||||
float baseAngle = Mathf.Atan2(baseDirection.Y, baseDirection.X);
|
||||
//float angle = angleOffset + (360 / count) * i;
|
||||
float angle = baseAngle + Mathf.DegToRad(angleOffset + (spread / count) * 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 SpawnTargetedBullet(Vector2 position, Vector2 target, float speed, BulletOwner owner, PackedScene bulletScene = null, int burstCount = 1, float spread = 0, IBulletModifier modifier = null)
|
||||
{
|
||||
Vector2 direction = (target - position).Normalized();
|
||||
SpawnBullet(position, direction, speed, owner, burstCount, spread: spread, bulletScene: bulletScene, modifier: modifier);
|
||||
}
|
||||
// public void SpawnTargetedBullet(Vector2 position, Vector2 target, float speed, BulletOwner owner, PackedScene bulletScene = null, int burstCount = 1, float spread = 0, IBulletModifier modifier = null)
|
||||
// {
|
||||
// Vector2 direction = (target - position).Normalized();
|
||||
// SpawnBullet(position, direction, speed, owner, burstCount, spread: spread, bulletScene: bulletScene, modifier: modifier);
|
||||
// }
|
||||
}
|
||||
|
||||
public class BulletInfo
|
||||
public class BulletInfo(BulletResource originalBulletResource)
|
||||
{
|
||||
public BulletResource OriginalBulletResource { get; set; } = originalBulletResource;
|
||||
public Vector2 Position { get; set; }
|
||||
public Vector2 Direction { get; set; }
|
||||
public float Speed { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Components;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
|
|
@ -6,5 +7,6 @@ namespace Cirno.Scripts.Resources;
|
|||
[Tool]
|
||||
public abstract partial class BulletCreationModifier : Resource, IBulletModifier
|
||||
{
|
||||
public abstract float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets);
|
||||
public abstract BulletInfo ModifyBullet(BulletInfo bullet, int bulletIndex, int totalBullets);
|
||||
//public abstract float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets);
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ public partial class BulletResource : Resource
|
|||
|
||||
public BulletInfo MakeBullet(Vector2 position, int count = 1, float spread = 0f, float rotationOffset = 0f)
|
||||
{
|
||||
return new BulletInfo()
|
||||
return new BulletInfo(this)
|
||||
{
|
||||
Position = position,
|
||||
Direction = Direction,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Components;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
|
|
@ -8,7 +9,13 @@ public partial class DecreasingSpeedModifier : BulletCreationModifier, IBulletMo
|
|||
{
|
||||
[Export] private float decreaseRate = 0.1f;
|
||||
|
||||
public override float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
public override BulletInfo ModifyBullet(BulletInfo bullet, int bulletIndex, int totalBullets)
|
||||
{
|
||||
bullet.Speed = ModifySpeed(bullet.OriginalBulletResource.BulletSpeed, bulletIndex, totalBullets);
|
||||
return bullet;
|
||||
}
|
||||
|
||||
public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
{
|
||||
return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Components;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
public interface IBulletModifier
|
||||
{
|
||||
float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets);
|
||||
BulletInfo ModifyBullet(BulletInfo bullet, int bulletIndex, int totalBullets);
|
||||
//float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets);
|
||||
}
|
||||
56
Scripts/Resources/ScriptableBullets/ParallelPatternGroup.cs
Normal file
56
Scripts/Resources/ScriptableBullets/ParallelPatternGroup.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using System.Collections.Generic;
|
||||
using Cirno.Scripts.AttackPatterns;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Resources.ScriptableBullets;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ParallelPatternGroup : AttackPattern
|
||||
{
|
||||
[Export(PropertyHint.None, "suffix:s")] public float Duration { get; private set; } = 10f;
|
||||
[Export] public Array<AttackPattern> Patterns { get; private set; } = [];
|
||||
|
||||
public override IPatternMachine MakeMachine(Node2D parent)
|
||||
{
|
||||
return new ParallelPatternGroupMachine(this, parent);
|
||||
}
|
||||
|
||||
public class ParallelPatternGroupMachine(ParallelPatternGroup patternGroup, Node2D parent) : IPatternMachine
|
||||
{
|
||||
public Node2D Parent => parent;
|
||||
//private int _currentPatternIndex = 0;
|
||||
|
||||
//private AttackPattern CurrentPattern => patternGroup.Patterns[_currentPatternIndex];
|
||||
|
||||
private List<IPatternMachine> _patternMachines = [];
|
||||
|
||||
public void Start()
|
||||
{
|
||||
//_currentPatternIndex = 0;
|
||||
foreach (var pattern in patternGroup.Patterns)
|
||||
{
|
||||
var machine = pattern.MakeMachine(parent);
|
||||
_patternMachines.Add(machine);
|
||||
machine.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta)
|
||||
{
|
||||
foreach (var patternMachine in _patternMachines)
|
||||
{
|
||||
//if (!CurrentPattern.WaitForCompletion || _patternMachine.IsComplete())
|
||||
if ( patternMachine.IsComplete()) continue;
|
||||
patternMachine.UpdatePattern(delta);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return _patternMachines.TrueForAll(x => x.IsComplete());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://rqtkxuqmo7gi
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Components;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
|
|
@ -12,7 +13,13 @@ public partial class SpeedModifier : BulletCreationModifier, IBulletModifier
|
|||
[Export] public float MinimumSpeed = 10f;
|
||||
[Export] public float ScalingFactor = 10.0f;
|
||||
|
||||
public override float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
public override BulletInfo ModifyBullet(BulletInfo bullet, int bulletIndex, int totalBullets)
|
||||
{
|
||||
bullet.Speed = ModifySpeed(bullet.OriginalBulletResource.BulletSpeed, bulletIndex, totalBullets);
|
||||
return bullet;
|
||||
}
|
||||
|
||||
public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
{
|
||||
if (totalBullets <= 1)
|
||||
return baseSpeed;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue