From ce093646aa7b4fb7d4f839e8c6d8e1296e6e0e7e Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Thu, 31 Aug 2023 19:03:16 -0700 Subject: [PATCH 01/10] clean up & some documentation --- Characters/Character.cs | 40 +++++++++- Characters/NPC.cs | 166 +--------------------------------------- Characters/Player.cs | 7 +- Items/Item.cs | 6 ++ Items/Weapons/Sword.cs | 28 +++++-- State/StateMachine.cs | 49 +++++++++++- 6 files changed, 120 insertions(+), 176 deletions(-) diff --git a/Characters/Character.cs b/Characters/Character.cs index 7546533..168b31d 100644 --- a/Characters/Character.cs +++ b/Characters/Character.cs @@ -26,9 +26,6 @@ public partial class Character : CharacterBody2D, IFaction } } - [Export] - public float Stealth { get; protected set; } = 0; - [Signal] public delegate void HealthChangedEventHandler(Events.HealthChangedArgs args); @@ -168,6 +165,9 @@ public partial class Character : CharacterBody2D, IFaction } } + /// + /// Handles the Character's death. + /// public virtual void Die() { if (HurtAnimation.HasAnimation("death")) @@ -190,11 +190,20 @@ public partial class Character : CharacterBody2D, IFaction NetImpulse += impulse / Mass; } + /// + /// Stuns the Chararacter for an amount of time. If + /// is less than the Character's current + /// stun time left, it will have no effect. + /// public virtual void Stun(float time) { StunTime = Mathf.Max(time, StunTime); } + /// + /// Draws the character so that its sprite and inventory items face the + /// character's direction. + /// protected virtual void DrawTarget() { Vector2 target = Target; @@ -213,6 +222,10 @@ public partial class Character : CharacterBody2D, IFaction Inventory.Rotation = angle; } + /// + /// Use the current item the character is using. Prefer to call this over + /// Item.Use as it will check if the character is stunned or alive. + /// public void UseCurrentItem() { if (StunTime > 0 || !IsAlive) @@ -264,6 +277,9 @@ public partial class Character : CharacterBody2D, IFaction } } + /// + /// Override this method to modify the damage the character takes. + /// protected virtual float ReceiveDamage( float damage, Character inflictor, @@ -285,6 +301,9 @@ public partial class Character : CharacterBody2D, IFaction _curDamageText.ShowText(); } + /// + /// Handles the character taking damage. + /// protected virtual void OnReceivedDamage( float damage, Character inflictor, @@ -348,6 +367,7 @@ public partial class Character : CharacterBody2D, IFaction } } +#if DEBUG /// /// For debugging purposes /// @@ -355,7 +375,12 @@ public partial class Character : CharacterBody2D, IFaction { OnReceivedDamage(damage, null, 0); } +#endif + /// + /// Plays a footstep sound. This should be called through an + /// AnimationPlayer to sync sounds with animations. + /// public virtual void Footstep() { if (GetNode("Effects/Footstep") is AudioStreamPlayer2D player) @@ -364,6 +389,15 @@ public partial class Character : CharacterBody2D, IFaction } } + /// + /// Returns whether the Character has line of sight with + /// . + /// + /// The character to check for LOS + /// + /// Determines whether the raycast should pass through world clips (physics + /// layer 5) + /// public bool HasLineOfSight(Character character, bool excludeClip = false) { var exclude = new Godot.Collections.Array(); diff --git a/Characters/NPC.cs b/Characters/NPC.cs index 1143e5d..fedf3c0 100644 --- a/Characters/NPC.cs +++ b/Characters/NPC.cs @@ -96,29 +96,9 @@ public partial class NPC : Character }; } - public override void _Draw() - { -#if DEBUG - for (int i = 0; i < 16; i++) - { - Vector2 vec = _weightDirs[i] * _weights[i] * 32; - Color c = Colors.Green; - if (_bestWeightIdx == i) - { - c = Colors.Blue; - } - else if (_weights[i] < 0) - { - c = Colors.Red; - vec = -vec; - } - DrawLine(Vector2.Zero, vec, c); - } -#endif - - base._Draw(); - } - + /// + /// Finds the NPC's best character to target. + /// public virtual Character FindBestTarget() { float bestScore = float.MaxValue; @@ -136,21 +116,9 @@ public partial class NPC : Character float score = 0; score += Position.DistanceTo(character.Position); - score *= (character.Stealth + 1); - - // if the character has enough stealth, the dot product of the - // enemy's current direction and to the character will affect - // the score - // TODO: implement if (score < bestScore) { - // if the character has enough stealth, they won't be - // targeted if the NPC is not able to see - if (!HasLineOfSight(character) && character.Stealth >= 1) - { - continue; - } bestScore = score; bestChar = character; } @@ -170,132 +138,4 @@ public partial class NPC : Character ThinkerStateMachine.PhysicsProcess(delta); base._PhysicsProcess(delta); } - - public void ThinkProcess(double delta) - { - if ((_thinkTimeElapsed += delta) > ThinkTime) - { - _thinkTimeElapsed = 0; - Think(); -#if DEBUG_NPC - QueueRedraw(); -#endif - } - - if (!ShouldMove || (!ShouldMoveWhenUsingItem && Inventory.IsUsingItem)) - { - Direction = Vector2.Zero; - } - else - { - Direction = _weightDirs[_bestWeightIdx]; - } - } - - public void UpdateWeights(Vector2 pos) - { - // FIXME: TODO: remove all the spaghetti - Vector2 dir = Target.Normalized(); - float distSq = GlobalPosition.DistanceSquaredTo(pos); - - var spaceState = GetWorld2D().DirectSpaceState; - var exclude = new Godot.Collections.Array(); - exclude.Add(this.GetRid()); - - // calculate weights based on distance - for (int i = 0; i < 16; i++) - { - float directDot = _weightDirs[i].Dot(dir); - // clamp dot from [-1, 1] to [0, 1] - directDot = (directDot + 1) / 2; - - float strafeDot = Math.Abs(_weightDirs[i].Dot(dir.Clockwise90())); - float currDirDot = (_weightDirs[i].Dot(Direction) + 1) / 16; - strafeDot = Mathf.Pow((strafeDot + 1) / 2, 2) + currDirDot; - - // favor strafing when getting closer - if (distSq > _preferredWeightDistanceSq) - { - _weights[i] = directDot; - } - else if (distSq > _maxWeightDistanceSq) - { - float dDotWeight = Mathf.Sqrt(distSq / 4096); - float sDotWeight = 1 - dDotWeight; - _weights[i] = (dDotWeight * directDot) + - (sDotWeight * strafeDot); - } - else - { - _weights[i] = strafeDot; - } - } - - // subtract weights that collide - for (int i = 0; i < 16; i++) - { - var rayParams = new PhysicsRayQueryParameters2D - { - Exclude = exclude, - CollideWithBodies = true, - From = GlobalPosition, - To = GlobalPosition + (_weightDirs[i] * 24), - CollisionMask = 1 + 2 + 16 - }; - - var result = spaceState.IntersectRay(rayParams); - - // if we hit something - if (result.Count > 0) - { - // then we subtract the value of this from the other weights - float oldWeight = _weights[i]; - for (int j = 0; j < 16; j++) - { - if (i == j) - { - _weights[i] = 0; - } - else - { - float dot = _weightDirs[i].Dot(_weightDirs[j]); - _weights[j] -= _weights[j] * dot; - } - } - } - } - - - float bestWeight = 0; - for (int i = 0; i < 16; i++) - { - if (_weights[i] > bestWeight) - { - _bestWeightIdx = i; - bestWeight = _weights[i]; - } - } - } - - protected virtual void Think() - { - // TODO: the entity should wander if it doesn't find a best target - Character bestTarget = FindBestTarget(); - if (bestTarget is not null) - { - Vector2 pos = FindBestTarget().GlobalPosition; - Target = pos - GlobalPosition; - Vector2 dir = Target; - float dist = GlobalPosition.DistanceSquaredTo(pos); - UpdateWeights(pos); - - if (dist < 1600 && CanAttack) - { - if (Inventory.SelectedItem is Weapon weapon) - { - UseCurrentItem(); - } - } - } - } } diff --git a/Characters/Player.cs b/Characters/Player.cs index d74a1d2..18702fc 100644 --- a/Characters/Player.cs +++ b/Characters/Player.cs @@ -51,10 +51,6 @@ public sealed partial class Player : Character public override void _Process(double delta) { base._Process(delta); - - var mod = Sprite.SelfModulate; - mod.A = 1 - (Stealth / 2); - Sprite.SelfModulate = mod; } public override void _Input(InputEvent @event) @@ -65,6 +61,9 @@ public sealed partial class Player : Character } } + /// + /// Respawns the player with full health and plays spawn animation + /// public void Spawn() { Health = 100; diff --git a/Items/Item.cs b/Items/Item.cs index df47050..78ee0b3 100644 --- a/Items/Item.cs +++ b/Items/Item.cs @@ -23,6 +23,12 @@ public abstract partial class Item : Node2D public Character CharacterOwner { get; set; } + /// + /// Determines if the item is being used. This property determines if + /// a character can use another item or not. + /// See + /// + /// public virtual bool IsUsing => false; /// diff --git a/Items/Weapons/Sword.cs b/Items/Weapons/Sword.cs index 1578c9f..76a1964 100644 --- a/Items/Weapons/Sword.cs +++ b/Items/Weapons/Sword.cs @@ -7,6 +7,9 @@ using SupaLidlGame.State.Weapon; namespace SupaLidlGame.Items.Weapons; +/// +/// A basic melee weapon. +/// public partial class Sword : Weapon, IParryable { public bool IsAttacking { get; protected set; } @@ -77,6 +80,9 @@ public partial class Sword : Weapon, IParryable EnableParry(Time.GetTicksMsec()); } + /// + /// Makes this melee weapon be able to parry and be parried. + /// public void EnableParry(ulong parryTimeOrigin) { IsParried = false; @@ -84,6 +90,9 @@ public partial class Sword : Weapon, IParryable ParryTimeOrigin = parryTimeOrigin; } + /// + /// Makes this melee weapon be able to parry and be parried. + /// public void DisableParry() { IsParryable = false; @@ -113,6 +122,10 @@ public partial class Sword : Weapon, IParryable base.DeuseAlt(); } + /// + /// Enables the weapon's hitbox. Prefer to call this from a state machine + /// rather than managing state through the weapon script. + /// public void Attack() { //RemainingAttackTime = AttackTime; @@ -120,6 +133,9 @@ public partial class Sword : Weapon, IParryable Hitbox.IsDisabled = false; } + /// + /// Disables the weapon's hitbox and processes all hurtboxes it hit. + /// public void Deattack() { IsAttacking = false; @@ -161,6 +177,9 @@ public partial class Sword : Weapon, IParryable base._Process(delta); } + /// + /// Processes all hits and applies damages to hurtboxes. + /// public void ProcessHits() { if (IsParried) @@ -199,6 +218,10 @@ public partial class Sword : Weapon, IParryable } } + /// + /// Stuns the wepaon holder. This is unique to swords and melee weapons + /// if they can parry. + /// public void Stun() { IsParried = true; @@ -238,9 +261,4 @@ public partial class Sword : Weapon, IParryable } } } - - protected void SetAnimationCondition(string condition, bool value) - { - - } } diff --git a/State/StateMachine.cs b/State/StateMachine.cs index 5be3f54..c680c39 100644 --- a/State/StateMachine.cs +++ b/State/StateMachine.cs @@ -18,11 +18,28 @@ public abstract partial class StateMachine : Node where T : Node, IState ChangeState(InitialState); } + /// + /// Changes the state of the StateMachine. + /// + /// The next state to transition to. + /// + /// if is a + /// valid state, otherwise + /// public virtual bool ChangeState(T nextState) { return ChangeState(nextState, out Stack _); } + /// + /// Changes the state of the StateMachine. + /// + /// The next state to transition to. + /// The actual state. + /// + /// if is a + /// valid state, otherwise + /// public bool ChangeState(T nextState, out T finalState) { var status = ChangeState(nextState, out Stack states); @@ -30,6 +47,15 @@ public abstract partial class StateMachine : Node where T : Node, IState return status; } + /// + /// Changes the state of the StateMachine. + /// + /// The next state to transition to. + /// Stack of all states that transitioned/proxied. + /// + /// if is a + /// valid state, otherwise + /// public bool ChangeState(T nextState, out Stack states) { states = new Stack(); @@ -71,14 +97,35 @@ public abstract partial class StateMachine : Node where T : Node, IState } /// - /// Changes the current state to a state of type U which must inherit from T. + /// Changes the state of the StateMachine of type + /// which must inherit from + /// . /// + /// The type of the state to transition to. + /// The resulting state to be transitioned to. + /// + /// if is a + /// valid state, otherwise + /// public bool ChangeState(out U state) where U : T { state = this.FindChildOfType(); return ChangeState(state); } + /// + /// Changes the state of the StateMachine with node name + /// . + /// + /// The type of the state to transition to. + /// + /// The name of the node. + /// + /// The resulting state to be transitioned to. + /// + /// if is a + /// valid state, otherwise + /// public bool ChangeState(string name, out T state) { state = GetNode(name); From 2c7ea564c17e5d98d4fbd060bb913c273da3eb5f Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Thu, 31 Aug 2023 19:51:58 -0700 Subject: [PATCH 02/10] update README.md --- README.md | 17 ++++++++++++++++- README.org | 8 -------- 2 files changed, 16 insertions(+), 9 deletions(-) delete mode 100644 README.org diff --git a/README.md b/README.md index e8b42e3..5c60a4e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,22 @@ Forsen-related game ![](./Assets/Sprites/Characters/forsen2-portrait.png) -![](https://i.ibb.co/t367kD4/baj.gif) +## Building + +This is currently being developed on a custom dev branch of Godot 4.1.1: +https://github.com/ryze312/godot/tree/x11_event_fix + +Try to avoid using newer versions of Godot as they are unstable with C#. + +## Notes + +The tilde key (`~`) can open the developer console. This allows access to +singletons --- an instance of `Utils.World` can be accessed through `World`, +and the player character can be accessed through `World.CurrentPlayer`. + +The default starting scene is `res://Scenes/ArenaExterior.tscn`, and running a +non-map scene may spill out errors from `SupaLidlGame.Utils.World`. Eventually +this will be fixed to allow main menu scenes. ## Attributions diff --git a/README.org b/README.org deleted file mode 100644 index c9fbeef..0000000 --- a/README.org +++ /dev/null @@ -1,8 +0,0 @@ -#+TITLE: SupaLidlGame - -Forsen-related game - -#+attr_html: :style margin-left: auto; margin-right: auto; -[[./Assets/Sprites/Characters/forsen2-portrait.png]] - -[[https://i.ibb.co/t367kD4/baj.gif]] From f5d83414ebc43694127116f72b3696f0db6e58a1 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Thu, 31 Aug 2023 19:52:07 -0700 Subject: [PATCH 03/10] delete old files --- project-todo.org | 39 --------------------------------------- todo.org | 2 -- 2 files changed, 41 deletions(-) delete mode 100644 project-todo.org delete mode 100644 todo.org diff --git a/project-todo.org b/project-todo.org deleted file mode 100644 index 4e6d18e..0000000 --- a/project-todo.org +++ /dev/null @@ -1,39 +0,0 @@ -#+TITLE: SupaLidlGame To-do List - -* STARTED Campfires -DEADLINE: <2022-12-03 Sat> - -* DONE Enemy Spawning - -* DONE Handle Character Death -DEADLINE: <2022-12-04 Sun> - -* Doc Boss - -** DONE Reset possible attacks after each cycle -CLOSED: [2023-07-21 Fri] - -** DONE Attack animations -CLOSED: [2023-07-20 Thu] - -** DONE Boss Music -CLOSED: [2023-07-24 Mon] - -* TODO Boss cards - -* DONE Dialog -CLOSED: [2023-07-25 Tue] - -* TODO Short arena entrance -CLOSED: [2023-08-02 Wed] - -* DONE Video demonstration -CLOSED: [2023-07-25 Tue] - -* TODO Combo Attacks ("Level system") - -** TODO Healing - -** TODO Alt attack - -** TODO Max level diff --git a/todo.org b/todo.org deleted file mode 100644 index d0928cf..0000000 --- a/todo.org +++ /dev/null @@ -1,2 +0,0 @@ -#+title: TODO LIST - From d04679009a290ad0a7ba42489f31be998a48dc28 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Fri, 1 Sep 2023 01:53:04 -0700 Subject: [PATCH 04/10] remove unnecessary comments and print statements --- BoundingBoxes/ConnectorBox.cs | 1 - BoundingBoxes/Hurtbox.cs | 2 -- Characters/Character.cs | 1 - Characters/Player.cs | 8 +------- Entities/DynamicDoor.cs | 1 - Items/Inventory.cs | 1 - Items/Weapons/ProjectileSpawner.cs | 1 - Utils/Physics.cs | 3 --- Utils/World.cs | 2 -- 9 files changed, 1 insertion(+), 19 deletions(-) diff --git a/BoundingBoxes/ConnectorBox.cs b/BoundingBoxes/ConnectorBox.cs index fa962af..049c754 100644 --- a/BoundingBoxes/ConnectorBox.cs +++ b/BoundingBoxes/ConnectorBox.cs @@ -35,7 +35,6 @@ public partial class ConnectorBox : Area2D { BodyEntered += (Node2D body) => { - GD.Print(body.Name + " entered"); if (body is Player && InteractionTrigger is null) { OnInteraction(); diff --git a/BoundingBoxes/Hurtbox.cs b/BoundingBoxes/Hurtbox.cs index 0d661d5..449b3a3 100644 --- a/BoundingBoxes/Hurtbox.cs +++ b/BoundingBoxes/Hurtbox.cs @@ -30,7 +30,6 @@ public partial class Hurtbox : BoundingBox, IFaction { InvincibilityTimer.Timeout += () => { - GD.Print("invincibility off"); Monitorable = true; }; } @@ -77,7 +76,6 @@ public partial class Hurtbox : BoundingBox, IFaction InvincibilityTimer.Start(); //Monitorable = false; SetDeferred("monitorable", false); - GD.Print("invincible"); } EmitSignal( diff --git a/Characters/Character.cs b/Characters/Character.cs index 168b31d..13a5fc7 100644 --- a/Characters/Character.cs +++ b/Characters/Character.cs @@ -344,7 +344,6 @@ public partial class Character : CharacterBody2D, IFaction if (this.GetNode("Effects/HurtSound") is AudioStreamPlayer2D sound) { // very small pitch deviation - GD.Print("hurt sound"); sound.At(GlobalPosition).WithPitchDeviation(0.125f).PlayOneShot(); } diff --git a/Characters/Player.cs b/Characters/Player.cs index 18702fc..16c4a8e 100644 --- a/Characters/Player.cs +++ b/Characters/Player.cs @@ -25,11 +25,6 @@ public sealed partial class Player : Character public override void _Ready() { InteractionRay = GetNode("Direction2D/InteractionRay"); - Death += async (Events.HurtArgs args) => - { - HurtAnimation.Play("death"); - await ToSignal(HurtAnimation, "animation_finished"); - }; base._Ready(); @@ -101,8 +96,7 @@ public sealed partial class Player : Character public override void Die() { - GD.Print("died"); - //base.Die(); + HurtAnimation.Play("death"); } protected override void DrawTarget() diff --git a/Entities/DynamicDoor.cs b/Entities/DynamicDoor.cs index f652586..97e8cd7 100644 --- a/Entities/DynamicDoor.cs +++ b/Entities/DynamicDoor.cs @@ -71,7 +71,6 @@ public partial class DynamicDoor : StaticBody2D { if (anim.TrackGetPath(i) == nodePath) { - GD.Print($"Disabled anim for {nodePath}"); anim.TrackSetEnabled(i, isEnabled); } } diff --git a/Items/Inventory.cs b/Items/Inventory.cs index 56ef5aa..321a9a7 100644 --- a/Items/Inventory.cs +++ b/Items/Inventory.cs @@ -50,7 +50,6 @@ public partial class Inventory : Node2D { if (child is Item item) { - GD.Print("Adding item " + item.Name); AddItem(item); } } diff --git a/Items/Weapons/ProjectileSpawner.cs b/Items/Weapons/ProjectileSpawner.cs index e2cee4b..89cafad 100644 --- a/Items/Weapons/ProjectileSpawner.cs +++ b/Items/Weapons/ProjectileSpawner.cs @@ -92,7 +92,6 @@ public partial class ProjectileSpawner : Ranged for (int i = 0; i < ProjectileCount; i++) { float curDeviation = -i + maxAngleDeviations; - GD.Print(curDeviation); SpawnProjectile(map, target.Rotated(curDeviation * theta)); } } diff --git a/Utils/Physics.cs b/Utils/Physics.cs index 239532a..80fa2e6 100644 --- a/Utils/Physics.cs +++ b/Utils/Physics.cs @@ -23,12 +23,9 @@ public static class Physics var relVel = relIdle + relDir * speed; var relSpeed = relVel.Length(); - GD.Print("Relative velocity: " + relVel); - // get t = time to travel // = (|s2| - |s1|)/(|v2| - |v1|) time = position.DistanceTo(targetPosition) / relSpeed; - GD.Print("Time: " + time); // predict target's position after time t return targetPosition + targetVelocity * time; diff --git a/Utils/World.cs b/Utils/World.cs index 6446b00..6867df1 100644 --- a/Utils/World.cs +++ b/Utils/World.cs @@ -327,8 +327,6 @@ public partial class World : Node public void SpawnPlayer() { // TODO: add max health property - //CurrentPlayer.Health = 100; - //CurrentPlayer.Sprite.Visible = true; if (CurrentMap.SceneFilePath != GlobalState.Stats.SaveMapKey) { LoadScene(GlobalState.Stats.SaveMapKey); From a07642c3af78936d03f1ffc1ad10ac881db62edb Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Sat, 2 Sep 2023 22:53:36 -0700 Subject: [PATCH 05/10] added OpenGL-compatible shaders; solves #13 --- Assets/Sprites/Particles/ParryParticles.tres | 29 +++++++++----- Items/Weapons/DocLance.tscn | 33 +++++----------- Items/Weapons/Pugio.tscn | 39 +++++-------------- Items/Weapons/Sword.tscn | 41 +++++++------------- 4 files changed, 53 insertions(+), 89 deletions(-) diff --git a/Assets/Sprites/Particles/ParryParticles.tres b/Assets/Sprites/Particles/ParryParticles.tres index 7b255aa..5bebde8 100644 --- a/Assets/Sprites/Particles/ParryParticles.tres +++ b/Assets/Sprites/Particles/ParryParticles.tres @@ -1,4 +1,4 @@ -[gd_resource type="ParticleProcessMaterial" load_steps=5 format=3 uid="uid://cbfaqolx1ydvv"] +[gd_resource type="ParticleProcessMaterial" load_steps=7 format=3 uid="uid://cbfaqolx1ydvv"] [sub_resource type="Gradient" id="Gradient_44upg"] offsets = PackedFloat32Array(0, 0.5) @@ -7,16 +7,27 @@ colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0) [sub_resource type="GradientTexture1D" id="GradientTexture1D_droiy"] gradient = SubResource("Gradient_44upg") -[sub_resource type="Curve" id="Curve_4kf4j"] -_data = [Vector2(0, 0.5), 0.0, 0.0, 0, 0, Vector2(0.1, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.5), 0.0, 0.0, 0, 0] -point_count = 3 +[sub_resource type="Curve" id="Curve_mx7gl"] +_data = [Vector2(0, 0.3), 0.0, 0.0, 0, 1, Vector2(1, 0.3), 0.0, 0.0, 1, 0] +point_count = 2 -[sub_resource type="CurveTexture" id="CurveTexture_qqrjb"] -curve = SubResource("Curve_4kf4j") +[sub_resource type="Curve" id="Curve_lfa60"] +_data = [Vector2(0.1, 1), 0.0, -1.75, 0, 1, Vector2(0.5, 0.3), -1.75, 0.0, 1, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_3iug1"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 1, Vector2(1, 1), 0.0, 0.0, 1, 0] +point_count = 2 + +[sub_resource type="CurveXYZTexture" id="CurveXYZTexture_xryvh"] +curve_x = SubResource("Curve_mx7gl") +curve_y = SubResource("Curve_lfa60") +curve_z = SubResource("Curve_3iug1") [resource] emission_shape = 1 emission_sphere_radius = 4.0 +particle_flag_align_y = true particle_flag_disable_z = true spread = 180.0 gravity = Vector3(0, 0, 0) @@ -26,7 +37,7 @@ orbit_velocity_min = 0.0 orbit_velocity_max = 0.0 linear_accel_min = -512.0 linear_accel_max = -512.0 -scale_min = 2.0 -scale_max = 2.0 -scale_curve = SubResource("CurveTexture_qqrjb") +scale_min = 0.1 +scale_max = 0.1 +scale_curve = SubResource("CurveXYZTexture_xryvh") color_ramp = SubResource("GradientTexture1D_droiy") diff --git a/Items/Weapons/DocLance.tscn b/Items/Weapons/DocLance.tscn index 0ad753e..0225d38 100644 --- a/Items/Weapons/DocLance.tscn +++ b/Items/Weapons/DocLance.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://p7oijq6dbvvk"] +[gd_scene load_steps=22 format=3 uid="uid://p7oijq6dbvvk"] [ext_resource type="Script" path="res://Items/Weapons/Sword.cs" id="1_1oyma"] [ext_resource type="Script" path="res://State/Weapon/WeaponStateMachine.cs" id="2_c41ov"] @@ -6,6 +6,7 @@ [ext_resource type="Script" path="res://State/Weapon/SwordAnticipateState.cs" id="4_t7af2"] [ext_resource type="Script" path="res://State/Weapon/SwordAttackState.cs" id="5_i5v42"] [ext_resource type="Texture2D" uid="uid://o7enu13gvji5" path="res://Assets/Sprites/doc-lance.png" id="6_7t87o"] +[ext_resource type="Texture2D" uid="uid://d75jkoev5v3w" path="res://Assets/Sprites/Particles/circle-64.png" id="8_gufhv"] [ext_resource type="Material" uid="uid://cbfaqolx1ydvv" path="res://Assets/Sprites/Particles/ParryParticles.tres" id="8_y2qyn"] [ext_resource type="PackedScene" uid="uid://du5vhccg75nrq" path="res://BoundingBoxes/Hitbox.tscn" id="9_buajm"] [ext_resource type="Texture2D" uid="uid://cmvh6pc71ir1m" path="res://Assets/Sprites/sword-swing-large.png" id="11_46l1i"] @@ -183,46 +184,33 @@ _data = { [sub_resource type="RectangleShape2D" id="RectangleShape2D_rrgwb"] size = Vector2(10, 34) -[node name="DocLance" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] +[node name="DocLance" type="Node2D"] y_sort_enabled = true texture_filter = 3 script = ExtResource("1_1oyma") -Hitbox = NodePath("Hitbox") -AnimationPlayer = NodePath("AnimationPlayer") AttackTime = 0.2 AttackAnimationDuration = 0.75 -ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles") NPCAnticipateTime = 0.3 -StateMachine = NodePath("State") -Anchor = NodePath("Anchor") Damage = 20.0 UseTime = 0.55 Knockback = 64.0 ShouldHideIdle = true -HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand") ItemName = "VSM-93" Description = "\"Violence. Speed. Momentum.\"" -[node name="State" type="Node" parent="." node_paths=PackedStringArray("InitialState")] +[node name="State" type="Node" parent="."] script = ExtResource("2_c41ov") -InitialState = NodePath("Idle") UsedItemStates = Array[NodePath]([NodePath("Attack")]) DeusedItemStates = Array[NodePath]([NodePath("Idle")]) -[node name="Idle" type="Node" parent="State" node_paths=PackedStringArray("UseState", "Sword")] +[node name="Idle" type="Node" parent="State"] script = ExtResource("3_sxffm") -UseState = NodePath("../Anticipate") -Sword = NodePath("../..") -[node name="Anticipate" type="Node" parent="State" node_paths=PackedStringArray("Sword", "AttackState")] +[node name="Anticipate" type="Node" parent="State"] script = ExtResource("4_t7af2") -Sword = NodePath("../..") -AttackState = NodePath("../Attack") -[node name="Attack" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState")] +[node name="Attack" type="Node" parent="State"] script = ExtResource("5_i5v42") -Sword = NodePath("../..") -IdleState = NodePath("../Idle") [node name="Anchor" type="Node2D" parent="."] y_sort_enabled = true @@ -239,17 +227,14 @@ texture = ExtResource("6_7t87o") [node name="ParryParticles" type="GPUParticles2D" parent="Anchor/Node2D/Sprite2D"] modulate = Color(1.2, 1.2, 1.2, 1) -position = Vector2(-0.221825, -3.12132) +position = Vector2(0, -3) rotation = 0.785398 -emitting = false amount = 16 process_material = ExtResource("8_y2qyn") +texture = ExtResource("8_gufhv") lifetime = 2.0 one_shot = true explosiveness = 1.0 -trail_enabled = true -trail_lifetime = 0.1 -trail_sections = 4 [node name="GPUParticles2D" type="GPUParticles2D" parent="Anchor/Node2D/Sprite2D"] position = Vector2(-2.28882e-05, -6) diff --git a/Items/Weapons/Pugio.tscn b/Items/Weapons/Pugio.tscn index eb037f8..a3f393a 100644 --- a/Items/Weapons/Pugio.tscn +++ b/Items/Weapons/Pugio.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=28 format=3 uid="uid://5y1acxl4j4n7"] +[gd_scene load_steps=29 format=3 uid="uid://5y1acxl4j4n7"] [ext_resource type="Script" path="res://Items/Weapons/Sword.cs" id="1_mai31"] [ext_resource type="Script" path="res://State/Weapon/WeaponStateMachine.cs" id="2_5ramr"] @@ -8,6 +8,7 @@ [ext_resource type="Texture2D" uid="uid://dfpe74vxvuwal" path="res://Assets/Sprites/Items/pugio.png" id="6_d28k5"] [ext_resource type="Script" path="res://State/Weapon/SwordBlockState.cs" id="6_yvm8x"] [ext_resource type="Material" uid="uid://cbfaqolx1ydvv" path="res://Assets/Sprites/Particles/ParryParticles.tres" id="8_we1sv"] +[ext_resource type="Texture2D" uid="uid://d75jkoev5v3w" path="res://Assets/Sprites/Particles/circle-64.png" id="9_3p5s2"] [ext_resource type="AudioStream" uid="uid://m1sbk3c4eask" path="res://Assets/Sounds/metal-bash2.wav" id="9_b6yro"] [ext_resource type="PackedScene" uid="uid://du5vhccg75nrq" path="res://BoundingBoxes/Hitbox.tscn" id="9_qimey"] [ext_resource type="AudioStream" uid="uid://kao8wbfaum27" path="res://Assets/Sounds/metal-bash3.wav" id="10_istfq"] @@ -369,52 +370,35 @@ shader_parameter/color = Quaternion(1, 1, 1, 1) shader_parameter/intensity = 0.0 shader_parameter/alpha_modulate = 1.0 -[node name="Pugio" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] +[node name="Pugio" type="Node2D"] y_sort_enabled = true texture_filter = 3 script = ExtResource("1_mai31") -Hitbox = NodePath("Hitbox") -AnimationPlayer = NodePath("AnimationPlayer") AttackTime = 0.2 AttackAltTime = 0.75 AttackAnimationDuration = 0.5 -ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles") NPCAnticipateTime = 0.3 -StateMachine = NodePath("State") -Anchor = NodePath("Anchor") Damage = 20.0 UseTime = 0.55 UseAltTime = 1.5 Knockback = 64.0 -HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand") -[node name="State" type="Node" parent="." node_paths=PackedStringArray("InitialState")] +[node name="State" type="Node" parent="."] script = ExtResource("2_5ramr") -InitialState = NodePath("Idle") UsedItemStates = Array[NodePath]([NodePath("Attack"), NodePath("Block")]) DeusedItemStates = Array[NodePath]([NodePath("Idle")]) -[node name="Idle" type="Node" parent="State" node_paths=PackedStringArray("UseState", "UseAltState", "Sword")] +[node name="Idle" type="Node" parent="State"] script = ExtResource("3_fwkit") -UseState = NodePath("../Anticipate") -UseAltState = NodePath("../Block") -Sword = NodePath("../..") -[node name="Anticipate" type="Node" parent="State" node_paths=PackedStringArray("Sword", "AttackState")] +[node name="Anticipate" type="Node" parent="State"] script = ExtResource("4_nsn1q") -Sword = NodePath("../..") -AttackState = NodePath("../Attack") -[node name="Attack" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState")] +[node name="Attack" type="Node" parent="State"] script = ExtResource("5_g1en5") -Sword = NodePath("../..") -IdleState = NodePath("../Idle") -[node name="Block" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState", "UseState")] +[node name="Block" type="Node" parent="State"] script = ExtResource("6_yvm8x") -Sword = NodePath("../..") -IdleState = NodePath("../Idle") -UseState = NodePath("../Anticipate") BlockAnimKey = "block" [node name="WorldEnvironment" type="WorldEnvironment" parent="."] @@ -435,17 +419,14 @@ texture = ExtResource("6_d28k5") [node name="ParryParticles" type="GPUParticles2D" parent="Anchor/Node2D/Sprite2D"] modulate = Color(1.2, 1.2, 1.2, 1) -position = Vector2(-0.221825, -3.12132) +position = Vector2(0, -3) rotation = 0.785398 -emitting = false amount = 16 process_material = ExtResource("8_we1sv") +texture = ExtResource("9_3p5s2") lifetime = 2.0 one_shot = true explosiveness = 1.0 -trail_enabled = true -trail_lifetime = 0.1 -trail_sections = 4 [node name="Hand" type="Sprite2D" parent="Anchor/Node2D/Sprite2D"] position = Vector2(-2.52724e-05, 7) diff --git a/Items/Weapons/Sword.tscn b/Items/Weapons/Sword.tscn index daf9f45..2c7bb84 100644 --- a/Items/Weapons/Sword.tscn +++ b/Items/Weapons/Sword.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=36 format=3 uid="uid://dvqap2uhcah63"] +[gd_scene load_steps=37 format=3 uid="uid://dvqap2uhcah63"] [ext_resource type="Script" path="res://Items/Weapons/Sword.cs" id="1_mlo73"] [ext_resource type="Script" path="res://State/Weapon/WeaponStateMachine.cs" id="2_vwirq"] @@ -10,6 +10,7 @@ [ext_resource type="Script" path="res://State/Weapon/SwordAttackState.cs" id="5_hmisb"] [ext_resource type="AudioStream" uid="uid://c4n7ioxpukdwi" path="res://Assets/Sounds/parry.wav" id="6_8nxjm"] [ext_resource type="Material" uid="uid://cbfaqolx1ydvv" path="res://Assets/Sprites/Particles/ParryParticles.tres" id="8_10gir"] +[ext_resource type="Texture2D" uid="uid://d75jkoev5v3w" path="res://Assets/Sprites/Particles/circle-64.png" id="9_o34ry"] [ext_resource type="Shape2D" uid="uid://dw4e4r2yxwk1b" path="res://Items/Weapons/SwordCollisionShape.tres" id="9_wsprl"] [ext_resource type="Texture2D" uid="uid://cmvh6pc71ir1m" path="res://Assets/Sprites/sword-swing-large.png" id="10_672jv"] [ext_resource type="AudioStream" uid="uid://qvthq6tppp63" path="res://Assets/Sounds/whoosh.wav" id="10_mfnl7"] @@ -353,44 +354,31 @@ graph_offset = Vector2(0, -104.073) [sub_resource type="AnimationNodeStateMachinePlayback" id="AnimationNodeStateMachinePlayback_37556"] -[node name="Sword" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] +[node name="Sword" type="Node2D"] y_sort_enabled = true texture_filter = 3 script = ExtResource("1_mlo73") -Hitbox = NodePath("Hitbox") -AnimationPlayer = NodePath("AnimationPlayer") AttackTime = 0.2 AttackAnimationDuration = 0.75 -ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles") NPCAnticipateTime = 0.3 -StateMachine = NodePath("State") -Anchor = NodePath("Anchor") Damage = 20.0 UseTime = 0.55 Knockback = 64.0 ShouldHideIdle = true -HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand") -[node name="State" type="Node" parent="." node_paths=PackedStringArray("InitialState")] +[node name="State" type="Node" parent="."] script = ExtResource("2_vwirq") -InitialState = NodePath("Idle") UsedItemStates = Array[NodePath]([NodePath("Attack")]) DeusedItemStates = Array[NodePath]([NodePath("Idle")]) -[node name="Idle" type="Node" parent="State" node_paths=PackedStringArray("UseState", "Sword")] +[node name="Idle" type="Node" parent="State"] script = ExtResource("3_nw6r0") -UseState = NodePath("../Anticipate") -Sword = NodePath("../..") -[node name="Anticipate" type="Node" parent="State" node_paths=PackedStringArray("Sword", "AttackState")] +[node name="Anticipate" type="Node" parent="State"] script = ExtResource("4_j3cud") -Sword = NodePath("../..") -AttackState = NodePath("../Attack") -[node name="Attack" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState")] +[node name="Attack" type="Node" parent="State"] script = ExtResource("5_hmisb") -Sword = NodePath("../..") -IdleState = NodePath("../Idle") [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_72txp") @@ -414,23 +402,22 @@ y_sort_enabled = true position = Vector2(0, -8) texture = ExtResource("3_r75ni") +[node name="Hand" type="Sprite2D" parent="Anchor/Node2D/Sprite2D"] +position = Vector2(-2.52724e-05, 7) +rotation = 1.5708 + [node name="ParryParticles" type="GPUParticles2D" parent="Anchor/Node2D/Sprite2D"] modulate = Color(1.2, 1.2, 1.2, 1) -position = Vector2(-0.221825, -3.12132) +position = Vector2(0, -3) rotation = 0.785398 emitting = false amount = 16 process_material = ExtResource("8_10gir") +texture = ExtResource("9_o34ry") lifetime = 2.0 one_shot = true explosiveness = 1.0 -trail_enabled = true -trail_lifetime = 0.1 -trail_sections = 4 - -[node name="Hand" type="Sprite2D" parent="Anchor/Node2D/Sprite2D"] -position = Vector2(-2.52724e-05, 7) -rotation = 1.5708 +fixed_fps = 16 [node name="AnimationPlayer" type="AnimationPlayer" parent="."] libraries = { From 385ed4ffdbc0fd40eb22e91a4d1b4147361cf6dd Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Sun, 3 Sep 2023 17:42:32 -0700 Subject: [PATCH 06/10] leveling up --- BoundingBoxes/Hurtbox.cs | 3 + Characters/Character.cs | 26 +++++++ Characters/Player.cs | 7 +- Characters/Player.tscn | 14 +++- Entities/Projectile.cs | 6 +- Entities/ShungiteSpike.cs | 1 + Events/EventBus.cs | 16 ++++ Events/HitArgs.cs | 6 ++ Exceptions/MultipleSingletonsException.cs | 6 ++ Items/Weapon.cs | 3 + Items/Weapons/ProjectileSpawner.cs | 3 + Items/Weapons/Pugio.tscn | 30 ++++++-- Items/Weapons/Shotgun.tscn | 1 + Items/Weapons/Sword.cs | 6 +- Items/Weapons/Sword.tscn | 24 ++++-- UI/Base.tscn | 21 ++++- UI/LevelBar.cs | 36 +++++++++ UI/LevelBar.tscn | 94 +++++++++++++++++++++++ Utils/PlayerStats.cs | 75 ++++++++++++++++++ Utils/Values/DoubleValue.cs | 22 ++++++ Utils/Values/FloatValue.cs | 22 ++++++ Utils/Values/IValue.cs | 8 ++ Utils/Values/IntValue.cs | 22 ++++++ 23 files changed, 433 insertions(+), 19 deletions(-) create mode 100644 Events/HitArgs.cs create mode 100644 Exceptions/MultipleSingletonsException.cs create mode 100644 UI/LevelBar.cs create mode 100644 UI/LevelBar.tscn create mode 100644 Utils/PlayerStats.cs create mode 100644 Utils/Values/DoubleValue.cs create mode 100644 Utils/Values/FloatValue.cs create mode 100644 Utils/Values/IValue.cs create mode 100644 Utils/Values/IntValue.cs diff --git a/BoundingBoxes/Hurtbox.cs b/BoundingBoxes/Hurtbox.cs index 449b3a3..fd67c0b 100644 --- a/BoundingBoxes/Hurtbox.cs +++ b/BoundingBoxes/Hurtbox.cs @@ -11,6 +11,7 @@ public partial class Hurtbox : BoundingBox, IFaction float damage, Character inflictor, float knockback, + Items.Weapon weapon = null, Vector2 knockbackDir = default); /// @@ -39,6 +40,7 @@ public partial class Hurtbox : BoundingBox, IFaction float damage, Character inflictor, float knockback, + Items.Weapon weapon = default, Vector2 knockbackOrigin = default, Vector2 knockbackVector = default) { @@ -83,6 +85,7 @@ public partial class Hurtbox : BoundingBox, IFaction damage, inflictor, knockback, + weapon, knockbackDir); } } diff --git a/Characters/Character.cs b/Characters/Character.cs index 13a5fc7..2fec6b9 100644 --- a/Characters/Character.cs +++ b/Characters/Character.cs @@ -308,6 +308,7 @@ public partial class Character : CharacterBody2D, IFaction float damage, Character inflictor, float knockback, + Weapon weapon = null, Vector2 knockbackDir = default) { if (Health <= 0) @@ -352,11 +353,17 @@ public partial class Character : CharacterBody2D, IFaction Attacker = inflictor, OldHealth = oldHealth, NewHealth = Health, + Weapon = weapon, Damage = damage, }; EmitSignal(SignalName.Hurt, args); + if (inflictor is Player) + { + EmitPlayerHitSignal(args); + } + if (Health <= 0) { EmitSignal(SignalName.Death, args); @@ -366,6 +373,25 @@ public partial class Character : CharacterBody2D, IFaction } } + /// + /// Converts a HurtArgs to HitArgs if the attacker was a player and emits + /// the EventBus.PlayerHit signal. + /// + private void EmitPlayerHitSignal(Events.HurtArgs args) + { + var newArgs = new Events.HitArgs + { + OldHealth = args.OldHealth, + NewHealth = args.NewHealth, + Damage = args.Damage, + Weapon = args.Weapon, + Victim = this, + }; + + var bus = Events.EventBus.Instance; + bus.EmitSignal(Events.EventBus.SignalName.PlayerHit, newArgs); + } + #if DEBUG /// /// For debugging purposes diff --git a/Characters/Player.cs b/Characters/Player.cs index 16c4a8e..4b8bed9 100644 --- a/Characters/Player.cs +++ b/Characters/Player.cs @@ -81,6 +81,7 @@ public sealed partial class Player : Character float damage, Character inflictor, float knockback, + Items.Weapon weapon = null, Vector2 knockbackDir = default) { if (damage >= 10 && IsAlive) @@ -91,7 +92,11 @@ public sealed partial class Player : Character GetNode("Effects/HurtParticles") .SetDirection(knockbackDir); - base.OnReceivedDamage(damage, inflictor, knockback, knockbackDir); + base.OnReceivedDamage(damage, + inflictor, + knockback, + weapon, + knockbackDir); } public override void Die() diff --git a/Characters/Player.tscn b/Characters/Player.tscn index a4a7122..855c060 100644 --- a/Characters/Player.tscn +++ b/Characters/Player.tscn @@ -1,12 +1,15 @@ -[gd_scene load_steps=63 format=3 uid="uid://b2254pup8k161"] +[gd_scene load_steps=66 format=3 uid="uid://b2254pup8k161"] [ext_resource type="Script" path="res://Characters/Player.cs" id="1_flygr"] [ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_ngsgt"] [ext_resource type="Texture2D" uid="uid://dpepm54hjuyga" path="res://Assets/Sprites/Characters/forsen-hand.png" id="3_3dqh7"] [ext_resource type="Texture2D" uid="uid://bej8thq7ruyty" path="res://Assets/Sprites/Characters/forsen2.png" id="4_5vird"] +[ext_resource type="Script" path="res://Utils/PlayerStats.cs" id="4_06oya"] [ext_resource type="PackedScene" uid="uid://cl56eadpklnbo" path="res://Utils/PlayerCamera.tscn" id="4_ym125"] [ext_resource type="Script" path="res://State/Character/CharacterStateMachine.cs" id="5_rgckv"] +[ext_resource type="Script" path="res://Utils/Values/DoubleValue.cs" id="5_txl0r"] [ext_resource type="Script" path="res://State/Character/CharacterDashState.cs" id="6_rft7p"] +[ext_resource type="Script" path="res://Utils/Values/IntValue.cs" id="6_sunc5"] [ext_resource type="Script" path="res://State/Character/PlayerIdleState.cs" id="6_wkfdm"] [ext_resource type="PackedScene" uid="uid://dvqap2uhcah63" path="res://Items/Weapons/Sword.tscn" id="7_4rxuv"] [ext_resource type="Script" path="res://State/Character/PlayerMoveState.cs" id="7_dfqd8"] @@ -331,6 +334,15 @@ StateMachine = NodePath("StateMachine") Hurtbox = NodePath("Hurtbox") Faction = 1 +[node name="Stats" type="Node" parent="."] +script = ExtResource("4_06oya") + +[node name="XP" type="Node" parent="Stats"] +script = ExtResource("5_txl0r") + +[node name="Level" type="Node" parent="Stats"] +script = ExtResource("6_sunc5") + [node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("InitialState", "Character")] script = ExtResource("5_rgckv") InitialState = NodePath("Idle") diff --git a/Entities/Projectile.cs b/Entities/Projectile.cs index 0eaf7bf..5f09fa5 100644 --- a/Entities/Projectile.cs +++ b/Entities/Projectile.cs @@ -43,8 +43,11 @@ public partial class Projectile : RigidBody2D [Export] public double Delay { get; set; } = 0; + [System.Obsolete] public Character Character { get; set; } + public Items.Weapon Weapon { get; set; } + public bool IsDead { get; set; } public override void _Ready() @@ -87,8 +90,9 @@ public partial class Projectile : RigidBody2D { hurtbox.InflictDamage( Hitbox.Damage, - Character, + Hitbox.Inflictor, Hitbox.Knockback, + weapon: Weapon, knockbackVector: Direction ); EmitSignal(SignalName.Hit, box); diff --git a/Entities/ShungiteSpike.cs b/Entities/ShungiteSpike.cs index 26fc2a2..983241a 100644 --- a/Entities/ShungiteSpike.cs +++ b/Entities/ShungiteSpike.cs @@ -63,6 +63,7 @@ public partial class ShungiteSpike : Projectile float damage, Characters.Character inflictor, float knockback, + Items.Weapon weapon, Vector2 knockbackDir) { // if we were hit by the player before the spike freezes, diff --git a/Events/EventBus.cs b/Events/EventBus.cs index 9f719b1..24835a2 100644 --- a/Events/EventBus.cs +++ b/Events/EventBus.cs @@ -4,6 +4,8 @@ namespace SupaLidlGame.Events; public partial class EventBus : Node { + public static EventBus Instance { get; private set; } + [Signal] public delegate void RequestMoveToAreaEventHandler(RequestAreaArgs args); @@ -16,6 +18,15 @@ public partial class EventBus : Node [Signal] public delegate void PlayerHurtEventHandler(HurtArgs args); + [Signal] + public delegate void PlayerHitEventHandler(HitArgs args); + + [Signal] + public delegate void PlayerXPChangedEventHandler(double xp); + + [Signal] + public delegate void PlayerLevelChangedEventHandler(int level); + [Signal] public delegate void PlayerHealthChangedEventHandler(HealthChangedArgs args); @@ -37,5 +48,10 @@ public partial class EventBus : Node public override void _Ready() { ProcessMode = ProcessModeEnum.Always; + if (Instance is not null) + { + throw new MultipleSingletonsException(); + } + Instance = this; } } diff --git a/Events/HitArgs.cs b/Events/HitArgs.cs new file mode 100644 index 0000000..e00ee82 --- /dev/null +++ b/Events/HitArgs.cs @@ -0,0 +1,6 @@ +namespace SupaLidlGame.Events; + +public partial class HitArgs : HurtArgs +{ + public Characters.Character Victim { get; set; } +} diff --git a/Exceptions/MultipleSingletonsException.cs b/Exceptions/MultipleSingletonsException.cs new file mode 100644 index 0000000..0ab3b1f --- /dev/null +++ b/Exceptions/MultipleSingletonsException.cs @@ -0,0 +1,6 @@ +namespace SupaLidlGame; + +public class MultipleSingletonsException : System.Exception +{ + +} diff --git a/Items/Weapon.cs b/Items/Weapon.cs index 29146b5..ea4475c 100644 --- a/Items/Weapon.cs +++ b/Items/Weapon.cs @@ -60,6 +60,9 @@ public abstract partial class Weapon : Item [Export] public float MaxDistanceHint { get; set; } + [Export] + public float PlayerLevelGain { get; set; } + [Export] public Sprite2D HandAnchor { get; set; } diff --git a/Items/Weapons/ProjectileSpawner.cs b/Items/Weapons/ProjectileSpawner.cs index 89cafad..61e3b9d 100644 --- a/Items/Weapons/ProjectileSpawner.cs +++ b/Items/Weapons/ProjectileSpawner.cs @@ -49,6 +49,9 @@ public partial class ProjectileSpawner : Ranged } } + projectile.Hitbox.Inflictor = Character; + projectile.Weapon = this; + if (projectile is Utils.ITarget target) { if (Character is Characters.NPC npc) diff --git a/Items/Weapons/Pugio.tscn b/Items/Weapons/Pugio.tscn index a3f393a..f73fc2e 100644 --- a/Items/Weapons/Pugio.tscn +++ b/Items/Weapons/Pugio.tscn @@ -370,35 +370,53 @@ shader_parameter/color = Quaternion(1, 1, 1, 1) shader_parameter/intensity = 0.0 shader_parameter/alpha_modulate = 1.0 -[node name="Pugio" type="Node2D"] +[node name="Pugio" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] y_sort_enabled = true texture_filter = 3 script = ExtResource("1_mai31") +Hitbox = NodePath("Hitbox") +AnimationPlayer = NodePath("AnimationPlayer") AttackTime = 0.2 AttackAltTime = 0.75 AttackAnimationDuration = 0.5 +ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles") NPCAnticipateTime = 0.3 +StateMachine = NodePath("State") +Anchor = NodePath("Anchor") Damage = 20.0 UseTime = 0.55 UseAltTime = 1.5 Knockback = 64.0 +PlayerLevelGain = 1.0 +HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand") -[node name="State" type="Node" parent="."] +[node name="State" type="Node" parent="." node_paths=PackedStringArray("InitialState")] script = ExtResource("2_5ramr") +InitialState = NodePath("Idle") UsedItemStates = Array[NodePath]([NodePath("Attack"), NodePath("Block")]) DeusedItemStates = Array[NodePath]([NodePath("Idle")]) -[node name="Idle" type="Node" parent="State"] +[node name="Idle" type="Node" parent="State" node_paths=PackedStringArray("UseState", "UseAltState", "Sword")] script = ExtResource("3_fwkit") +UseState = NodePath("../Anticipate") +UseAltState = NodePath("../Block") +Sword = NodePath("../..") -[node name="Anticipate" type="Node" parent="State"] +[node name="Anticipate" type="Node" parent="State" node_paths=PackedStringArray("Sword", "AttackState")] script = ExtResource("4_nsn1q") +Sword = NodePath("../..") +AttackState = NodePath("../Attack") -[node name="Attack" type="Node" parent="State"] +[node name="Attack" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState")] script = ExtResource("5_g1en5") +Sword = NodePath("../..") +IdleState = NodePath("../Idle") -[node name="Block" type="Node" parent="State"] +[node name="Block" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState", "UseState")] script = ExtResource("6_yvm8x") +Sword = NodePath("../..") +IdleState = NodePath("../Idle") +UseState = NodePath("../Anticipate") BlockAnimKey = "block" [node name="WorldEnvironment" type="WorldEnvironment" parent="."] diff --git a/Items/Weapons/Shotgun.tscn b/Items/Weapons/Shotgun.tscn index 9fcd5d5..1f84f6d 100644 --- a/Items/Weapons/Shotgun.tscn +++ b/Items/Weapons/Shotgun.tscn @@ -258,6 +258,7 @@ StateMachine = NodePath("State") Damage = 12.0 UseTime = 1.5 InitialVelocity = 220.0 +PlayerLevelGain = 0.5 [node name="State" type="Node" parent="." node_paths=PackedStringArray("InitialState")] script = ExtResource("2_ag6rd") diff --git a/Items/Weapons/Sword.cs b/Items/Weapons/Sword.cs index 76a1964..07a7351 100644 --- a/Items/Weapons/Sword.cs +++ b/Items/Weapons/Sword.cs @@ -191,7 +191,11 @@ public partial class Sword : Weapon, IParryable { if (box is Hurtbox hurtbox) { - hurtbox.InflictDamage(Damage, Character, Knockback); + hurtbox.InflictDamage( + Damage, + Character, + Knockback, + this); } } } diff --git a/Items/Weapons/Sword.tscn b/Items/Weapons/Sword.tscn index 2c7bb84..3da3286 100644 --- a/Items/Weapons/Sword.tscn +++ b/Items/Weapons/Sword.tscn @@ -354,31 +354,45 @@ graph_offset = Vector2(0, -104.073) [sub_resource type="AnimationNodeStateMachinePlayback" id="AnimationNodeStateMachinePlayback_37556"] -[node name="Sword" type="Node2D"] +[node name="Sword" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] y_sort_enabled = true texture_filter = 3 script = ExtResource("1_mlo73") +Hitbox = NodePath("Hitbox") +AnimationPlayer = NodePath("AnimationPlayer") AttackTime = 0.2 AttackAnimationDuration = 0.75 +ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles") NPCAnticipateTime = 0.3 +StateMachine = NodePath("State") +Anchor = NodePath("Anchor") Damage = 20.0 UseTime = 0.55 Knockback = 64.0 ShouldHideIdle = true +PlayerLevelGain = 1.0 +HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand") -[node name="State" type="Node" parent="."] +[node name="State" type="Node" parent="." node_paths=PackedStringArray("InitialState")] script = ExtResource("2_vwirq") +InitialState = NodePath("Idle") UsedItemStates = Array[NodePath]([NodePath("Attack")]) DeusedItemStates = Array[NodePath]([NodePath("Idle")]) -[node name="Idle" type="Node" parent="State"] +[node name="Idle" type="Node" parent="State" node_paths=PackedStringArray("UseState", "Sword")] script = ExtResource("3_nw6r0") +UseState = NodePath("../Anticipate") +Sword = NodePath("../..") -[node name="Anticipate" type="Node" parent="State"] +[node name="Anticipate" type="Node" parent="State" node_paths=PackedStringArray("Sword", "AttackState")] script = ExtResource("4_j3cud") +Sword = NodePath("../..") +AttackState = NodePath("../Attack") -[node name="Attack" type="Node" parent="State"] +[node name="Attack" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState")] script = ExtResource("5_hmisb") +Sword = NodePath("../..") +IdleState = NodePath("../Idle") [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_72txp") diff --git a/UI/Base.tscn b/UI/Base.tscn index db8df23..ad628a7 100644 --- a/UI/Base.tscn +++ b/UI/Base.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://c271rdjhd1gfo"] +[gd_scene load_steps=8 format=3 uid="uid://c271rdjhd1gfo"] [ext_resource type="PackedScene" uid="uid://73jm5qjy52vq" path="res://Dialogue/balloon.tscn" id="1_atjb1"] [ext_resource type="Script" path="res://UI/UIController.cs" id="2_b4b6l"] [ext_resource type="PackedScene" uid="uid://bxo553hblp6nf" path="res://UI/HealthBar.tscn" id="3_j1j6h"] [ext_resource type="PackedScene" uid="uid://01d24ij5av1y" path="res://UI/BossBar.tscn" id="4_igi28"] +[ext_resource type="PackedScene" uid="uid://cr7tkxctmyags" path="res://UI/LevelBar.tscn" id="4_rcekd"] [ext_resource type="PackedScene" uid="uid://c77754nvmckn" path="res://UI/LocationDisplay.tscn" id="5_cr6vo"] [ext_resource type="PackedScene" uid="uid://d3q1yu3n7cqfj" path="res://UI/SceneTransition.tscn" id="6_j0nhv"] @@ -47,7 +48,7 @@ BossBar = NodePath("Bottom/BossBar") layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 -offset_bottom = 40.0 +offset_bottom = 64.0 grow_horizontal = 2 [node name="Margin" type="MarginContainer" parent="SubViewportContainer/UIViewport/MainUILayer/Main/Top"] @@ -55,9 +56,21 @@ layout_mode = 2 theme_override_constants/margin_left = 16 theme_override_constants/margin_top = 16 -[node name="HealthBar" parent="SubViewportContainer/UIViewport/MainUILayer/Main/Top/Margin" instance=ExtResource("3_j1j6h")] +[node name="VBoxContainer" type="VBoxContainer" parent="SubViewportContainer/UIViewport/MainUILayer/Main/Top/Margin"] layout_mode = 2 -size_flags_horizontal = 3 +theme_override_constants/separation = 12 + +[node name="HealthBar" parent="SubViewportContainer/UIViewport/MainUILayer/Main/Top/Margin/VBoxContainer" instance=ExtResource("3_j1j6h")] +layout_mode = 2 + +[node name="LevelBar" parent="SubViewportContainer/UIViewport/MainUILayer/Main/Top/Margin/VBoxContainer" instance=ExtResource("4_rcekd")] +layout_mode = 2 + +[node name="Margin2" type="MarginContainer" parent="SubViewportContainer/UIViewport/MainUILayer/Main/Top/Margin/VBoxContainer"] +visible = false +layout_mode = 2 +theme_override_constants/margin_left = 16 +theme_override_constants/margin_top = 16 [node name="Bottom" type="HBoxContainer" parent="SubViewportContainer/UIViewport/MainUILayer/Main"] layout_mode = 1 diff --git a/UI/LevelBar.cs b/UI/LevelBar.cs new file mode 100644 index 0000000..cf08429 --- /dev/null +++ b/UI/LevelBar.cs @@ -0,0 +1,36 @@ +using Godot; +using SupaLidlGame.Events; + +namespace SupaLidlGame.UI; + +public partial class LevelBar : Control +{ + public TextureProgressBar XPBar { get; set; } + + private TextureProgressBar[] _levelBars = new TextureProgressBar[4]; + + public override void _Ready() + { + XPBar = GetNode("%XPBar"); + + for (int i = 0; i < 4; i++) + { + _levelBars[i] = GetNode($"%Level{i + 1}Bar"); + } + + EventBus.Instance.PlayerXPChanged += (xp) => + { + XPBar.Value = xp; + }; + + EventBus.Instance.PlayerLevelChanged += (level) => + { + for (int i = 0; i < _levelBars.Length; i++) + { + // level 0: 0 is not less than 0 + // level 1: 0 is less than 1 + _levelBars[i].Value = i < level ? 1 : 0; + } + }; + } +} diff --git a/UI/LevelBar.tscn b/UI/LevelBar.tscn new file mode 100644 index 0000000..eaff566 --- /dev/null +++ b/UI/LevelBar.tscn @@ -0,0 +1,94 @@ +[gd_scene load_steps=4 format=3 uid="uid://cr7tkxctmyags"] + +[ext_resource type="Script" path="res://UI/LevelBar.cs" id="1_eqetx"] +[ext_resource type="Texture2D" uid="uid://b75oak1nd2q6x" path="res://Assets/Sprites/UI/over-under-bar.png" id="2_f332l"] +[ext_resource type="Texture2D" uid="uid://co7xm7i5f6n51" path="res://Assets/Sprites/UI/progress-bar.png" id="3_arvub"] + +[node name="LevelBar" type="Control"] +layout_mode = 3 +anchors_preset = 0 +offset_right = 128.0 +offset_bottom = 8.0 +script = ExtResource("1_eqetx") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 +offset_right = 128.0 +offset_bottom = 8.0 + +[node name="XPBar" type="TextureProgressBar" parent="HBoxContainer"] +unique_name_in_owner = true +texture_filter = 1 +layout_mode = 2 +size_flags_horizontal = 3 +max_value = 4.0 +step = 0.01 +nine_patch_stretch = true +stretch_margin_left = 3 +stretch_margin_top = 3 +stretch_margin_right = 3 +stretch_margin_bottom = 3 +texture_under = ExtResource("2_f332l") +texture_progress = ExtResource("3_arvub") + +[node name="Level1Bar" type="TextureProgressBar" parent="HBoxContainer"] +unique_name_in_owner = true +texture_filter = 1 +layout_mode = 2 +max_value = 1.0 +nine_patch_stretch = true +stretch_margin_left = 3 +stretch_margin_top = 3 +stretch_margin_right = 3 +stretch_margin_bottom = 3 +texture_under = ExtResource("2_f332l") +texture_progress = ExtResource("3_arvub") + +[node name="Level2Bar" type="TextureProgressBar" parent="HBoxContainer"] +unique_name_in_owner = true +texture_filter = 1 +layout_mode = 2 +max_value = 1.0 +nine_patch_stretch = true +stretch_margin_left = 3 +stretch_margin_top = 3 +stretch_margin_right = 3 +stretch_margin_bottom = 3 +texture_under = ExtResource("2_f332l") +texture_progress = ExtResource("3_arvub") + +[node name="Level3Bar" type="TextureProgressBar" parent="HBoxContainer"] +unique_name_in_owner = true +texture_filter = 1 +layout_mode = 2 +max_value = 1.0 +nine_patch_stretch = true +stretch_margin_left = 3 +stretch_margin_top = 3 +stretch_margin_right = 3 +stretch_margin_bottom = 3 +texture_under = ExtResource("2_f332l") +texture_progress = ExtResource("3_arvub") + +[node name="Level4Bar" type="TextureProgressBar" parent="HBoxContainer"] +unique_name_in_owner = true +texture_filter = 1 +layout_mode = 2 +max_value = 1.0 +nine_patch_stretch = true +stretch_margin_left = 3 +stretch_margin_top = 3 +stretch_margin_right = 3 +stretch_margin_bottom = 3 +texture_under = ExtResource("2_f332l") +texture_progress = ExtResource("3_arvub") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/separation = 4 diff --git a/Utils/PlayerStats.cs b/Utils/PlayerStats.cs new file mode 100644 index 0000000..70f51bb --- /dev/null +++ b/Utils/PlayerStats.cs @@ -0,0 +1,75 @@ +using Godot; +using SupaLidlGame.Events; + +namespace SupaLidlGame.Utils; + +public partial class PlayerStats : Node +{ + public const int MAX_XP_PER_LEVEL = 4; + + public const int MAX_LEVELS = 4; + + public DoubleValue XP { get; set; } + + public IntValue Level { get; set; } + + public double XPDecayVelocity { get; set; } = 1; + + protected bool _shouldDecayXP = true; + + protected Timer _xpDecayTimer; + + public override void _Ready() + { + XP = GetNode("XP"); + Level = GetNode("Level"); + + _xpDecayTimer = new Timer(); + _xpDecayTimer.Timeout += () => _shouldDecayXP = true; + _xpDecayTimer.Stop(); + AddChild(_xpDecayTimer); + + var bus = EventBus.Instance; + XP.Changed += (oldValue, newValue) => + { + bus.EmitSignal(EventBus.SignalName.PlayerXPChanged, newValue); + }; + + Level.Changed += (oldValue, newValue) => + { + bus.EmitSignal(EventBus.SignalName.PlayerLevelChanged, newValue); + }; + + bus.PlayerHit += (args) => + { + double xp = XP.Value; + xp += args.Weapon?.PlayerLevelGain ?? 0; + + if (xp >= MAX_XP_PER_LEVEL) + { + int deltaLevel = (int)(xp / MAX_XP_PER_LEVEL); + xp %= MAX_XP_PER_LEVEL; + Level.Value = Mathf.Min(Level.Value + deltaLevel, MAX_LEVELS); + } + + if (Level.Value == MAX_LEVELS) + { + // if max level, can only go up to 1 xp + xp = Mathf.Min(xp, 1); + } + + XP.Value = xp; + + _shouldDecayXP = false; + _xpDecayTimer.Start(1); + }; + } + + public override void _Process(double delta) + { + if (_shouldDecayXP) + { + XP.Value = Mathf.MoveToward(XP.Value, 1, XPDecayVelocity * delta); + } + } +} diff --git a/Utils/Values/DoubleValue.cs b/Utils/Values/DoubleValue.cs new file mode 100644 index 0000000..bad84bb --- /dev/null +++ b/Utils/Values/DoubleValue.cs @@ -0,0 +1,22 @@ +using Godot; + +namespace SupaLidlGame; + +public partial class DoubleValue : Node, IValue +{ + [Signal] + public delegate void ChangedEventHandler(double oldValue, double newValue); + + protected double _value = default; + + [Export] + public double Value + { + get => _value; + set + { + EmitSignal(SignalName.Changed, _value, value); + _value = value; + } + } +} diff --git a/Utils/Values/FloatValue.cs b/Utils/Values/FloatValue.cs new file mode 100644 index 0000000..602beb6 --- /dev/null +++ b/Utils/Values/FloatValue.cs @@ -0,0 +1,22 @@ +using Godot; + +namespace SupaLidlGame; + +public partial class FloatValue : Node, IValue +{ + [Signal] + public delegate void ChangedEventHandler(float oldValue, float newValue); + + protected float _value = default; + + [Export] + public float Value + { + get => _value; + set + { + EmitSignal(SignalName.Changed, _value, value); + _value = value; + } + } +} diff --git a/Utils/Values/IValue.cs b/Utils/Values/IValue.cs new file mode 100644 index 0000000..d44a31e --- /dev/null +++ b/Utils/Values/IValue.cs @@ -0,0 +1,8 @@ +namespace SupaLidlGame; + +public interface IValue +{ + public delegate void ChangedEventHandler(T oldValue, T newValue); + + public T Value { get; set; } +} diff --git a/Utils/Values/IntValue.cs b/Utils/Values/IntValue.cs new file mode 100644 index 0000000..d3975b8 --- /dev/null +++ b/Utils/Values/IntValue.cs @@ -0,0 +1,22 @@ +using Godot; + +namespace SupaLidlGame; + +public partial class IntValue : Node, IValue +{ + [Signal] + public delegate void ChangedEventHandler(int oldValue, int newValue); + + protected int _value = default; + + [Export] + public int Value + { + get => _value; + set + { + EmitSignal(SignalName.Changed, _value, value); + _value = value; + } + } +} From 60cd7cdbc0e15528d033a8f435bc8895af2d48ef Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Sun, 3 Sep 2023 17:47:17 -0700 Subject: [PATCH 07/10] fix lance particles being different color --- Items/Weapons/DocLance.tscn | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Items/Weapons/DocLance.tscn b/Items/Weapons/DocLance.tscn index 0225d38..34af05c 100644 --- a/Items/Weapons/DocLance.tscn +++ b/Items/Weapons/DocLance.tscn @@ -35,7 +35,7 @@ orbit_velocity_max = 0.0 scale_min = 2.0 scale_max = 2.0 scale_curve = SubResource("CurveTexture_383y7") -color = Color(1, 0, 1, 1) +color = Color(0.560784, 0.145098, 0.180392, 1) [sub_resource type="Animation" id="Animation_b7327"] length = 0.001 @@ -184,33 +184,46 @@ _data = { [sub_resource type="RectangleShape2D" id="RectangleShape2D_rrgwb"] size = Vector2(10, 34) -[node name="DocLance" type="Node2D"] +[node name="DocLance" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] y_sort_enabled = true texture_filter = 3 script = ExtResource("1_1oyma") +Hitbox = NodePath("Hitbox") +AnimationPlayer = NodePath("AnimationPlayer") AttackTime = 0.2 AttackAnimationDuration = 0.75 +ParryParticles = NodePath("Anchor/Node2D/Sprite2D/ParryParticles") NPCAnticipateTime = 0.3 +StateMachine = NodePath("State") +Anchor = NodePath("Anchor") Damage = 20.0 UseTime = 0.55 Knockback = 64.0 ShouldHideIdle = true +HandAnchor = NodePath("Anchor/Node2D/Sprite2D/Hand") ItemName = "VSM-93" Description = "\"Violence. Speed. Momentum.\"" -[node name="State" type="Node" parent="."] +[node name="State" type="Node" parent="." node_paths=PackedStringArray("InitialState")] script = ExtResource("2_c41ov") +InitialState = NodePath("Idle") UsedItemStates = Array[NodePath]([NodePath("Attack")]) DeusedItemStates = Array[NodePath]([NodePath("Idle")]) -[node name="Idle" type="Node" parent="State"] +[node name="Idle" type="Node" parent="State" node_paths=PackedStringArray("UseState", "Sword")] script = ExtResource("3_sxffm") +UseState = NodePath("../Anticipate") +Sword = NodePath("../..") -[node name="Anticipate" type="Node" parent="State"] +[node name="Anticipate" type="Node" parent="State" node_paths=PackedStringArray("Sword", "AttackState")] script = ExtResource("4_t7af2") +Sword = NodePath("../..") +AttackState = NodePath("../Attack") -[node name="Attack" type="Node" parent="State"] +[node name="Attack" type="Node" parent="State" node_paths=PackedStringArray("Sword", "IdleState")] script = ExtResource("5_i5v42") +Sword = NodePath("../..") +IdleState = NodePath("../Idle") [node name="Anchor" type="Node2D" parent="."] y_sort_enabled = true @@ -229,6 +242,7 @@ texture = ExtResource("6_7t87o") modulate = Color(1.2, 1.2, 1.2, 1) position = Vector2(0, -3) rotation = 0.785398 +emitting = false amount = 16 process_material = ExtResource("8_y2qyn") texture = ExtResource("8_gufhv") From c964415be25ba6b8538746026e0e0315aac4fc77 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Wed, 6 Sep 2023 22:52:59 -0700 Subject: [PATCH 08/10] remove print statement --- State/Character/PlayerState.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/State/Character/PlayerState.cs b/State/Character/PlayerState.cs index 0c49024..602dd86 100644 --- a/State/Character/PlayerState.cs +++ b/State/Character/PlayerState.cs @@ -34,7 +34,6 @@ public abstract partial class PlayerState : CharacterState if (@event.IsActionPressed("interact")) { // if looking at a trigger then interact with it - GD.Print("interacting"); player.InteractionRay.Trigger?.InvokeInteraction(); } } From f60b2d548d745895e79cfba943765705ff29855d Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Wed, 6 Sep 2023 22:53:39 -0700 Subject: [PATCH 09/10] Player.DesiredTarget property --- Characters/Player.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Characters/Player.cs b/Characters/Player.cs index 4b8bed9..26eab10 100644 --- a/Characters/Player.cs +++ b/Characters/Player.cs @@ -11,6 +11,8 @@ public sealed partial class Player : Character { private string _spriteAnim; + public Vector2 DesiredTarget { get; set; } + [Export] public PlayerCamera Camera { get; set; } @@ -107,9 +109,7 @@ public sealed partial class Player : Character protected override void DrawTarget() { base.DrawTarget(); - DirectionMarker.GlobalRotation = DirectionMarker.GlobalPosition - .DirectionTo(GetGlobalMousePosition()) - .Angle(); + DirectionMarker.GlobalRotation = DesiredTarget.Angle(); } public override void Footstep() From 153132c48da2bdf521a46b3c3c258b45f856c7f4 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Wed, 6 Sep 2023 22:54:20 -0700 Subject: [PATCH 10/10] gl_compatibility rendering --- project.godot | 1 + 1 file changed, 1 insertion(+) diff --git a/project.godot b/project.godot index 55cbffc..64ee799 100644 --- a/project.godot +++ b/project.godot @@ -196,4 +196,5 @@ locale/translations_pot_files=PackedStringArray("res://Assets/Dialog/doc.dialogu [rendering] textures/canvas_textures/default_texture_filter=0 +renderer/rendering_method="gl_compatibility" environment/defaults/default_clear_color=Color(0.301961, 0.301961, 0.301961, 1)