attack -> shungite dart, new abstract attack state
parent
ecfeb2f764
commit
df3799910c
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=33 format=3 uid="uid://bt6s40u515jvo"]
|
||||
[gd_scene load_steps=33 format=3 uid="uid://dsr5kkbthpwpl"]
|
||||
|
||||
[ext_resource type="Script" path="res://Characters/Doc.cs" id="2_3elet"]
|
||||
[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_5jxom"]
|
||||
|
@ -9,7 +9,7 @@
|
|||
[ext_resource type="Script" path="res://State/NPC/NPCStateMachine.cs" id="6_kjpug"]
|
||||
[ext_resource type="Script" path="res://State/NPC/Doc/DocTelegraphState.cs" id="7_tfwbh"]
|
||||
[ext_resource type="PackedScene" uid="uid://cjgxyhgcyvsv7" path="res://BoundingBoxes/Hurtbox.tscn" id="7_tnve0"]
|
||||
[ext_resource type="Script" path="res://State/NPC/Doc/DocAttackState.cs" id="8_r4l3q"]
|
||||
[ext_resource type="Script" path="res://State/NPC/Doc/DocShungiteDartState.cs" id="8_1hoax"]
|
||||
[ext_resource type="Script" path="res://Items/Inventory.cs" id="8_r8ejq"]
|
||||
[ext_resource type="Script" path="res://State/NPC/Doc/DocExitState.cs" id="9_6com1"]
|
||||
[ext_resource type="PackedScene" uid="uid://doiwdphocqlpo" path="res://Entities/ShungiteSpike.tscn" id="9_7kavk"]
|
||||
|
@ -237,7 +237,7 @@ AttackState = NodePath("../Attack")
|
|||
NPC = NodePath("../..")
|
||||
|
||||
[node name="Attack" type="Node" parent="BossStateMachine" node_paths=PackedStringArray("ExitState", "NPC")]
|
||||
script = ExtResource("8_r4l3q")
|
||||
script = ExtResource("8_1hoax")
|
||||
Duration = 8.0
|
||||
AttackDuration = 1.0
|
||||
Projectile = ExtResource("9_7kavk")
|
||||
|
|
|
@ -1,95 +1,16 @@
|
|||
using Godot;
|
||||
using GodotUtilities;
|
||||
using SupaLidlGame.Entities;
|
||||
|
||||
namespace SupaLidlGame.State.NPC.Doc;
|
||||
|
||||
public partial class DocAttackState : NPCState
|
||||
public abstract partial class DocAttackState : NPCState
|
||||
{
|
||||
protected Scenes.Map _map;
|
||||
protected Utils.World _world;
|
||||
public abstract double Duration { get; set; }
|
||||
|
||||
protected double _currentDuration = 0;
|
||||
protected double _currentAttackDuration = 0;
|
||||
public abstract double AttackDuration { get; set; }
|
||||
|
||||
[Export]
|
||||
public double Duration { get; set; }
|
||||
public abstract PackedScene Projectile { get; set; }
|
||||
|
||||
[Export]
|
||||
public double AttackDuration { get; set; }
|
||||
public abstract DocExitState ExitState { get; set; }
|
||||
|
||||
[Export]
|
||||
public PackedScene Projectile { get; set; }
|
||||
|
||||
[Export]
|
||||
public DocExitState ExitState { get; set; }
|
||||
|
||||
private float _intensity = 1;
|
||||
|
||||
public override NPCState Enter(IState<NPCState> previousState)
|
||||
{
|
||||
_map = this.GetAncestor<Scenes.Map>();
|
||||
_world = this.GetAncestor<Utils.World>();
|
||||
_currentDuration = Duration;
|
||||
_currentAttackDuration = AttackDuration;
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void Exit(IState<NPCState> nextState)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual Projectile SpawnProjectile(
|
||||
Vector2 position,
|
||||
Vector2 direction)
|
||||
{
|
||||
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;
|
||||
projectile.GlobalPosition = position;
|
||||
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)
|
||||
{
|
||||
if ((_currentDuration -= delta) <= 0)
|
||||
{
|
||||
return ExitState;
|
||||
}
|
||||
|
||||
if (NPC.Health < 500)
|
||||
{
|
||||
_intensity = 2;
|
||||
}
|
||||
|
||||
if (NPC.Health < 250)
|
||||
{
|
||||
_intensity = 3;
|
||||
}
|
||||
|
||||
if ((_currentAttackDuration -= delta) <= 0)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
protected abstract void Attack();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
using Godot;
|
||||
using GodotUtilities;
|
||||
using SupaLidlGame.Entities;
|
||||
|
||||
namespace SupaLidlGame.State.NPC.Doc;
|
||||
|
||||
public partial class DocShungiteDartState : DocAttackState
|
||||
{
|
||||
protected Scenes.Map _map;
|
||||
protected Utils.World _world;
|
||||
|
||||
protected double _currentDuration = 0;
|
||||
protected double _currentAttackDuration = 0;
|
||||
|
||||
[Export]
|
||||
public override double Duration { get; set; }
|
||||
|
||||
[Export]
|
||||
public override double AttackDuration { get; set; }
|
||||
|
||||
[Export]
|
||||
public override PackedScene Projectile { get; set; }
|
||||
|
||||
[Export]
|
||||
public override DocExitState ExitState { get; set; }
|
||||
|
||||
private float _intensity = 1;
|
||||
|
||||
public override NPCState Enter(IState<NPCState> previousState)
|
||||
{
|
||||
_map = this.GetAncestor<Scenes.Map>();
|
||||
_world = this.GetAncestor<Utils.World>();
|
||||
_currentDuration = Duration;
|
||||
_currentAttackDuration = AttackDuration;
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void Exit(IState<NPCState> nextState)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual Projectile SpawnProjectile(
|
||||
Vector2 position,
|
||||
Vector2 direction)
|
||||
{
|
||||
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;
|
||||
projectile.GlobalPosition = position;
|
||||
projectile.Direction = direction;
|
||||
projectile.GlobalRotation = direction.Angle();
|
||||
projectile.Delay = 1 / _intensity;
|
||||
return projectile;
|
||||
}
|
||||
|
||||
protected override 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)
|
||||
{
|
||||
if ((_currentDuration -= delta) <= 0)
|
||||
{
|
||||
return ExitState;
|
||||
}
|
||||
|
||||
if (NPC.Health < 500)
|
||||
{
|
||||
_intensity = 2;
|
||||
}
|
||||
|
||||
if (NPC.Health < 250)
|
||||
{
|
||||
_intensity = 3;
|
||||
}
|
||||
|
||||
if ((_currentAttackDuration -= delta) <= 0)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
using Godot;
|
||||
using GodotUtilities;
|
||||
using SupaLidlGame.Entities;
|
||||
|
||||
namespace SupaLidlGame.State.NPC.Doc;
|
||||
|
||||
public partial class DocShungiteSpikeState : DocAttackState
|
||||
public partial class DocShungiteSpikeState : DocShungiteDartState
|
||||
{
|
||||
private float _intensity = 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue