Massive refactor (inventory menu still a little broken but its Good Enough)
This commit is contained in:
@@ -9,12 +9,8 @@ namespace GameJamDungeon
|
||||
{
|
||||
public interface IPlayer : ICharacterBody3D, IKillable
|
||||
{
|
||||
PlayerStatInfo PlayerStatInfo { get; }
|
||||
|
||||
PlayerLogic PlayerLogic { get; }
|
||||
|
||||
PlayerData PlayerData { get; }
|
||||
|
||||
public Vector3 GetGlobalInputVector();
|
||||
|
||||
public float GetLeftStrafeInputVector();
|
||||
@@ -38,27 +34,13 @@ namespace GameJamDungeon
|
||||
[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; } = 12.0f;
|
||||
|
||||
/// <summary>Player speed (meters/sec).</summary>
|
||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
||||
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; } = 4f;
|
||||
|
||||
[Export]
|
||||
public PlayerStatInfo PlayerStatInfo { get; set; }
|
||||
public PlayerStatResource PlayerStatResource { get; set; } = default!;
|
||||
|
||||
public PlayerLogic.Settings Settings { get; set; } = default!;
|
||||
|
||||
public PlayerLogic PlayerLogic { get; set; } = default!;
|
||||
|
||||
public PlayerData PlayerData { get; set; } = default!;
|
||||
|
||||
public PlayerLogic.IBinding PlayerBinding { get; set; } = default!;
|
||||
|
||||
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
@@ -69,14 +51,10 @@ namespace GameJamDungeon
|
||||
|
||||
[Node] public Timer HealthTimer { get; set; } = default!;
|
||||
|
||||
[Node] public Label HPNumber { get; set; } = default!;
|
||||
|
||||
[Node] public Label VTNumber { get; set; } = default!;
|
||||
|
||||
[Node] public Label LevelNumber { get; set; } = default!;
|
||||
|
||||
[Node] public IArea3D CollisionDetector { get; set; } = default!;
|
||||
|
||||
private PlayerData PlayerData { get; set; } = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
@@ -84,7 +62,29 @@ namespace GameJamDungeon
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
Settings = new PlayerLogic.Settings() { RotationSpeed = RotationSpeed, MoveSpeed = MoveSpeed, Acceleration = Acceleration };
|
||||
Settings = new PlayerLogic.Settings() { RotationSpeed = PlayerStatResource.RotationSpeed, MoveSpeed = PlayerStatResource.MoveSpeed, Acceleration = PlayerStatResource.Acceleration };
|
||||
|
||||
PlayerData = new PlayerData()
|
||||
{
|
||||
GlobalTransform = GlobalTransform,
|
||||
StateMachine = PlayerLogic,
|
||||
Velocity = Velocity,
|
||||
Inventory = new Inventory(),
|
||||
CurrentHP = new AutoProp<int>(PlayerStatResource.CurrentHP),
|
||||
MaximumHP = new AutoProp<int>(PlayerStatResource.MaximumHP),
|
||||
CurrentVT = new AutoProp<int>(PlayerStatResource.CurrentVT),
|
||||
MaximumVT = new AutoProp<int>(PlayerStatResource.MaximumVT),
|
||||
CurrentAttack = new AutoProp<int>(PlayerStatResource.CurrentAttack),
|
||||
MaxAttack = new AutoProp<int>(PlayerStatResource.MaxAttack),
|
||||
CurrentDefense = new AutoProp<int>(PlayerStatResource.CurrentDefense),
|
||||
MaxDefense = new AutoProp<int>(PlayerStatResource.MaxDefense),
|
||||
CurrentExp = new AutoProp<int>(PlayerStatResource.CurrentExp),
|
||||
ExpToNextLevel = new AutoProp<int>(PlayerStatResource.ExpToNextLevel),
|
||||
CurrentLevel = new AutoProp<int>(PlayerStatResource.CurrentLevel),
|
||||
BonusAttack = new AutoProp<int>(PlayerStatResource.BonusAttack),
|
||||
BonusDefense = new AutoProp<int>(PlayerStatResource.BonusDefense),
|
||||
Luck = new AutoProp<double>(PlayerStatResource.Luck)
|
||||
};
|
||||
|
||||
PlayerLogic = new PlayerLogic();
|
||||
PlayerLogic.Set(this as IPlayer);
|
||||
@@ -92,6 +92,12 @@ namespace GameJamDungeon
|
||||
PlayerLogic.Set(AppRepo);
|
||||
PlayerLogic.Set(GameRepo);
|
||||
PlayerLogic.Set(PlayerData);
|
||||
|
||||
PlayerData.Inventory.EquippedWeapon.Sync += EquippedWeapon_Sync;
|
||||
PlayerData.Inventory.EquippedArmor.Sync += EquippedArmor_Sync;
|
||||
PlayerData.Inventory.EquippedAccessory.Sync += EquippedAccessory_Sync;
|
||||
|
||||
PlayerData.CurrentHP.Sync += CurrentHP_Sync;
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
@@ -106,9 +112,8 @@ namespace GameJamDungeon
|
||||
})
|
||||
.Handle((in PlayerLogic.Output.Animations.Attack output) =>
|
||||
{
|
||||
var weaponInfo = GameRepo.EquippedWeapon.Value.WeaponInfo;
|
||||
var attackSpeed = (float)weaponInfo.AttackSpeed;
|
||||
AnimationPlayer.SetSpeedScale(attackSpeed);
|
||||
var attackSpeed = PlayerData.Inventory.EquippedWeapon.Value.WeaponStats.AttackSpeed;
|
||||
AnimationPlayer.SetSpeedScale((float)attackSpeed);
|
||||
AnimationPlayer.Play("attack");
|
||||
})
|
||||
.Handle((in PlayerLogic.Output.ThrowItem output) =>
|
||||
@@ -117,11 +122,10 @@ namespace GameJamDungeon
|
||||
|
||||
this.Provide();
|
||||
PlayerLogic.Start();
|
||||
|
||||
GameRepo.SetPlayerData(PlayerData);
|
||||
SwordSlashAnimation.Position = GetViewport().GetVisibleRect().Size / 2;
|
||||
GlobalPosition = GameRepo.PlayerGlobalPosition.Value;
|
||||
GameRepo.SetPlayerStatInfo(PlayerStatInfo);
|
||||
|
||||
GameRepo.PlayerGlobalPosition.Sync += PlayerGlobalPosition_Sync;
|
||||
HealthTimer.Timeout += OnHealthTimerTimeout;
|
||||
CollisionDetector.AreaEntered += OnEnemyHitBoxEntered;
|
||||
}
|
||||
@@ -142,26 +146,6 @@ namespace GameJamDungeon
|
||||
Settings.MoveSpeed /= 4;
|
||||
}
|
||||
|
||||
private void OnEnemyHitBoxEntered(Area3D area)
|
||||
{
|
||||
if (area is IHitbox hitBox)
|
||||
{
|
||||
if (GameRepo.PlayerStatInfo.Value.CurrentHP > 0)
|
||||
{
|
||||
var enemy = hitBox.GetParent<IEnemy>();
|
||||
var isCriticalHit = false;
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var roll = rng.Randf();
|
||||
if (roll <= enemy.EnemyStatInfo.Luck)
|
||||
isCriticalHit = true;
|
||||
var damage = DamageCalculator.CalculateEnemyDamage(PlayerStatInfo, enemy.EnemyStatInfo, GameRepo.EquippedArmor.Value.ArmorInfo, isCriticalHit);
|
||||
GameRepo.PlayerStatInfo.Value.CurrentHP = GameRepo.PlayerStatInfo.Value.CurrentHP - damage;
|
||||
GD.Print($"Player hit for {damage} damage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPhysicsProcess(double delta)
|
||||
{
|
||||
PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta));
|
||||
@@ -171,13 +155,6 @@ namespace GameJamDungeon
|
||||
PlayerLogic.Input(new PlayerLogic.Input.Moved(GlobalPosition));
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
OnHPChanged(GameRepo.PlayerStatInfo.Value.CurrentHP);
|
||||
OnVTChanged(GameRepo.PlayerStatInfo.Value.CurrentVT);
|
||||
OnLevelChanged(GameRepo.PlayerStatInfo.Value.CurrentLevel);
|
||||
}
|
||||
|
||||
public Vector3 GetGlobalInputVector()
|
||||
{
|
||||
var rawInput = Input.GetVector(GameInputs.MoveLeft, GameInputs.MoveRight, GameInputs.MoveUp, GameInputs.MoveDown);
|
||||
@@ -226,35 +203,72 @@ namespace GameJamDungeon
|
||||
|
||||
public void Kill() => PlayerLogic.Input(new PlayerLogic.Input.Killed());
|
||||
|
||||
private void OnHPChanged(double newHP)
|
||||
private void PlayerGlobalPosition_Sync(Vector3 newPlayerPosition)
|
||||
{
|
||||
HPNumber.Text = $"{Mathf.RoundToInt(newHP)}/{PlayerStatInfo.MaximumHP}";
|
||||
|
||||
if (newHP <= 0.0)
|
||||
{
|
||||
PlayerLogic.Input(new PlayerLogic.Input.Killed());
|
||||
HealthTimer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnVTChanged(int newVT)
|
||||
{
|
||||
VTNumber.Text = $"{newVT}/{PlayerStatInfo.MaximumVT}";
|
||||
}
|
||||
|
||||
private void OnLevelChanged(int newLevel)
|
||||
{
|
||||
LevelNumber.Text = $"{newLevel}";
|
||||
GlobalPosition = newPlayerPosition;
|
||||
}
|
||||
|
||||
private void OnPlayerPositionUpdated(Vector3 globalPosition) => GlobalPosition = globalPosition;
|
||||
|
||||
private void OnHealthTimerTimeout()
|
||||
{
|
||||
if (GameRepo.PlayerStatInfo.Value.CurrentVT > 0)
|
||||
GameRepo.PlayerStatInfo.Value.CurrentVT = GameRepo.PlayerStatInfo.Value.CurrentVT - 1;
|
||||
if (PlayerData.CurrentVT.Value > 0)
|
||||
PlayerData.CurrentVT.OnNext(PlayerData.CurrentVT.Value - 1);
|
||||
else
|
||||
GameRepo.PlayerStatInfo.Value.CurrentHP = GameRepo.PlayerStatInfo.Value.CurrentHP - 1;
|
||||
PlayerData.CurrentHP.OnNext(PlayerData.CurrentHP.Value - 1);
|
||||
}
|
||||
|
||||
private void EquippedAccessory_Sync(Accessory equippedItem)
|
||||
{
|
||||
PlayerData.BonusAttack.OnNext(PlayerData.BonusAttack.Value - PlayerData.Inventory.EquippedAccessory.Value.AccessoryInfo.ATKUp);
|
||||
PlayerData.BonusDefense.OnNext(PlayerData.BonusDefense.Value - PlayerData.Inventory.EquippedAccessory.Value.AccessoryInfo.DEFUp);
|
||||
PlayerData.MaximumHP.OnNext(PlayerData.MaximumHP.Value - PlayerData.Inventory.EquippedAccessory.Value.AccessoryInfo.MaxHPUp);
|
||||
PlayerData.MaximumVT.OnNext(PlayerData.MaximumVT.Value - PlayerData.Inventory.EquippedAccessory.Value.AccessoryInfo.MaxVTUp);
|
||||
PlayerData.Luck.OnNext(PlayerData.Luck.Value - PlayerData.Inventory.EquippedAccessory.Value.AccessoryInfo.LUCKUp);
|
||||
|
||||
PlayerData.BonusAttack.OnNext(PlayerData.BonusAttack.Value + equippedItem.AccessoryInfo.ATKUp);
|
||||
PlayerData.BonusDefense.OnNext(PlayerData.BonusDefense.Value + equippedItem.AccessoryInfo.DEFUp);
|
||||
PlayerData.MaximumHP.OnNext(PlayerData.MaximumHP.Value + equippedItem.AccessoryInfo.MaxHPUp);
|
||||
PlayerData.MaximumVT.OnNext(PlayerData.MaximumVT.Value + equippedItem.AccessoryInfo.MaxVTUp);
|
||||
PlayerData.Luck.OnNext(PlayerData.Luck.Value + equippedItem.AccessoryInfo.LUCKUp);
|
||||
PlayerData.Inventory.Equip(equippedItem);
|
||||
}
|
||||
|
||||
private void EquippedArmor_Sync(Armor equippedItem)
|
||||
{
|
||||
PlayerData.BonusDefense.OnNext(PlayerData.BonusDefense.Value - PlayerData.Inventory.EquippedArmor.Value.ArmorStats.Defense);
|
||||
PlayerData.BonusDefense.OnNext(PlayerData.BonusDefense.Value + equippedItem.ArmorStats.Defense);
|
||||
PlayerData.Inventory.Equip(equippedItem);
|
||||
}
|
||||
|
||||
private void EquippedWeapon_Sync(Weapon equippedItem)
|
||||
{
|
||||
PlayerData.BonusAttack.OnNext(PlayerData.BonusAttack.Value - PlayerData.Inventory.EquippedWeapon.Value.WeaponStats.Damage);
|
||||
PlayerData.BonusAttack.OnNext(PlayerData.BonusAttack.Value + equippedItem.WeaponStats.Damage);
|
||||
PlayerData.Inventory.Equip(equippedItem);
|
||||
}
|
||||
|
||||
private void OnEnemyHitBoxEntered(Area3D area)
|
||||
{
|
||||
if (area is IHitbox hitBox)
|
||||
{
|
||||
var enemy = hitBox.GetParent<IEnemy>();
|
||||
var isCriticalHit = false;
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var roll = rng.Randf();
|
||||
if (roll <= enemy.EnemyStatResource.Luck)
|
||||
isCriticalHit = true;
|
||||
var damage = DamageCalculator.CalculateEnemyDamage(PlayerData.CurrentDefense.Value + PlayerData.BonusDefense.Value, enemy.EnemyStatResource, GameRepo.PlayerData.Inventory.EquippedArmor.Value.ArmorStats, isCriticalHit);
|
||||
PlayerData.CurrentHP.OnNext(PlayerData.CurrentHP.Value - Mathf.RoundToInt(damage));
|
||||
GD.Print($"Player hit for {damage} damage.");
|
||||
}
|
||||
}
|
||||
|
||||
private void CurrentHP_Sync(int newHealth)
|
||||
{
|
||||
if (newHealth <= 0)
|
||||
Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
[gd_scene load_steps=22 format=3 uid="uid://cfecvvav8kkp6"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://cfecvvav8kkp6"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/player/Player.cs" id="1_xcol5"]
|
||||
[ext_resource type="Texture2D" uid="uid://bokx3h8kfdo5i" path="res://src/player/slash_0000_Classic_30.png" id="2_la11l"]
|
||||
[ext_resource type="Script" path="res://src/hitbox/Hitbox.cs" id="2_lb3qc"]
|
||||
[ext_resource type="Script" path="res://src/player/PlayerStatInfo.cs" id="2_n88di"]
|
||||
[ext_resource type="Script" path="res://src/player/PlayerStatResource.cs" id="2_xq68d"]
|
||||
[ext_resource type="Texture2D" uid="uid://byosr5gk51237" path="res://src/player/slash_0001_Classic_29.png" id="3_ux3f1"]
|
||||
[ext_resource type="Texture2D" uid="uid://nh071o6ii03j" path="res://src/player/slash_0002_Classic_28.png" id="4_gqnq0"]
|
||||
[ext_resource type="Texture2D" uid="uid://bodfblud4kea3" path="res://src/player/slash_0003_Classic_27.png" id="5_eebal"]
|
||||
[ext_resource type="Texture2D" uid="uid://de55prolicl0u" path="res://src/player/slash_0004_Classic_26.png" id="6_ngag5"]
|
||||
[ext_resource type="Texture2D" uid="uid://bp0msic3uk3kc" path="res://src/player/slash_0005_Layer-1.png" id="7_tp5uu"]
|
||||
[ext_resource type="Texture2D" uid="uid://hg2kraa5nrnl" path="res://src/ui/textures/blank level symbol.png" id="10_rsd7v"]
|
||||
[ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="11_6gvkm"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="12_f4uqk"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_up0v1"]
|
||||
script = ExtResource("2_n88di")
|
||||
CurrentHP = 100.0
|
||||
MaximumHP = 100.0
|
||||
[sub_resource type="Resource" id="Resource_btp2w"]
|
||||
script = ExtResource("2_xq68d")
|
||||
RotationSpeed = 3.0
|
||||
MoveSpeed = 4.0
|
||||
Acceleration = 1.0
|
||||
CurrentHP = 100
|
||||
MaximumHP = 100
|
||||
CurrentVT = 90
|
||||
MaximumVT = 90
|
||||
CurrentExp = 0
|
||||
ExpToNextLevel = 100
|
||||
CurrentLevel = 1
|
||||
CurrentEXP = 0
|
||||
EXPToNextLevel = 100
|
||||
CurrentAttack = 12
|
||||
MaxAttack = 12
|
||||
CurrentDefense = 8
|
||||
MaxDefense = 8
|
||||
CurrentAttack = 14
|
||||
CurrentDefense = 12
|
||||
MaxAttack = 14
|
||||
MaxDefense = 12
|
||||
BonusAttack = 0
|
||||
BonusDefense = 0
|
||||
Luck = 0.0
|
||||
Luck = 0.05
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_wedu3"]
|
||||
|
||||
@@ -98,8 +98,8 @@ tracks/1/keys = {
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_w8l8m"]
|
||||
_data = {
|
||||
&"attack": SubResource("Animation_0jjwv"),
|
||||
&"RESET": SubResource("Animation_hcjph")
|
||||
"RESET": SubResource("Animation_hcjph"),
|
||||
"attack": SubResource("Animation_0jjwv")
|
||||
}
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_ywvvo"]
|
||||
@@ -139,10 +139,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.381018, 0)
|
||||
collision_layer = 38
|
||||
collision_mask = 7
|
||||
script = ExtResource("1_xcol5")
|
||||
RotationSpeed = 3.0
|
||||
MoveSpeed = 4.0
|
||||
Acceleration = 1.0
|
||||
PlayerStatInfo = SubResource("Resource_up0v1")
|
||||
PlayerStatResource = SubResource("Resource_btp2w")
|
||||
|
||||
[node name="Hitbox" type="Area3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
@@ -183,7 +180,7 @@ omni_range = 83.659
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_w8l8m")
|
||||
"": SubResource("AnimationLibrary_w8l8m")
|
||||
}
|
||||
|
||||
[node name="SwordSlashAnimation" type="AnimatedSprite2D" parent="."]
|
||||
@@ -197,82 +194,3 @@ unique_name_in_owner = true
|
||||
process_mode = 1
|
||||
wait_time = 3.0
|
||||
autostart = true
|
||||
|
||||
[node name="PlayerInfoUI" type="MarginContainer" parent="."]
|
||||
offset_right = 629.0
|
||||
offset_bottom = 256.0
|
||||
theme_override_constants/margin_left = 32
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="PlayerInfoUI"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="PlayerInfoUI/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="PlayerInfoUI/HBoxContainer/CenterContainer"]
|
||||
custom_minimum_size = Vector2(128, 128)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
texture = ExtResource("10_rsd7v")
|
||||
expand_mode = 1
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="LevelNumber" type="Label" parent="PlayerInfoUI/HBoxContainer/CenterContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
layout_mode = 2
|
||||
text = "99"
|
||||
label_settings = ExtResource("11_6gvkm")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="PlayerInfoUI/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 15
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="PlayerInfoUI/HBoxContainer/VBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="HP" type="Label" parent="PlayerInfoUI/HBoxContainer/VBox/HBox"]
|
||||
layout_mode = 2
|
||||
text = "HP: "
|
||||
label_settings = ExtResource("11_6gvkm")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="PlayerInfoUI/HBoxContainer/VBox/HBox"]
|
||||
custom_minimum_size = Vector2(30, 0)
|
||||
layout_mode = 2
|
||||
border_width = 0.0
|
||||
|
||||
[node name="HPNumber" type="Label" parent="PlayerInfoUI/HBoxContainer/VBox/HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "222/222"
|
||||
label_settings = ExtResource("12_f4uqk")
|
||||
|
||||
[node name="HBox2" type="HBoxContainer" parent="PlayerInfoUI/HBoxContainer/VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VT" type="Label" parent="PlayerInfoUI/HBoxContainer/VBox/HBox2"]
|
||||
layout_mode = 2
|
||||
text = "VT:"
|
||||
label_settings = ExtResource("11_6gvkm")
|
||||
|
||||
[node name="ReferenceRect" type="ReferenceRect" parent="PlayerInfoUI/HBoxContainer/VBox/HBox2"]
|
||||
custom_minimum_size = Vector2(30, 0)
|
||||
layout_mode = 2
|
||||
border_width = 0.0
|
||||
|
||||
[node name="VTNumber" type="Label" parent="PlayerInfoUI/HBoxContainer/VBox/HBox2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "444/444"
|
||||
label_settings = ExtResource("12_f4uqk")
|
||||
|
||||
[node name="TextureButton" type="TextureButton" parent="PlayerInfoUI"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Marker3D" type="Marker3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.70201)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Chickensoft.Serialization;
|
||||
using Chickensoft.Collections;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
|
||||
namespace GameJamDungeon
|
||||
@@ -12,5 +13,36 @@ namespace GameJamDungeon
|
||||
public required PlayerLogic StateMachine { get; init; }
|
||||
[Save("velocity")]
|
||||
public required Vector3 Velocity { get; init; }
|
||||
|
||||
[Save("inventory")]
|
||||
public required Inventory Inventory { get; init; }
|
||||
[Save("currentHP")]
|
||||
public required AutoProp<int> CurrentHP { get; init; }
|
||||
[Save("maximumHP")]
|
||||
public required AutoProp<int> MaximumHP { get; init; }
|
||||
[Save("currentVT")]
|
||||
public required AutoProp<int> CurrentVT { get; init; }
|
||||
[Save("maximumVT")]
|
||||
public required AutoProp<int> MaximumVT { get; init; }
|
||||
[Save("currentExp")]
|
||||
public required AutoProp<int> CurrentExp { get; init; }
|
||||
[Save("expToNextLevel")]
|
||||
public required AutoProp<int> ExpToNextLevel { get; init; }
|
||||
[Save("currentLevel")]
|
||||
public required AutoProp<int> CurrentLevel { get; init; }
|
||||
[Save("currentAttack")]
|
||||
public required AutoProp<int> CurrentAttack { get; init; }
|
||||
[Save("currentDefense")]
|
||||
public required AutoProp<int> CurrentDefense { get; init; }
|
||||
[Save("maxAttack")]
|
||||
public required AutoProp<int> MaxAttack { get; init; }
|
||||
[Save("maxDefense")]
|
||||
public required AutoProp<int> MaxDefense { get; init; }
|
||||
[Save("bonusAttack")]
|
||||
public required AutoProp<int> BonusAttack { get; init; }
|
||||
[Save("bonusDefense")]
|
||||
public required AutoProp<int> BonusDefense { get; init; }
|
||||
[Save("luck")]
|
||||
public required AutoProp<double> Luck { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
using Chickensoft.Collections;
|
||||
using Godot;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
[GlobalClass]
|
||||
public partial class PlayerStatInfo : Resource, ICharacterStats
|
||||
{
|
||||
[Export]
|
||||
public double CurrentHP { get => _currentHP.Value; set => _currentHP.OnNext(Mathf.Min(MaximumHP, value)); }
|
||||
|
||||
[Export]
|
||||
public double MaximumHP { get => _maximumHP.Value; set => _maximumHP.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public int CurrentVT { get => _currentVT.Value; set => _currentVT.OnNext(Mathf.Min(MaximumVT, value)); }
|
||||
|
||||
[Export]
|
||||
public int MaximumVT { get => _maximumVT.Value; set => _maximumVT.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public int CurrentLevel { get => _currentLevel.Value; set => _currentLevel.OnNext(value); }
|
||||
|
||||
|
||||
[Export]
|
||||
public int CurrentEXP { get => _currentExp.Value; set => _currentExp.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public int EXPToNextLevel { get => _expToNextLevel.Value; set => _expToNextLevel.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public int CurrentAttack { get => _currentAttack.Value; set => _currentAttack.OnNext(Mathf.Min(MaxAttack, value)); }
|
||||
|
||||
[Export]
|
||||
public int MaxAttack { get => _maxAttack.Value; set => _maxAttack.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public int CurrentDefense { get => _currentDefense.Value; set => _currentDefense.OnNext(Mathf.Min(CurrentDefense, value)); }
|
||||
[Export]
|
||||
public int MaxDefense { get => _maxDefense.Value; set => _maxDefense.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public int BonusAttack { get => _bonusAttack.Value; set => _bonusAttack.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public int BonusDefense { get => _bonusDefense.Value; set => _bonusDefense.OnNext(value); }
|
||||
|
||||
[Export]
|
||||
public double Luck { get => _luck.Value; set => _luck.OnNext(value); }
|
||||
|
||||
// AutoProp backing data
|
||||
private readonly AutoProp<double> _currentHP = new AutoProp<double>(double.MaxValue);
|
||||
private readonly AutoProp<double> _maximumHP = new AutoProp<double>(double.MaxValue);
|
||||
|
||||
private readonly AutoProp<int> _currentVT = new AutoProp<int>(int.MaxValue);
|
||||
private readonly AutoProp<int> _maximumVT = new AutoProp<int>(int.MaxValue);
|
||||
|
||||
private readonly AutoProp<int> _currentExp = new AutoProp<int>(int.MaxValue);
|
||||
private readonly AutoProp<int> _expToNextLevel = new AutoProp<int>(int.MaxValue);
|
||||
private readonly AutoProp<int> _currentLevel = new AutoProp<int>(int.MaxValue);
|
||||
|
||||
private readonly AutoProp<int> _currentAttack = new AutoProp<int>(int.MaxValue);
|
||||
private readonly AutoProp<int> _currentDefense = new AutoProp<int>(int.MaxValue);
|
||||
|
||||
private readonly AutoProp<int> _maxAttack = new AutoProp<int>(int.MaxValue);
|
||||
private readonly AutoProp<int> _maxDefense = new AutoProp<int>(int.MaxValue);
|
||||
|
||||
private readonly AutoProp<int> _bonusAttack = new AutoProp<int>(int.MaxValue);
|
||||
private readonly AutoProp<int> _bonusDefense = new AutoProp<int>(int.MaxValue);
|
||||
|
||||
private readonly AutoProp<double> _luck = new AutoProp<double>(double.MaxValue);
|
||||
}
|
||||
}
|
||||
42
src/player/PlayerStatResource.cs
Normal file
42
src/player/PlayerStatResource.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Godot;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
[GlobalClass]
|
||||
public partial class PlayerStatResource : Resource
|
||||
{
|
||||
/// <summary>Rotation speed (quaternions?/sec).</summary>
|
||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
||||
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; } = 8f;
|
||||
|
||||
/// <summary>Player speed (meters^2/sec).</summary>
|
||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
||||
public float Acceleration { get; set; } = 4f;
|
||||
|
||||
[Export] public int CurrentHP { get; set; }
|
||||
[Export] public int MaximumHP { get; set; }
|
||||
|
||||
[Export] public int CurrentVT { get; set; }
|
||||
[Export] public int MaximumVT { get; set; }
|
||||
|
||||
[Export] public int CurrentExp { get; set; }
|
||||
[Export] public int ExpToNextLevel { get; set; }
|
||||
[Export] public int CurrentLevel { get; set; }
|
||||
|
||||
[Export] public int CurrentAttack { get; set; }
|
||||
[Export] public int CurrentDefense { get; set; }
|
||||
|
||||
[Export] public int MaxAttack { get; set; }
|
||||
[Export] public int MaxDefense { get; set; }
|
||||
|
||||
[Export] public int BonusAttack { get; set; }
|
||||
[Export] public int BonusDefense { get; set; }
|
||||
|
||||
[Export(PropertyHint.Range, "0, 1, 0.01")]
|
||||
public double Luck { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
[gd_resource type="Resource" script_class="PlayerStatInfo" load_steps=2 format=3 uid="uid://cofd1ylluj24"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/player/PlayerStatInfo.cs" id="1_a84hi"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_a84hi")
|
||||
MaximumHP = 120.0
|
||||
MaximumVT = 90
|
||||
BaseAttack = 10
|
||||
BaseDefense = 0
|
||||
ElementAResistance = 0.0
|
||||
ElementBResistance = 0.0
|
||||
ElementCResistance = 15.0
|
||||
BaseElementADamageBonus = 30.0
|
||||
BaseElementBDamageBonus = 15.0
|
||||
BaseElementCDamageBonus = 20.0
|
||||
Reference in New Issue
Block a user