Messing with the dungeon
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.SaveFileBuilder;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
@@ -22,20 +23,26 @@ namespace GameJamDungeon
|
||||
|
||||
PlayerLogic IProvide<PlayerLogic>.Value() => PlayerLogic;
|
||||
|
||||
[Dependency] public IAppRepo AppRepo => this.DependOn<IAppRepo>();
|
||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
[Dependency]
|
||||
public IAppRepo AppRepo => this.DependOn<IAppRepo>();
|
||||
|
||||
[Dependency]
|
||||
public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
[Dependency]
|
||||
public ISaveChunk<GameData> GameChunk => this.DependOn<ISaveChunk<GameData>>();
|
||||
|
||||
/// <summary>Rotation speed (quaternions?/sec).</summary>
|
||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
||||
public float RotationSpeed { get; set; } = 0.5f;
|
||||
public float RotationSpeed { get; set; } = 12.0f;
|
||||
|
||||
/// <summary>Player speed (meters/sec).</summary>
|
||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
||||
public float MoveSpeed { get; set; } = 2f;
|
||||
public float MoveSpeed { get; set; } = 8f;
|
||||
|
||||
/// <summary>Player speed (meters^2/sec).</summary>
|
||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
||||
public float Acceleration { get; set; } = 1f;
|
||||
public float Acceleration { get; set; } = 4f;
|
||||
|
||||
public PlayerLogic.Settings Settings { get; set; } = default!;
|
||||
|
||||
@@ -45,9 +52,15 @@ namespace GameJamDungeon
|
||||
|
||||
public PlayerLogic.IBinding PlayerBinding { get; set; } = default!;
|
||||
|
||||
[Node]
|
||||
public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
[Node]
|
||||
public IAnimatedSprite2D SwordSlashAnimation { get; set; } = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
@@ -75,24 +88,24 @@ namespace GameJamDungeon
|
||||
{
|
||||
PlayerBinding = PlayerLogic.Bind();
|
||||
|
||||
GameRepo.SetPlayerGlobalPosition(GlobalPosition);
|
||||
|
||||
PlayerBinding
|
||||
.Handle((in PlayerLogic.Output.MovementComputed output) =>
|
||||
{
|
||||
Transform = Transform with { Basis = output.Rotation };
|
||||
Velocity = output.Velocity;
|
||||
})
|
||||
{
|
||||
Transform = Transform with { Basis = output.Rotation };
|
||||
Velocity = output.Velocity;
|
||||
})
|
||||
.Handle((in PlayerLogic.Output.Animations.Attack output) =>
|
||||
{
|
||||
AnimationPlayer.Play("attack");
|
||||
});
|
||||
|
||||
this.Provide();
|
||||
PlayerLogic.Start();
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
SetPhysicsProcess(true);
|
||||
}
|
||||
public void OnReady() => SetPhysicsProcess(true);
|
||||
|
||||
public void OnPhysicsProcess(double delta)
|
||||
{
|
||||
@@ -119,12 +132,17 @@ namespace GameJamDungeon
|
||||
return input with { Y = 0f };
|
||||
}
|
||||
|
||||
public void OnAnimationFinished(StringName animation)
|
||||
{
|
||||
GD.Print("Attack finished");
|
||||
PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished());
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
PlayerLogic.Stop();
|
||||
AppRepo.Dispose();
|
||||
GameRepo.Dispose();
|
||||
PlayerBinding.Dispose();
|
||||
AnimationPlayer.AnimationFinished -= OnAnimationFinished;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user