Danmaku system

This commit is contained in:
Marco 2025-02-05 19:41:49 +01:00
commit fdec052c16
38 changed files with 924 additions and 9 deletions

View file

@ -1,5 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArray_00601_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FDecompilerCache_003Fdecompiler_003F4fd22cd129a84c16b5d8004b467c426f518800_003F67_003F90d26b57_003FArray_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACanvasItem_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fe43c43ee5cdcf2c7c8ddb9366f75a76a3c61c77bf45ceac78721c269f3c360_003FCanvasItem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACastHelpers_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F3c92637ae2e83da0a63791071c41eae291d594156062866d8621b7ed7245c_003FCastHelpers_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEnemy_005FScriptProperties_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fd6739058209280d46591ab296d6b49dfcf7ecd2_003FEnemy_005FScriptProperties_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fbb1b701f3c7411227a9d2e09f965d857ff3e771557650c4f513e427d77c_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AVariantUtils_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FDecompilerCache_003Fdecompiler_003F4fd22cd129a84c16b5d8004b467c426f518800_003F38_003Fb04c4423_003FVariantUtils_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

View file

@ -0,0 +1,43 @@
[gd_resource type="Resource" script_class="BossPhase" load_steps=9 format=3 uid="uid://ks6fypeil6gk"]
[ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="1_0cgch"]
[ext_resource type="Script" path="res://Scripts/Resources/SimpleMovementPattern.cs" id="1_xksf5"]
[ext_resource type="Resource" uid="uid://csudslb5tliw4" path="res://Resources/Patterns/rumia_ns_1.tres" id="2_3486e"]
[ext_resource type="Resource" uid="uid://du2kuv125vbrx" path="res://Resources/Patterns/rumia_ns_2.tres" id="3_mwcf3"]
[sub_resource type="Resource" id="Resource_acaax"]
script = ExtResource("1_xksf5")
relativeTargetPosition = Vector2(-100, 20)
moveDuration = 4.0
transitionType = 1
easeType = 2
WaitForCompletion = false
[sub_resource type="Resource" id="Resource_o8win"]
script = ExtResource("1_xksf5")
relativeTargetPosition = Vector2(0, 0)
moveDuration = 4.0
transitionType = 1
easeType = 2
WaitForCompletion = false
[sub_resource type="Resource" id="Resource_k77ig"]
script = ExtResource("1_xksf5")
relativeTargetPosition = Vector2(-100, 20)
moveDuration = 4.0
transitionType = 1
easeType = 2
WaitForCompletion = false
[sub_resource type="Resource" id="Resource_5ocg5"]
script = ExtResource("1_xksf5")
relativeTargetPosition = Vector2(0, 0)
moveDuration = 4.0
transitionType = 1
easeType = 2
WaitForCompletion = false
[resource]
script = ExtResource("1_0cgch")
Threshold = 20
Patterns = Array[Resource]([SubResource("Resource_acaax"), ExtResource("2_3486e"), ExtResource("3_mwcf3"), SubResource("Resource_o8win"), ExtResource("2_3486e"), ExtResource("3_mwcf3"), SubResource("Resource_k77ig"), ExtResource("2_3486e"), ExtResource("3_mwcf3"), SubResource("Resource_5ocg5"), ExtResource("2_3486e"), ExtResource("3_mwcf3")])

View file

@ -0,0 +1,21 @@
[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="Script" path="res://Scripts/Resources/DecreasingSpeedModifier.cs" id="2_wxqq0"]
[ext_resource type="Script" path="res://Scripts/AttackPatterns/TargetedPattern.cs" id="3_ht3k1"]
[sub_resource type="Resource" id="Resource_jeq72"]
script = ExtResource("2_wxqq0")
decreaseRate = 4.0
[resource]
script = ExtResource("3_ht3k1")
BulletScene = ExtResource("1_pocps")
bulletSpeed = 50.0
duration = 4.0
burstInterval = 0.4
bulletsPerShot = 10
spread = 0.0
owner = 2
modifier = SubResource("Resource_jeq72")
WaitForCompletion = true

View file

@ -0,0 +1,47 @@
[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="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="Script" path="res://Scripts/Resources/PatternGroup.cs" id="3_jvysx"]
[sub_resource type="Resource" id="Resource_ne4q3"]
script = ExtResource("2_ee42k")
BulletScene = ExtResource("1_tt36x")
bulletSpeed = 20.0
bulletCount = 10
rotationSpeed = 120.0
duration = 4.0
burstInterval = 2.0
spread = 360.0
owner = 2
WaitForCompletion = true
[sub_resource type="Resource" id="Resource_kohuh"]
script = ExtResource("2_ee42k")
BulletScene = ExtResource("3_gr7a3")
bulletSpeed = 20.0
bulletCount = 16
rotationSpeed = 120.0
duration = 4.0
burstInterval = 2.0
spread = 360.0
owner = 2
WaitForCompletion = true
[sub_resource type="Resource" id="Resource_depjj"]
script = ExtResource("2_ee42k")
BulletScene = ExtResource("1_tt36x")
bulletSpeed = 30.0
bulletCount = 10
rotationSpeed = 120.0
duration = 4.0
burstInterval = 2.0
spread = 360.0
owner = 2
WaitForCompletion = true
[resource]
script = ExtResource("3_jvysx")
patterns = Array[Resource]([SubResource("Resource_ne4q3"), SubResource("Resource_kohuh"), SubResource("Resource_depjj")])
WaitForCompletion = true

85
Scenes/Actors/Rumia.tscn Normal file
View file

@ -0,0 +1,85 @@
[gd_scene load_steps=12 format=3 uid="uid://d1rlw6ddpmrn8"]
[ext_resource type="Script" path="res://Scripts/Actors/Boss.cs" id="1_na4uq"]
[ext_resource type="Resource" uid="uid://ks6fypeil6gk" path="res://Resources/BossPhases/TestBoss1.tres" id="2_1rhf6"]
[ext_resource type="Texture2D" uid="uid://bcqgke6dthlrj" path="res://Sprites/Actors/Rumia.png" id="2_7k5gp"]
[ext_resource type="Script" path="res://Scripts/Components/ProximityPlayerDetection.cs" id="3_gka5j"]
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="4_xc6nm"]
[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="5_g1p0m"]
[ext_resource type="Script" path="res://Scripts/Components/BulletSpawner.cs" id="7_2obh7"]
[sub_resource type="CircleShape2D" id="CircleShape2D_8gtts"]
radius = 7.0
[sub_resource type="CircleShape2D" id="CircleShape2D_cacb5"]
radius = 4.0
[sub_resource type="CircleShape2D" id="CircleShape2D_v711r"]
radius = 85.0529
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m1rsg"]
size = Vector2(8, 12)
[node name="Rumia" type="CharacterBody2D" groups=["Destroyable"]]
collision_layer = 16
collision_mask = 9
script = ExtResource("1_na4uq")
Phases = Array[Resource]([ExtResource("2_1rhf6")])
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_7k5gp")
[node name="Damage_HitBox" type="CollisionShape2D" parent="."]
visible = false
shape = SubResource("CircleShape2D_8gtts")
[node name="RigidBody2D" type="RigidBody2D" parent="."]
collision_layer = 16
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
visible = false
position = Vector2(0, 5)
shape = SubResource("CircleShape2D_cacb5")
[node name="PlayerDetection" type="Area2D" parent="."]
visible = false
collision_layer = 16
collision_mask = 2
script = ExtResource("3_gka5j")
[node name="PlayerDetectionArea" type="CollisionShape2D" parent="PlayerDetection"]
shape = SubResource("CircleShape2D_v711r")
[node name="ShootTimer" type="Timer" parent="."]
wait_time = 0.4
one_shot = true
[node name="Weapon" parent="." instance=ExtResource("4_xc6nm")]
BulletScene = ExtResource("5_g1p0m")
BulletCapacity = 4
BulletSpeed = 50.0
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
target_desired_distance = 64.0
path_max_distance = 800.0
path_postprocessing = 1
avoidance_enabled = true
debug_enabled = true
debug_path_custom_color = Color(1, 0, 0, 1)
[node name="DamageHitbox" type="Area2D" parent="."]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageHitbox"]
shape = SubResource("RectangleShape2D_m1rsg")
[node name="BulletSpawner" type="Node2D" parent="."]
script = ExtResource("7_2obh7")
BulletScene = ExtResource("5_g1p0m")
[connection signal="area_entered" from="PlayerDetection" to="PlayerDetection" method="_on_area_entered"]
[connection signal="area_exited" from="PlayerDetection" to="." method="_on_area_exited"]
[connection signal="velocity_computed" from="NavigationAgent2D" to="." method="_on_navigation_agent_2d_velocity_computed"]
[connection signal="area_entered" from="DamageHitbox" to="." method="_on_damage_hitbox_area_entered"]

View file

@ -1,6 +1,17 @@
[gd_scene load_steps=2 format=3 uid="uid://bu5fvatj2j08j"]
[gd_scene load_steps=4 format=3 uid="uid://bu5fvatj2j08j"]
[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://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_f17ts"]
[node name="BossTestArena" type="Node2D"]
[node name="GameScene" type="Node2D" node_paths=PackedStringArray("PlayerSpawnMarker")]
script = ExtResource("1_paetl")
PlayerTemplate = ExtResource("2_f17ts")
PlayerSpawnMarker = NodePath("PlayerStartPosition")
[node name="Rumia" parent="." instance=ExtResource("2_47q21")]
position = Vector2(163, 37)
Health = 40.0
[node name="PlayerStartPosition" type="Marker2D" parent="."]
position = Vector2(178, 115)

View file

@ -0,0 +1,30 @@
[gd_scene load_steps=4 format=3 uid="uid://dohakkayqj4w2"]
[ext_resource type="Script" path="res://Scripts/Bullet.cs" id="1_vg1kg"]
[ext_resource type="Texture2D" uid="uid://dmwi86k7hr8sl" path="res://Sprites/Bullets/small_bullet_green.png" id="2_divgu"]
[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_vg1kg")
Speed = 200.0
Owner = 2
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_divgu")
[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"]

View file

@ -0,0 +1,30 @@
[gd_scene load_steps=4 format=3 uid="uid://b0clsnefjsohc"]
[ext_resource type="Script" path="res://Scripts/Bullet.cs" id="1_w5w28"]
[ext_resource type="Texture2D" uid="uid://c4ijhpgbwmbr8" path="res://Sprites/Bullets/mid_bullet.png" id="2_5gscp"]
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
radius = 4.0
[node name="Bullet" type="Area2D" groups=["bullets"]]
collision_layer = 128
collision_mask = 71
script = ExtResource("1_w5w28")
Speed = 200.0
Owner = 2
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_5gscp")
[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"]

View file

@ -0,0 +1,27 @@
[gd_scene load_steps=4 format=3 uid="uid://by2rk6gx67f7e"]
[ext_resource type="Script" path="res://Scripts/Bullet.cs" id="1_hd5v3"]
[ext_resource type="Texture2D" uid="uid://s5argltaljmq" path="res://Sprites/Bullets/small_bullet_yellow.png" id="2_c3vqu"]
[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_hd5v3")
Speed = 200.0
Owner = 2
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_c3vqu")
[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"]

54
Scripts/Actors/Boss.cs Normal file
View file

@ -0,0 +1,54 @@
using Cirno.Scripts.Resources;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Actors;
public partial class Boss : Enemy
{
[Export] private Array<BossPhase> Phases;
private int currentPhaseIndex = 0;
private GameManager _gameManager;
private Vector2 _homePosition;
public Vector2 HomePosition => _homePosition;
public GameManager GameManager => _gameManager;
private BossPhase CurrentPhase => Phases[currentPhaseIndex];
public override void _Ready()
{
base._Ready();
_gameManager = GetNode<GameManager>("/root/GameScene");
_homePosition = this.GlobalPosition;
StartPhase(CurrentPhase);
}
public override void _Process(double delta)
{
base._Process(delta);
CurrentPhase.UpdatePhase(delta);
if (_currentHealth <= CurrentPhase.Threshold && currentPhaseIndex + 1 < Phases.Count)
{
currentPhaseIndex++;
StartPhase(CurrentPhase);
}
}
private void StartPhase(BossPhase phase)
{
phase.Start(this);
}
public void TakeDamage(int amount)
{
_currentHealth -= amount;
}
}

View file

@ -0,0 +1,54 @@
using Cirno.Scripts.Actors;
using Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.AttackPatterns;
[GlobalClass]
public partial class MovementPattern : AttackPattern
{
[Export] private Vector2 relativeTargetPosition;
[Export] private float moveDuration = 2f;
[Export] private Tween.TransitionType transitionType = Tween.TransitionType.Linear;
[Export] private Tween.EaseType easeType = Tween.EaseType.InOut;
[Export] private AttackPattern shootingPattern;
private Tween tween;
private bool isComplete = false;
public override void Start(Boss boss)
{
Boss = boss;
tween = boss.CreateTween();
isComplete = false;
Vector2 targetPosition = (Boss?.HomePosition ?? boss.GlobalPosition) + this.relativeTargetPosition;
tween.TweenProperty(Boss, "position", targetPosition, moveDuration)
.SetTrans(transitionType)
.SetEase(easeType)
.Finished += () => isComplete = true;
if (shootingPattern != null && !WaitForCompletion)
{
shootingPattern.Start(boss);
}
}
public override void UpdatePattern(double delta)
{
if (shootingPattern != null && !WaitForCompletion)
{
shootingPattern.UpdatePattern(delta);
}
}
public override bool IsComplete()
{
if (WaitForCompletion && shootingPattern != null)
return isComplete && shootingPattern.IsComplete();
return isComplete;
}
}

View file

@ -0,0 +1,45 @@
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] private float bulletSpeed = 5f;
[Export] private int bulletCount = 12;
[Export] private float duration = 3f;
[Export] private float burstInterval = 0.5f;
[Export] private BulletOwner owner = BulletOwner.Enemy;
private double timer;
private double burstTimer;
private BulletSpawner spawner;
public override void Start(Boss boss)
{
Boss = boss;
timer = 0;
burstTimer = 0;
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
}
public override void UpdatePattern(double delta)
{
timer += delta;
burstTimer += delta;
if (timer < duration && burstTimer >= burstInterval)
{
spawner.SpawnBullet(Boss.GlobalPosition, Vector2.Right, bulletSpeed, owner, bulletCount, bulletScene: BulletScene);
burstTimer = 0;
}
}
public override bool IsComplete()
{
return timer >= duration;
}
}

View file

@ -0,0 +1,47 @@
using Cirno.Scripts.Actors;
using Cirno.Scripts.Components;
using Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.AttackPatterns;
[GlobalClass]
public partial class SpiralPattern : AttackPattern
{
[Export] public PackedScene BulletScene;
[Export] private float bulletSpeed = 5f;
[Export] private int bulletCount = 16;
[Export] private float rotationSpeed = 90f;
[Export] private float duration = 5f;
[Export] private float burstInterval = 0.5f;
[Export] private float spread = 360f;
[Export] private BulletOwner owner = BulletOwner.Enemy;
private double timer;
private double burstTimer;
private BulletSpawner spawner;
public override void Start(Boss boss)
{
Boss = boss;
timer = 0;
burstTimer = burstInterval; // start immediately
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
}
public override void UpdatePattern(double delta)
{
timer += delta;
burstTimer += delta;
if (timer < duration && burstTimer >= burstInterval)
{
spawner.SpawnSpiralPattern(Boss.GlobalPosition, bulletSpeed, owner, bulletCount, rotationSpeed, timer, spread, BulletScene);
burstTimer = 0;
}
}
public override bool IsComplete()
{
return timer >= duration;
}
}

View file

@ -0,0 +1,54 @@
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 Resource modifier;
private double timer;
private double burstTimer;
private BulletSpawner spawner;
//private Node2D player;
private GameManager _gameManager;
public override void Start(Boss boss)
{
_gameManager = boss.GetNode<GameManager>("/root/GameScene");
Boss = boss;
timer = 0;
burstTimer = 0;
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
}
public override void UpdatePattern(double delta)
{
timer += delta;
burstTimer += delta;
if (timer < duration && burstTimer >= burstInterval && _gameManager.PlayerPosition.HasValue)
{
spawner.SpawnTargetedBullet(Boss.GlobalPosition, _gameManager.PlayerPosition.Value, bulletSpeed, owner, BulletScene, bulletsPerShot, spread, modifier as IBulletModifier);
burstTimer = 0;
}
}
public override bool IsComplete()
{
return timer >= duration;
}
}

View file

@ -42,7 +42,6 @@ public partial class Bullet : Area2D
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{

View file

@ -0,0 +1,53 @@
using Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.Components;
public partial class BulletSpawner : Node2D
{
[Export] public PackedScene BulletScene;
private GameManager _gameManager;
public override void _Ready()
{
_gameManager = GetNode<GameManager>("/root/GameScene");
}
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.Owner = owner;
//bullet.Speed = speed;
float modifiedSpeed = modifier?.ModifySpeed(speed, i) ?? 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 SpawnSpiralPattern(Vector2 position, float speed, BulletOwner owner, int bulletCount, float rotationSpeed, double time, float spread, PackedScene bulletScene = null)
{
float angleOffset = (float)(rotationSpeed * time);
SpawnBullet(position, Vector2.Right, speed, owner, bulletCount, angleOffset, spread, bulletScene: bulletScene);
}
}

View file

@ -8,6 +8,12 @@ using Godot.Collections;
public partial class Enemy : CharacterBody2D
{
private InteractionController _cachedPlayer;
public InteractionController CachedPlayer
{
get => _cachedPlayer;
protected set => _cachedPlayer = value;
}
private EnemyState _currentState = EnemyState.Idle;
[Export] public float Health = 4f;
@ -20,7 +26,7 @@ public partial class Enemy : CharacterBody2D
[Export] public Weapon EquippedWeapon;
private float _currentHealth = 0f;
protected float _currentHealth = 0f;
private bool _isDestroyed = false;
@ -52,10 +58,13 @@ public partial class Enemy : CharacterBody2D
_navigationAgent = GetNodeOrNull<NavigationAgent2D>("NavigationAgent2D");
_alarmManager = GetNode<AlarmManager>("/root/GameScene/AlarmManager");
_alarmManager = GetNodeOrNull<AlarmManager>("/root/GameScene/AlarmManager");
if (_alarmManager != null)
{
_alarmManager.AlarmEnabled += AlarmManagerOnAlarmEnabled;
}
}
private void AlarmManagerOnAlarmEnabled(Vector2 location)
{

View file

@ -8,8 +8,12 @@ public partial class GameManager : Node2D
private PlayerMovement _player;
public PlayerMovement Player => _player;
private Node2D _cameraTarget;
public Vector2? PlayerPosition => _player?.GlobalPosition ?? null;
[Export]
public PackedScene PlayerTemplate { get; set; }

View file

@ -0,0 +1,13 @@
using Cirno.Scripts.Actors;
using Godot;
namespace Cirno.Scripts.Resources;
public abstract partial class AttackPattern : Resource
{
public Boss Boss;
[Export] public bool WaitForCompletion = true;
public abstract void Start(Boss boss);
public abstract void UpdatePattern(double delta);
public abstract bool IsComplete();
}

View file

@ -0,0 +1,35 @@
using Cirno.Scripts.Actors;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Resources;
[GlobalClass]
public partial class BossPhase : Resource
{
[Export] public int Threshold;
[Export] public Array<AttackPattern> Patterns;
private int currentPatternIndex = 0;
private double patternTimer;
public void Start(Boss boss)
{
currentPatternIndex = 0;
Patterns[currentPatternIndex].Start(boss);
}
public void UpdatePhase(double delta)
{
patternTimer += delta;
var currentPattern = Patterns[currentPatternIndex];
currentPattern.UpdatePattern(delta);
if (!currentPattern.WaitForCompletion || currentPattern.IsComplete())
{
currentPatternIndex = (currentPatternIndex + 1) % Patterns.Count;
Patterns[currentPatternIndex].Start(currentPattern.Boss);
}
}
}

View file

@ -0,0 +1,14 @@
using Godot;
namespace Cirno.Scripts.Resources;
[GlobalClass]
public partial class DecreasingSpeedModifier : Resource, IBulletModifier
{
[Export] private float decreaseRate = 0.1f;
public float ModifySpeed(float baseSpeed, int bulletIndex)
{
return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex));
}
}

View file

@ -0,0 +1,6 @@
namespace Cirno.Scripts.Resources;
public interface IBulletModifier
{
float ModifySpeed(float baseSpeed, int bulletIndex);
}

View file

@ -0,0 +1,42 @@
using Godot;
using System.Collections.Generic;
using Cirno.Scripts.Actors;
using Godot.Collections;
namespace Cirno.Scripts.Resources;
[GlobalClass]
public partial class PatternGroup : AttackPattern
{
[Export] private Array<AttackPattern> patterns;
private int currentPatternIndex = 0;
public override void Start(Boss boss)
{
Boss = boss;
currentPatternIndex = 0;
patterns[currentPatternIndex].Start(boss);
}
public override void UpdatePattern(double delta)
{
if (currentPatternIndex < patterns.Count)
{
patterns[currentPatternIndex].UpdatePattern(delta);
if (!patterns[currentPatternIndex].WaitForCompletion || patterns[currentPatternIndex].IsComplete())
{
currentPatternIndex++;
if (currentPatternIndex < patterns.Count)
{
patterns[currentPatternIndex].Start(Boss);
}
}
}
}
public override bool IsComplete()
{
return currentPatternIndex >= patterns.Count;
}
}

View file

@ -0,0 +1,37 @@
using Cirno.Scripts.Actors;
using Godot;
namespace Cirno.Scripts.Resources;
[GlobalClass]
public partial class SimpleMovementPattern : AttackPattern
{
[Export] private Vector2 relativeTargetPosition;
[Export] private float moveDuration = 2f;
[Export] private Tween.TransitionType transitionType = Tween.TransitionType.Linear;
[Export] private Tween.EaseType easeType = Tween.EaseType.InOut;
private Tween tween;
private bool isComplete = false;
public override void Start(Boss boss)
{
Boss = boss;
tween = boss.CreateTween();
isComplete = false;
Vector2 targetPosition = (Boss?.HomePosition ?? boss.GlobalPosition) + relativeTargetPosition;
tween.TweenProperty(Boss, "position", targetPosition, moveDuration)
.SetTrans(transitionType)
.SetEase(easeType)
.Finished += () => isComplete = true;
}
public override void UpdatePattern(double delta) { }
public override bool IsComplete()
{
return isComplete;
}
}

View file

@ -98,7 +98,6 @@ public partial class Weapon : Node2D
// Rotate the ShootDirection by the spread angle
Vector2 spreadDirection = ShootDirection.Rotated(Mathf.DegToRad(spreadOffset));
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, BulletScene, _muzzle.GlobalPosition);
if (bullet == null)

BIN
Sprites/Actors/Rumia.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/Actors/Rumia.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bcqgke6dthlrj"
path="res://.godot/imported/Rumia.png-17dc64f86b8ab2ed278a5be8a865a79b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Actors/Rumia.png"
dest_files=["res://.godot/imported/Rumia.png-17dc64f86b8ab2ed278a5be8a865a79b.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.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/Bullets/mid_bullet.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c4ijhpgbwmbr8"
path="res://.godot/imported/mid_bullet.png-1ac58965f8b5ef0dd6b167a05ec5fb5b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Bullets/mid_bullet.png"
dest_files=["res://.godot/imported/mid_bullet.png-1ac58965f8b5ef0dd6b167a05ec5fb5b.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

Binary file not shown.

BIN
Sprites/Bullets/small_bullet_green.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dmwi86k7hr8sl"
path="res://.godot/imported/small_bullet_green.png-06ba77c665a606eaa98def679ad773e0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Bullets/small_bullet_green.png"
dest_files=["res://.godot/imported/small_bullet_green.png-06ba77c665a606eaa98def679ad773e0.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

Binary file not shown.

BIN
Sprites/Bullets/small_bullet_yellow.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://s5argltaljmq"
path="res://.godot/imported/small_bullet_yellow.png-41c6526899201bd1a4e75ddd93c0f76e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Bullets/small_bullet_yellow.png"
dest_files=["res://.godot/imported/small_bullet_yellow.png-41c6526899201bd1a4e75ddd93c0f76e.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

View file

@ -21,7 +21,7 @@ Settings/temporaryLogLifetime=5.0
[application]
config/name="Cirno"
run/main_scene="res://Scenes/test.tscn"
run/main_scene="res://Scenes/Maps/BossTestArena.tscn"
config/features=PackedStringArray("4.3", "C#", "GL Compatibility")
config/icon="res://icon.svg"