Polished up attacking
This commit is contained in:
parent
f411a52687
commit
b8c08c4ab0
@ -341,7 +341,7 @@ AudioListener:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1568434226}
|
m_GameObject: {fileID: 1568434226}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
--- !u!20 &1568434228
|
--- !u!20 &1568434228
|
||||||
Camera:
|
Camera:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -17,7 +17,7 @@ AnimatorStateMachine:
|
|||||||
m_Position: {x: 290, y: 100, z: 0}
|
m_Position: {x: 290, y: 100, z: 0}
|
||||||
- serializedVersion: 1
|
- serializedVersion: 1
|
||||||
m_State: {fileID: 702953099919513969}
|
m_State: {fileID: 702953099919513969}
|
||||||
m_Position: {x: 530, y: 50, z: 0}
|
m_Position: {x: 430, y: 60, z: 0}
|
||||||
m_ChildStateMachines: []
|
m_ChildStateMachines: []
|
||||||
m_AnyStateTransitions: []
|
m_AnyStateTransitions: []
|
||||||
m_EntryTransitions: []
|
m_EntryTransitions: []
|
||||||
|
|||||||
@ -16,10 +16,12 @@ public class ClassBase {
|
|||||||
protected Animator Animator;
|
protected Animator Animator;
|
||||||
protected Player Player;
|
protected Player Player;
|
||||||
protected float PlayerOriginalSpeed;
|
protected float PlayerOriginalSpeed;
|
||||||
|
protected FloatingTextSpawner TextPopUp;
|
||||||
|
|
||||||
public ClassBase(Player player) {
|
public ClassBase(Player player) {
|
||||||
Player = player;
|
Player = player;
|
||||||
Animator = Player.Animator;
|
Animator = Player.Animator;
|
||||||
|
TextPopUp = new FloatingTextSpawner(player.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual public void InitializeClass(Player player) {
|
virtual public void InitializeClass(Player player) {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using JetBrains.Annotations;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -15,6 +16,7 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
private bool ChargingAnAttack;
|
private bool ChargingAnAttack;
|
||||||
private float ChargeValue;
|
private float ChargeValue;
|
||||||
private bool AllowBladeVortex;
|
private bool AllowBladeVortex;
|
||||||
|
private int ChargeTick;
|
||||||
|
|
||||||
|
|
||||||
private AttackState CurrentState;
|
private AttackState CurrentState;
|
||||||
@ -48,14 +50,14 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
|
|
||||||
case AttackState.ChargeSurgeA:
|
case AttackState.ChargeSurgeA:
|
||||||
ChargingAnAttack = Input.GetMouseButton(0);
|
ChargingAnAttack = Input.GetMouseButton(0);
|
||||||
ChargeValue = timeElapsed;
|
HandleCharging(timeElapsed);
|
||||||
if (!ChargingAnAttack) ChangeState(AttackState.KineticSurgeA);
|
if (!ChargingAnAttack) ChangeState(AttackState.KineticSurgeA);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case AttackState.ChargeSurgeB:
|
case AttackState.ChargeSurgeB:
|
||||||
ChargingAnAttack = Input.GetMouseButton(1);
|
ChargingAnAttack = Input.GetMouseButton(1);
|
||||||
ChargeValue = timeElapsed;
|
HandleCharging(timeElapsed);
|
||||||
if (!ChargingAnAttack) ChangeState(AttackState.KineticSurgeB);
|
if (!ChargingAnAttack) ChangeState(AttackState.KineticSurgeB);
|
||||||
break;
|
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 0–1
|
||||||
|
|
||||||
|
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() {
|
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) {
|
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;
|
CurrentState = state;
|
||||||
ComboResetTime = resetTime;
|
ComboResetTime = resetTime;
|
||||||
LastComboTime = Time.time;
|
LastComboTime = Time.time;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user