Barrier
This commit is contained in:
@@ -18,6 +18,8 @@ public interface IPlayer : IKillable, ICharacterBody3D
|
||||
|
||||
public void LevelUp();
|
||||
|
||||
public void EnactBriefImmunity();
|
||||
|
||||
public void TeleportPlayer((Vector3 Rotation, Vector3 Position) newTransform);
|
||||
|
||||
public void Equip(IEquipableItem equipable);
|
||||
@@ -66,6 +68,8 @@ public interface IPlayer : IKillable, ICharacterBody3D
|
||||
|
||||
public bool AutoIdentifyItems { get; set; }
|
||||
|
||||
public bool BriefImmunity { get; set; }
|
||||
|
||||
public event Action PlayerDied;
|
||||
public delegate IBaseInventoryItem RerollItem(IBaseInventoryItem item);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=27 format=3 uid="uid://brgi35xj3b4ud"]
|
||||
[gd_scene load_steps=29 format=3 uid="uid://brgi35xj3b4ud"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cw100tox0ufsy" path="res://src/audio/SfxDatabase.cs" id="1_ojkqd"]
|
||||
[ext_resource type="AudioStream" uid="uid://cye8wlqbx66h4" path="res://src/audio/sfx/player_heal.ogg" id="2_158j8"]
|
||||
@@ -18,6 +18,8 @@
|
||||
[ext_resource type="AudioStream" uid="uid://na0lxb1lib11" path="res://src/audio/sfx/player_crit.ogg" id="14_p5cio"]
|
||||
[ext_resource type="AudioStream" uid="uid://bsc83jkt7uisg" path="res://src/audio/sfx/PLAYER_GET_ITEM.ogg" id="15_r16t0"]
|
||||
[ext_resource type="AudioStream" uid="uid://ckf3md1ujxhvm" path="res://src/audio/sfx/player_levelup.ogg" id="16_sew62"]
|
||||
[ext_resource type="AudioStream" uid="uid://borq41t2u5jhe" path="res://src/audio/sfx/PLAYER_BUFF.ogg" id="17_rcwkk"]
|
||||
[ext_resource type="AudioStream" uid="uid://brb8xj4vsgcw4" path="res://src/audio/sfx/player_DEBUFF.ogg" id="18_bi4v5"]
|
||||
[ext_resource type="AudioStream" uid="uid://coeynqnn61c43" path="res://src/audio/sfx/ITEM_TRANSFER.ogg" id="18_l6w22"]
|
||||
[ext_resource type="AudioStream" uid="uid://bfrmm07vthpwt" path="res://src/audio/sfx/item_divine_recall.ogg" id="19_nerso"]
|
||||
[ext_resource type="AudioStream" uid="uid://bu8akh5uh3ioo" path="res://src/audio/sfx/item_devic_balance_element1.ogg" id="20_rloay"]
|
||||
@@ -125,6 +127,18 @@ process_mode = 3
|
||||
stream = ExtResource("8_rf1la")
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="BuffSound" type="AudioStreamPlayer" parent="Player"]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
stream = ExtResource("17_rcwkk")
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="DebuffSound" type="AudioStreamPlayer" parent="Player"]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
stream = ExtResource("18_bi4v5")
|
||||
bus = &"SFX"
|
||||
|
||||
[node name="Item" type="Node" parent="."]
|
||||
|
||||
[node name="TransferItemSound" type="AudioStreamPlayer" parent="Item"]
|
||||
|
||||
@@ -31,6 +31,8 @@ public partial class SfxDatabase : Node
|
||||
{SoundEffect.MoveUI, MoveSound },
|
||||
{SoundEffect.Equip, EquipSound },
|
||||
{SoundEffect.Unequip, UnequipSound },
|
||||
{SoundEffect.Buff, BuffSound },
|
||||
{SoundEffect.Debuff, DebuffSound },
|
||||
{SoundEffect.SortInventory, SortSound },
|
||||
{SoundEffect.SelectUI, SelectSound },
|
||||
{SoundEffect.CancelUI, CancelSound },
|
||||
@@ -63,6 +65,8 @@ public partial class SfxDatabase : Node
|
||||
[Node] private AudioStreamPlayer MoveSound { get; set; }
|
||||
[Node] private AudioStreamPlayer EquipSound { get; set; }
|
||||
[Node] private AudioStreamPlayer UnequipSound { get; set; }
|
||||
[Node] private AudioStreamPlayer BuffSound { get; set; }
|
||||
[Node] private AudioStreamPlayer DebuffSound { get; set; }
|
||||
[Node] private AudioStreamPlayer SortSound { get; set; }
|
||||
[Node] private AudioStreamPlayer SelectSound { get; set; }
|
||||
[Node] private AudioStreamPlayer CancelSound { get; set; }
|
||||
@@ -115,5 +119,7 @@ public enum SoundEffect
|
||||
WeaponSlowSlash,
|
||||
WeaponPlasmaSword,
|
||||
Eucharistia,
|
||||
Buff,
|
||||
Debuff
|
||||
}
|
||||
|
||||
|
||||
@@ -630,6 +630,9 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
switch (effectItem.UsableItemTag)
|
||||
{
|
||||
case UsableItemTag.BriefImmunity:
|
||||
_player.EnactBriefImmunity();
|
||||
break;
|
||||
case UsableItemTag.TeleportAllEnemiesToRoom:
|
||||
_effectService.TeleportEnemiesToCurrentRoom([.. GetTree().GetNodesInGroup("enemy").OfType<IEnemy>()]);
|
||||
SfxDatabase.Instance.Play(SoundEffect.RecallEnemies);
|
||||
|
||||
21
Zennysoft.Game.Ma/src/items/Barrier.cs
Normal file
21
Zennysoft.Game.Ma/src/items/Barrier.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Barrier : Node3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public AnimationPlayer Fader { get; set; }
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
Fader.Play("fade_in");
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
{
|
||||
Fader.Play("fade_out");
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/items/Barrier.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/items/Barrier.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b43uny7cxx4bw
|
||||
328
Zennysoft.Game.Ma/src/items/Barrier.tscn
Normal file
328
Zennysoft.Game.Ma/src/items/Barrier.tscn
Normal file
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_q0ipf")
|
||||
UsableItemTag = 0
|
||||
UsableItemTag = 2
|
||||
ElementalDamageType = 0
|
||||
InitialCount = 0
|
||||
Name = "Persiko"
|
||||
|
||||
@@ -22,6 +22,7 @@ public partial class DummyPlayer : CharacterBody3D, IPlayer
|
||||
public float HealthTimerSpeedModifier { get; }
|
||||
public bool AutoIdentifyItems { get; set; }
|
||||
public IStatusEffectComponent StatusEffectComponent { get; }
|
||||
public bool BriefImmunity { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public event Action PlayerDied;
|
||||
|
||||
@@ -41,4 +42,5 @@ public partial class DummyPlayer : CharacterBody3D, IPlayer
|
||||
public void TeleportPlayer((Vector3 Rotation, Vector3 Position) newTransform) => throw new NotImplementedException();
|
||||
public void Unequip(IEquipableItem equipable) => throw new NotImplementedException();
|
||||
public IBaseInventoryItem IdentifyItem(IBaseInventoryItem unidentifiedItem) => throw new NotImplementedException();
|
||||
public void EnactBriefImmunity() => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
|
||||
[Node] private ShakeCamera _camera3D { get; set; } = default!;
|
||||
|
||||
[Node] private Barrier Barrier { get; set; } = default!;
|
||||
|
||||
[Node] private ProjectileSystem _airReactorProjectileSystem { get; set; } = default!;
|
||||
[Node] private ProjectileSystem _fireReactorProjectileSystem { get; set; } = default!;
|
||||
[Node] private ProjectileSystem _waterReactorProjectileSystem { get; set; } = default!;
|
||||
@@ -116,6 +118,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
[Export]
|
||||
public bool AutoIdentifyItems { get; set; } = false;
|
||||
|
||||
[Export]
|
||||
public bool BriefImmunity { get; set; } = false;
|
||||
|
||||
[Export]
|
||||
private float _immunityTime { get; set; } = 30f;
|
||||
|
||||
[Export]
|
||||
public float HealthTimerSpeedModifier { get; set; } = 1f;
|
||||
|
||||
@@ -137,6 +145,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
private PlayerEffectService _playerEffectService;
|
||||
|
||||
private Timer _projectileCooldownTimer;
|
||||
private Timer _immunityTimer;
|
||||
private bool _fired;
|
||||
|
||||
public void Initialize()
|
||||
@@ -212,9 +221,21 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
_projectileCooldownTimer.WaitTime = 1.8f;
|
||||
_projectileCooldownTimer.Timeout += ProjectileCooldown;
|
||||
|
||||
_immunityTimer = new Timer();
|
||||
AddChild(_immunityTimer);
|
||||
_immunityTimer.WaitTime = _immunityTime;
|
||||
_immunityTimer.Timeout += _immunityTimer_Timeout;
|
||||
|
||||
SetProcessInput(false);
|
||||
SetPhysicsProcess(false);
|
||||
}
|
||||
|
||||
private void _immunityTimer_Timeout()
|
||||
{
|
||||
BriefImmunity = false;
|
||||
Barrier.FadeOut();
|
||||
SfxDatabase.Instance.Play(SoundEffect.Debuff);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Activate()
|
||||
@@ -266,6 +287,9 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
|
||||
public void TakeDamage(AttackData damage)
|
||||
{
|
||||
if (BriefImmunity)
|
||||
return;
|
||||
|
||||
_camera3D.AddShake(1.0f);
|
||||
TakeDamageAnimationPlayer.Play("take_damage");
|
||||
var damageReceived = DamageCalculator.CalculateDamage(damage, TotalDefense, EquipmentComponent.ElementalResistance);
|
||||
@@ -649,6 +673,14 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
HealthComponent.LowerMaximumHP(hpIncrease);
|
||||
}
|
||||
|
||||
public void EnactBriefImmunity()
|
||||
{
|
||||
SfxDatabase.Instance.Play(SoundEffect.Buff);
|
||||
BriefImmunity = true;
|
||||
Barrier.FadeIn();
|
||||
_immunityTimer.Start();
|
||||
}
|
||||
|
||||
private static float LeftStrafeInputVector => Godot.Input.GetActionStrength(GameInputs.StrafeLeft);
|
||||
|
||||
private static float RightStrafeInputVector => Godot.Input.GetActionStrength(GameInputs.StrafeRight);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user