mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-22 07:23:48 +00:00
Shield particles
This commit is contained in:
parent
4a8ac7a495
commit
fc833ae300
2 changed files with 42 additions and 38 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=38 format=3 uid="uid://bghghp5ep4w2j"]
|
[gd_scene load_steps=39 format=3 uid="uid://bghghp5ep4w2j"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/PlayerMovement.cs" id="1_m27vu"]
|
[ext_resource type="Script" path="res://Scripts/PlayerMovement.cs" id="1_m27vu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_bwf6x"]
|
[ext_resource type="Texture2D" uid="uid://la06powu57hu" path="res://Sprites/Cirno_Big.png" id="2_bwf6x"]
|
||||||
|
|
@ -27,7 +27,7 @@ region = Rect2(0, 0, 8, 16)
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_s7co1"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_s7co1"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("6_xugve")
|
shader = ExtResource("6_xugve")
|
||||||
shader_parameter/blink_color = Color(1, 1, 1, 1)
|
shader_parameter/blink_color = Color(1, 0.0705882, 0.0392157, 1)
|
||||||
shader_parameter/blink_intensity = 0.0
|
shader_parameter/blink_intensity = 0.0
|
||||||
shader_parameter/teleport_progress = 0.0
|
shader_parameter/teleport_progress = 0.0
|
||||||
shader_parameter/scanline_density = 0.0
|
shader_parameter/scanline_density = 0.0
|
||||||
|
|
@ -172,7 +172,16 @@ radius = 17.2627
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_e6woi"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_e6woi"]
|
||||||
radius = 1.0
|
radius = 1.0
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle", "HitboxSprite") groups=["Destroyable", "player"]]
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_hmqi5"]
|
||||||
|
particle_flag_disable_z = true
|
||||||
|
emission_shape = 2
|
||||||
|
emission_sphere_radius = 16.0
|
||||||
|
orbit_velocity_min = -1.0
|
||||||
|
orbit_velocity_max = 1.098
|
||||||
|
gravity = Vector3(0, 0, 0)
|
||||||
|
color = Color(0.0392157, 0.380392, 1, 1)
|
||||||
|
|
||||||
|
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("Muzzle", "HitboxSprite", "_shieldParticles") groups=["Destroyable", "player"]]
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 99
|
collision_mask = 99
|
||||||
|
|
@ -187,6 +196,7 @@ Muzzle = NodePath("Muzzle")
|
||||||
BlinkShader = ExtResource("6_xugve")
|
BlinkShader = ExtResource("6_xugve")
|
||||||
HitboxSprite = NodePath("Smoothing2D/HitboxSprite")
|
HitboxSprite = NodePath("Smoothing2D/HitboxSprite")
|
||||||
_deathParticles = ExtResource("4_1bl4h")
|
_deathParticles = ExtResource("4_1bl4h")
|
||||||
|
_shieldParticles = NodePath("ShieldParticles")
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
@ -267,6 +277,13 @@ script = ExtResource("14_mfxfv")
|
||||||
ResourceName = "Shield"
|
ResourceName = "Shield"
|
||||||
MaxResource = 25.0
|
MaxResource = 25.0
|
||||||
|
|
||||||
|
[node name="ShieldParticles" type="GPUParticles2D" parent="."]
|
||||||
|
emitting = false
|
||||||
|
amount = 32
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_hmqi5")
|
||||||
|
lifetime = 0.4
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
[connection signal="area_entered" from="InteractionController" to="." method="_on_interaction_controller_area_entered"]
|
[connection signal="area_entered" from="InteractionController" to="." method="_on_interaction_controller_area_entered"]
|
||||||
[connection signal="area_exited" from="InteractionController" to="." method="_on_interaction_controller_area_exited"]
|
[connection signal="area_exited" from="InteractionController" to="." method="_on_interaction_controller_area_exited"]
|
||||||
[connection signal="area_entered" from="DamageHitBox" to="." method="_on_damage_hit_box_area_entered"]
|
[connection signal="area_entered" from="DamageHitBox" to="." method="_on_damage_hit_box_area_entered"]
|
||||||
|
|
|
||||||
|
|
@ -49,20 +49,19 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
|
|
||||||
[Export] public float MaxHealth = 32f;
|
[Export] public float MaxHealth = 32f;
|
||||||
[Export] public float MaxShield = 32f;
|
[Export] public float MaxShield = 32f;
|
||||||
|
|
||||||
[Export] public Shader BlinkShader {get;set;}
|
[Export] public Shader BlinkShader {get;set;}
|
||||||
|
[Export] public Sprite2D HitboxSprite { get; set; }
|
||||||
|
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
|
||||||
|
|
||||||
[ExportGroup("Action Names")]
|
[ExportGroup("Action Names")]
|
||||||
[Export] private string _shootActionName = "shoot";
|
[Export] private string _shootActionName = "shoot";
|
||||||
[ExportGroup("Action Names")]
|
|
||||||
[Export] private string _useActionName = "Use";
|
[Export] private string _useActionName = "Use";
|
||||||
[ExportGroup("Action Names")]
|
|
||||||
[Export] private string _strafeActionName = "strafe";
|
[Export] private string _strafeActionName = "strafe";
|
||||||
[ExportGroup("Action Names")]
|
|
||||||
[Export] private string _nextWeaponActionName = "next_weapon";
|
[Export] private string _nextWeaponActionName = "next_weapon";
|
||||||
[ExportGroup("Action Names")]
|
|
||||||
[Export] private string _previousWeaponActionName = "previous_weapon";
|
[Export] private string _previousWeaponActionName = "previous_weapon";
|
||||||
|
[ExportCategory("Particles")]
|
||||||
|
[Export] private PackedScene _deathParticles;
|
||||||
|
[Export] private GpuParticles2D _shieldParticles;
|
||||||
public Weapon EquippedWeapon { get; set; }
|
public Weapon EquippedWeapon { get; set; }
|
||||||
|
|
||||||
public Array<Weapon> EquippedWeapons { get; set; } = new Array<Weapon>();
|
public Array<Weapon> EquippedWeapons { get; set; } = new Array<Weapon>();
|
||||||
|
|
@ -81,10 +80,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
private ActorResourceProvider _healthProvider;
|
private ActorResourceProvider _healthProvider;
|
||||||
private ActorResourceProvider _shieldProvider;
|
private ActorResourceProvider _shieldProvider;
|
||||||
|
|
||||||
[Export] public Sprite2D HitboxSprite { get; set; }
|
|
||||||
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.Player;
|
|
||||||
|
|
||||||
[Export] private PackedScene _deathParticles;
|
|
||||||
private bool _isStrafing { get; set; }
|
private bool _isStrafing { get; set; }
|
||||||
|
|
||||||
private bool _canMove = true;
|
private bool _canMove = true;
|
||||||
|
|
@ -104,24 +99,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void DeathEventHandler();
|
public delegate void DeathEventHandler();
|
||||||
|
|
||||||
// public float CurrentHealth
|
|
||||||
// {
|
|
||||||
// get => _currentHealth;
|
|
||||||
// set
|
|
||||||
// {
|
|
||||||
// if (_currentHealth != value)
|
|
||||||
// {
|
|
||||||
// _currentHealth = value;
|
|
||||||
//
|
|
||||||
// if (_currentHealth > MaxHealth) {
|
|
||||||
// _currentHealth = MaxHealth;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// EmitSignal(nameof(HealthChanged), _currentHealth, MaxHealth);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public float CurrentHealth
|
public float CurrentHealth
|
||||||
{
|
{
|
||||||
get => _healthProvider.CurrentResource;
|
get => _healthProvider.CurrentResource;
|
||||||
|
|
@ -473,6 +450,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
|
|
||||||
if (CurrentShield > 0 && type is not DamageType.Explosive or DamageType.Acid) {
|
if (CurrentShield > 0 && type is not DamageType.Explosive or DamageType.Acid) {
|
||||||
// Reduce shield
|
// Reduce shield
|
||||||
|
PlayShieldAnimation();
|
||||||
CurrentShield -= damage;
|
CurrentShield -= damage;
|
||||||
if (CurrentShield < 0 ) {
|
if (CurrentShield < 0 ) {
|
||||||
CurrentHealth -= Math.Abs(CurrentShield);
|
CurrentHealth -= Math.Abs(CurrentShield);
|
||||||
|
|
@ -486,13 +464,8 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
else {
|
else {
|
||||||
CurrentHealth -= damage;
|
CurrentHealth -= damage;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Blink
|
Blink();
|
||||||
//_animatedSprite
|
|
||||||
if (BlinkShader != null)
|
|
||||||
{
|
|
||||||
_ = Blink();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(CurrentHealth <= 0)) return;
|
if (!(CurrentHealth <= 0)) return;
|
||||||
|
|
@ -500,7 +473,21 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||||
Explode();
|
Explode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Blink()
|
private void PlayShieldAnimation()
|
||||||
|
{
|
||||||
|
if (_shieldParticles is null) return;
|
||||||
|
_shieldParticles.Emitting = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Blink()
|
||||||
|
{
|
||||||
|
if (BlinkShader != null)
|
||||||
|
{
|
||||||
|
_ = BlinkAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task BlinkAsync()
|
||||||
{
|
{
|
||||||
((ShaderMaterial)_animatedSprite.Material).Shader = BlinkShader;
|
((ShaderMaterial)_animatedSprite.Material).Shader = BlinkShader;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue