diff --git a/Resources/BossPhases/Rumia_NS2.tres b/Resources/BossPhases/Rumia_NS2.tres index d5b1e1d1..92ab437a 100644 --- a/Resources/BossPhases/Rumia_NS2.tres +++ b/Resources/BossPhases/Rumia_NS2.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="BossPhase" load_steps=15 format=3 uid="uid://ddb5dqocmk6x7"] +[gd_resource type="Resource" script_class="BossPhase" load_steps=25 format=3 uid="uid://ddb5dqocmk6x7"] [ext_resource type="PackedScene" uid="uid://dh81snen2f6bf" path="res://Scenes/Weapons/Bullets/enemyBullet_rice_blue_small.tscn" id="1_as8n2"] [ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="1_fdlxv"] @@ -6,6 +6,9 @@ [ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="2_wkmhk"] [ext_resource type="PackedScene" uid="uid://ctrk5qrb7n3fm" path="res://Scenes/Weapons/Bullets/enemyBullet_rice_green_small.tscn" id="4_tek7n"] [ext_resource type="PackedScene" uid="uid://chowj81jsdvcx" path="res://Scenes/Weapons/Bullets/enemyBullet_rice_red_small.tscn" id="5_n4xqo"] +[ext_resource type="Script" path="res://Scripts/Resources/SimpleMovementPattern.cs" id="6_bw7cj"] +[ext_resource type="PackedScene" uid="uid://dohakkayqj4w2" path="res://Scenes/Weapons/Bullets/enemyBullet_green.tscn" id="7_gsnyb"] +[ext_resource type="Script" path="res://Scripts/Resources/SpeedModifier.cs" id="8_6ya1v"] [sub_resource type="Resource" id="Resource_17kqi"] script = ExtResource("2_kghxb") @@ -121,9 +124,81 @@ _timeModifiers = Array[Resource]([SubResource("Resource_sk6w4")]) _targetPlayer = false WaitForCompletion = true +[sub_resource type="Resource" id="Resource_erexw"] +script = ExtResource("6_bw7cj") +relativeTargetPosition = Vector2(50, 5) +moveDuration = 2.0 +transitionType = 0 +easeType = 2 +WaitForCompletion = true + +[sub_resource type="Resource" id="Resource_80ngy"] +script = ExtResource("8_6ya1v") +ModifierType = 1 +Easing = 0 +Invert = true +MinimumSpeed = 10.0 +ScalingFactor = 10.0 + +[sub_resource type="Resource" id="Resource_hutbf"] +script = ExtResource("2_kghxb") +TimeInSeconds = 0.5 +ModifierType = 2 +Value = 0.0 + +[sub_resource type="Resource" id="Resource_krtsy"] +script = ExtResource("2_kghxb") +TimeInSeconds = 0.8 +ModifierType = 0 +Value = 50.0 + +[sub_resource type="Resource" id="Resource_mpjrl"] +script = ExtResource("2_wkmhk") +BulletScene = ExtResource("7_gsnyb") +bulletSpeed = 80.0 +bulletCount = 12 +rotationSpeed = 0.0 +_rotationOffset = 45.0 +duration = 1.0 +burstInterval = 1.0 +spread = 180.0 +owner = 2 +_damageType = 0 +_bulletDamage = 1.0 +_modifier = SubResource("Resource_80ngy") +_timeModifiers = Array[Resource]([SubResource("Resource_hutbf"), SubResource("Resource_krtsy")]) +_targetPlayer = false +WaitForCompletion = true + +[sub_resource type="Resource" id="Resource_l05f2"] +script = ExtResource("6_bw7cj") +relativeTargetPosition = Vector2(45, 0) +moveDuration = 0.4 +transitionType = 0 +easeType = 2 +WaitForCompletion = true + +[sub_resource type="Resource" id="Resource_ncfnl"] +script = ExtResource("2_wkmhk") +BulletScene = ExtResource("7_gsnyb") +bulletSpeed = 80.0 +bulletCount = 12 +rotationSpeed = 0.0 +_rotationOffset = 45.0 +duration = 1.0 +burstInterval = 1.0 +spread = 180.0 +owner = 2 +_damageType = 0 +_bulletDamage = 1.0 +_modifier = SubResource("Resource_80ngy") +_timeModifiers = Array[Resource]([SubResource("Resource_hutbf"), SubResource("Resource_krtsy")]) +_targetPlayer = false +WaitForCompletion = true + [resource] script = ExtResource("1_fdlxv") PhaseName = "" Threshold = 800 PlayAnimation = false -Patterns = Array[Object]([SubResource("Resource_puvpt"), SubResource("Resource_44j24"), SubResource("Resource_wkxow"), SubResource("Resource_gcqck"), SubResource("Resource_bxbto"), SubResource("Resource_q48s1")]) +Patterns = Array[Object]([SubResource("Resource_puvpt"), SubResource("Resource_44j24"), SubResource("Resource_wkxow"), SubResource("Resource_gcqck"), SubResource("Resource_bxbto"), SubResource("Resource_q48s1"), SubResource("Resource_erexw"), SubResource("Resource_mpjrl"), SubResource("Resource_l05f2"), SubResource("Resource_ncfnl")]) diff --git a/Scenes/Barrel.cs b/Scenes/Barrel.cs index 0566d99b..6f0b9a1e 100644 --- a/Scenes/Barrel.cs +++ b/Scenes/Barrel.cs @@ -17,6 +17,8 @@ public partial class Barrel : Area2D, IDestructible [Export] public PackedScene ExplosionParticles { get; set; } [Export] public BulletResource ExplosionData { get; set; } + private GameManager _gameManager; + private float _currentHealth = 0f; private bool _isDestroyed = false; @@ -24,6 +26,7 @@ public partial class Barrel : Area2D, IDestructible // Called when the node enters the scene tree for the first time. public override void _Ready() { + _gameManager = this.GetGameManager(); _currentHealth = Health; } @@ -48,7 +51,7 @@ public partial class Barrel : Area2D, IDestructible var explosion = this.CreateSibling(ExplosionData.BulletScene); explosion.Speed = 0; - explosion.Initialize(ExplosionData.MakeBullet(this.GlobalPosition)); + explosion.Initialize(ExplosionData.MakeBullet(this.GlobalPosition), _gameManager); } private void ApplyExplosionDamage() diff --git a/Scripts/Bullet.cs b/Scripts/Bullet.cs index 7aa4f06e..b1b58e5a 100644 --- a/Scripts/Bullet.cs +++ b/Scripts/Bullet.cs @@ -27,10 +27,14 @@ public partial class Bullet : Area2D private List _modifiers = new(); - public void Initialize(BulletInfo bulletInfo) + private GameManager _gameManager; + + public void Initialize(BulletInfo bulletInfo, GameManager gameManager) { _bulletInfo = bulletInfo; + _gameManager = gameManager; + // Ugly hack to make instances unique _modifiers = _bulletInfo.TimeModifiers.Select(x => new ModifierWrapper() { @@ -79,14 +83,11 @@ public partial class Bullet : Area2D //Rotation = radians; } - private void FacePlayer() { - // TODO: cache player - var player = GetTree().GetFirstNodeInGroup("Player") as Node2D; - if (player != null) + if (_gameManager.Player != null) { - _direction = (player.GlobalPosition - this.GlobalPosition).Normalized(); + _direction = (_gameManager.Player.GlobalPosition - this.GlobalPosition).Normalized(); //LookAt(player.GlobalPosition); } } diff --git a/Scripts/Components/BulletSpawner.cs b/Scripts/Components/BulletSpawner.cs index 7becde92..efa61611 100644 --- a/Scripts/Components/BulletSpawner.cs +++ b/Scripts/Components/BulletSpawner.cs @@ -22,7 +22,7 @@ public partial class BulletSpawner : Node2D { var bullet = this.CreateChildOf(_gameManager.BulletsContainer, bulletInfo.BulletScene ?? BulletScene, bulletInfo.Position); - bullet.Initialize(bulletInfo); + bullet.Initialize(bulletInfo, _gameManager); float modifiedSpeed = bulletInfo.Modifier?.ModifySpeed(bulletInfo.Speed, i, bulletInfo.BulletCount) ?? bulletInfo.Speed; bullet.Speed = modifiedSpeed; @@ -37,7 +37,6 @@ public partial class BulletSpawner : Node2D Vector2 bulletDirection = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); - bullet.SetDirection(bulletDirection); } } diff --git a/Scripts/Tools.cs b/Scripts/Tools.cs index 5e816199..258536f9 100644 --- a/Scripts/Tools.cs +++ b/Scripts/Tools.cs @@ -64,7 +64,8 @@ public static class Tools public static GameManager GetGameManager(this Node2D node) { - return node.GetNode("/root/GameScene"); + return node.GetTree().Root.GetNode("GameScene"); + // node.GetNode("/root/GameScene"); } public static AlarmManager GetAlarmManager(this Node2D node) diff --git a/Scripts/Weapon.cs b/Scripts/Weapon.cs index d9282d1a..0392adf0 100644 --- a/Scripts/Weapon.cs +++ b/Scripts/Weapon.cs @@ -107,7 +107,7 @@ public partial class Weapon : Node2D return; }; - bullet.Initialize(WeaponData.MakeBullet(_muzzle.GlobalPosition)); + bullet.Initialize(WeaponData.MakeBullet(_muzzle.GlobalPosition), _gameManager); //bullet.SetDirection(ShootDirection); bullet.SetDirection(spreadDirection);