Polished up attacking

This commit is contained in:
Nico 2025-07-01 02:07:12 -07:00
parent f411a52687
commit b8c08c4ab0
4 changed files with 30 additions and 5 deletions

View File

@ -341,7 +341,7 @@ AudioListener:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1568434226}
m_Enabled: 1
m_Enabled: 0
--- !u!20 &1568434228
Camera:
m_ObjectHideFlags: 0

View File

@ -17,7 +17,7 @@ AnimatorStateMachine:
m_Position: {x: 290, y: 100, z: 0}
- serializedVersion: 1
m_State: {fileID: 702953099919513969}
m_Position: {x: 530, y: 50, z: 0}
m_Position: {x: 430, y: 60, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []

View File

@ -16,10 +16,12 @@ public class ClassBase {
protected Animator Animator;
protected Player Player;
protected float PlayerOriginalSpeed;
protected FloatingTextSpawner TextPopUp;
public ClassBase(Player player) {
Player = player;
Animator = Player.Animator;
TextPopUp = new FloatingTextSpawner(player.transform);
}
virtual public void InitializeClass(Player player) {

View File

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@ -15,6 +16,7 @@ public class MeleeFighterClass : ClassBase {
private bool ChargingAnAttack;
private float ChargeValue;
private bool AllowBladeVortex;
private int ChargeTick;
private AttackState CurrentState;
@ -48,14 +50,14 @@ public class MeleeFighterClass : ClassBase {
case AttackState.ChargeSurgeA:
ChargingAnAttack = Input.GetMouseButton(0);
ChargeValue = timeElapsed;
HandleCharging(timeElapsed);
if (!ChargingAnAttack) ChangeState(AttackState.KineticSurgeA);
break;
case AttackState.ChargeSurgeB:
ChargingAnAttack = Input.GetMouseButton(1);
ChargeValue = timeElapsed;
HandleCharging(timeElapsed);
if (!ChargingAnAttack) ChangeState(AttackState.KineticSurgeB);
break;
}
@ -67,6 +69,25 @@ public class MeleeFighterClass : ClassBase {
}
}
private void HandleCharging(float timeElapsed){
ChargeValue = timeElapsed * 60;
if (ChargeValue > 100) ChargeValue = 100;
if (ChargeTick++ > 10) {
ChargeTick = 0;
TextPopUp.SpawnFloatingText($"Charging {ChargeValue:0.0}", GetChargeColor(), 3);
}
}
private Color GetChargeColor() {
ChargeValue = Mathf.Clamp01(ChargeValue / 100f); // Normalize to 01
if (ChargeValue < 0.5f) {
return Color.Lerp(Color.red, Color.yellow, ChargeValue / 0.5f);
} else {
return Color.Lerp(Color.yellow, Color.green, (ChargeValue - 0.5f) / 0.5f);
}
}
override public void HandleLMB() {
@ -134,6 +155,8 @@ public class MeleeFighterClass : ClassBase {
private void ChangeState(AttackState state, float decreasedSpeed = 0.2f, float resetTime = 0.3f) {
if (state != AttackState.None)
TextPopUp.SpawnFloatingText(state.ToString(), Color.red, 3);
CurrentState = state;
ComboResetTime = resetTime;
LastComboTime = Time.time;