shungite spike state

pull/3/head
John Montagu, the 4th Earl of Sandvich 2023-07-17 20:03:38 -07:00
parent 54c2bef86b
commit ecfeb2f764
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
6 changed files with 124 additions and 11 deletions

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://debqunpkdemj2"
path="res://.godot/imported/mini-shungite.png-01bdbec41fe54ed8fc826d4314ec257e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Sprites/Misc/mini-shungite.png"
dest_files=["res://.godot/imported/mini-shungite.png-01bdbec41fe54ed8fc826d4314ec257e.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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dvx2b0y6dup53"
path="res://.godot/imported/shungite-spike.png-3c88db04670aa56f0aed81fe7332990b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Sprites/Misc/shungite-spike.png"
dest_files=["res://.godot/imported/shungite-spike.png-3c88db04670aa56f0aed81fe7332990b.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

@ -1,5 +1,6 @@
using Godot;
using GodotUtilities;
using SupaLidlGame.Entities;
namespace SupaLidlGame.State.NPC.Doc;
@ -39,9 +40,11 @@ public partial class DocAttackState : NPCState
}
protected virtual void SpawnProjectile(Vector2 position, Vector2 direction)
protected virtual Projectile SpawnProjectile(
Vector2 position,
Vector2 direction)
{
var projectile = _map.SpawnEntity<Entities.Projectile>(Projectile);
var projectile = _map.SpawnEntity<Projectile>(Projectile);
projectile.Hitbox.Faction = NPC.Faction;
// global position is (from npc to player) * 2 = (2 * npc) - player
//projectile.GlobalPosition = 2 * NPC.GlobalPosition - playerPos;
@ -49,6 +52,20 @@ public partial class DocAttackState : NPCState
projectile.Direction = direction;
projectile.GlobalRotation = direction.Angle();
projectile.Delay = 1 / _intensity;
return projectile;
}
protected virtual void Attack()
{
var player = _world.CurrentPlayer;
var playerPos = player.GlobalPosition;
Vector2 position1 = 2 * NPC.GlobalPosition - playerPos;
Vector2 position2 = 2 * playerPos - NPC.GlobalPosition;
Vector2 direction1 = position1.DirectionTo(playerPos);
Vector2 direction2 = -direction1;
SpawnProjectile(position1, direction1);
SpawnProjectile(position2, direction2);
_currentAttackDuration = AttackDuration / _intensity;
}
public override NPCState Process(double delta)
@ -70,15 +87,7 @@ public partial class DocAttackState : NPCState
if ((_currentAttackDuration -= delta) <= 0)
{
var player = _world.CurrentPlayer;
var playerPos = player.GlobalPosition;
Vector2 position1 = 2 * NPC.GlobalPosition - playerPos;
Vector2 position2 = 2 * playerPos - NPC.GlobalPosition;
Vector2 direction1 = position1.DirectionTo(playerPos);
Vector2 direction2 = -direction1;
SpawnProjectile(position1, direction1);
SpawnProjectile(position2, direction2);
_currentAttackDuration = AttackDuration / _intensity;
Attack();
}
return null;

View File

@ -0,0 +1,36 @@
using Godot;
using GodotUtilities;
using SupaLidlGame.Entities;
namespace SupaLidlGame.State.NPC.Doc;
public partial class DocShungiteSpikeState : DocAttackState
{
private float _intensity = 1;
protected override Projectile SpawnProjectile(
Vector2 position,
Vector2 direction)
{
var projectile = base.SpawnProjectile(position, direction);
projectile.Delay = 4;
return projectile;
}
protected override void Attack()
{
var player = _world.CurrentPlayer;
var playerPos = player.GlobalPosition;
Vector2 left = playerPos + Vector2.Left * 64;
Vector2 right = playerPos + Vector2.Right * 64;
Vector2 up = playerPos + Vector2.Up * 64;
Vector2 down = playerPos + Vector2.Down * 64;
SpawnProjectile(left, Vector2.Zero);
SpawnProjectile(right, Vector2.Zero);
SpawnProjectile(up, Vector2.Zero);
SpawnProjectile(down, Vector2.Zero);
// only attack once and stop (but keep in this state for 8 seconds)
_currentAttackDuration = float.PositiveInfinity;
}
}