Add jump ability
This commit is contained in:
parent
cc316e263a
commit
39708027b4
@ -71010,6 +71010,14 @@ PrefabInstance:
|
|||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 0}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
|
- target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
|
propertyPath: VfxKineticSurge
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 4566952472781634859, guid: 0d7c4835b1f550241bb630daef9e33e8, type: 3}
|
||||||
|
- target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
|
propertyPath: FighterClass.VfxKineticSurge
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 4566952472781634859, guid: 0d7c4835b1f550241bb630daef9e33e8, type: 3}
|
||||||
- target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
- target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
propertyPath: 'ClassIndicators.Array.data[0]'
|
propertyPath: 'ClassIndicators.Array.data[0]'
|
||||||
value:
|
value:
|
||||||
@ -71026,6 +71034,10 @@ PrefabInstance:
|
|||||||
propertyPath: 'ClassIndicators.Array.data[3]'
|
propertyPath: 'ClassIndicators.Array.data[3]'
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 1731397399}
|
objectReference: {fileID: 1731397399}
|
||||||
|
- target: {fileID: 1787569555844345674, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1825172400684165510, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
- target: {fileID: 1825172400684165510, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
propertyPath: m_BodyType
|
propertyPath: m_BodyType
|
||||||
value: 1
|
value: 1
|
||||||
@ -71162,6 +71174,14 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: -0.195
|
value: -0.195
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9074809610135348735, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 9098681062314285509, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
|
propertyPath: m_IsActive
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 9117212351613092415, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
- target: {fileID: 9117212351613092415, guid: d00d92ab204198c489965b31a298b234, type: 3}
|
||||||
propertyPath: m_Size.x
|
propertyPath: m_Size.x
|
||||||
value: 0.84173715
|
value: 0.84173715
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
using AI.Base;
|
using AI.Base;
|
||||||
using UnityEditor.Experimental.GraphView;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static TMPro.SpriteAssetUtilities.TexturePacker_JsonArray;
|
|
||||||
|
|
||||||
public class EnemyStateManager : StateManager {
|
public class EnemyStateManager : StateManager {
|
||||||
[Header("States")]
|
[Header("States")]
|
||||||
|
|||||||
@ -52,10 +52,11 @@ public class AttackAnimatorFactory : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void MeleeResetKineticCharge() {
|
public void MeleeResetKineticCharge() {
|
||||||
Melee.CrossFade("Blank", 0, 1);
|
//Melee.CrossFade("Blank", 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MeleeBasic(int set) {
|
public void MeleeBasic(int set) {
|
||||||
|
return;
|
||||||
RotateTowardsMouse();
|
RotateTowardsMouse();
|
||||||
|
|
||||||
if (set == 1) Melee.CrossFade("BasicAttack1", 0, 0);
|
if (set == 1) Melee.CrossFade("BasicAttack1", 0, 0);
|
||||||
@ -68,6 +69,7 @@ public class AttackAnimatorFactory : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void MeleeKineticSurge() {
|
public void MeleeKineticSurge() {
|
||||||
|
return;
|
||||||
Melee.CrossFade("KineticSurgeRelease", 0, 0);
|
Melee.CrossFade("KineticSurgeRelease", 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public class ClassBase {
|
|||||||
protected float PlayerOriginalSpeed;
|
protected float PlayerOriginalSpeed;
|
||||||
protected FloatingTextSpawner TextPopUp;
|
protected FloatingTextSpawner TextPopUp;
|
||||||
/// <summary>Always in the order of Up, Down, Left, Right</summary>
|
/// <summary>Always in the order of Up, Down, Left, Right</summary>
|
||||||
public string AnimationToPlay;
|
public string AnimationToPlay = "";
|
||||||
|
|
||||||
public ClassBase(Player player) {
|
public ClassBase(Player player) {
|
||||||
Player = player;
|
Player = player;
|
||||||
@ -29,6 +29,6 @@ public class ClassBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual public void Tick() { }
|
virtual public void Tick() { }
|
||||||
virtual public void HandleLMB() { }
|
virtual public void HandlePrimaryAttack() { }
|
||||||
virtual public void HandleRMB() { }
|
virtual public void HandleSecondaryAttack() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,7 @@
|
|||||||
using JetBrains.Annotations;
|
using UnityEngine;
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEditor.VersionControl;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class MeleeFighterClass : ClassBase {
|
public class MeleeFighterClass : ClassBase {
|
||||||
public MeleeFighterClass(Player player) : base(player) { }
|
|
||||||
private readonly int BladeVortex = Animator.StringToHash("BladeVortex");
|
private readonly int BladeVortex = Animator.StringToHash("BladeVortex");
|
||||||
private float BladeVortexSpeed = 0.4f;
|
private float BladeVortexSpeed = 0.4f;
|
||||||
public float ComboResetTime;
|
public float ComboResetTime;
|
||||||
@ -22,6 +13,15 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
public float TimeElapsed;
|
public float TimeElapsed;
|
||||||
public float Cooldown;
|
public float Cooldown;
|
||||||
public bool TimesUp;
|
public bool TimesUp;
|
||||||
|
private bool HandlingOnStateEnter;
|
||||||
|
|
||||||
|
public VfxHandlerBase VfxKineticSurgeHandler { get { return Player.VfxKineticSurgeHandler; } }
|
||||||
|
|
||||||
|
|
||||||
|
public MeleeFighterClass(Player player) : base(player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AttackState CurrentState;
|
public AttackState CurrentState;
|
||||||
@ -77,11 +77,11 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
AnimationToPlay = "Attack1";
|
AnimationToPlay = "Attack1";
|
||||||
TextPopUp.SpawnFloatingText("KineticSurge", Color.red, 3);
|
TextPopUp.SpawnFloatingText("KineticSurge", Color.red, 3);
|
||||||
//Player.SkillInUse = false;
|
//Player.SkillInUse = false;
|
||||||
Player.MoveSpeed = PlayerOriginalSpeed;
|
//Player.MoveSpeed = PlayerOriginalSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ChargingAnAttack && TimesUp) {
|
if (!ChargingAnAttack && TimesUp) {
|
||||||
Player.MoveSpeed = PlayerOriginalSpeed;
|
Player.MoveSpeedDampener = 1;
|
||||||
ChangeState(AttackState.None);
|
ChangeState(AttackState.None);
|
||||||
AttackAnimator.MeleeResetKineticCharge();
|
AttackAnimator.MeleeResetKineticCharge();
|
||||||
Player.SkillInUse = false;
|
Player.SkillInUse = false;
|
||||||
@ -109,12 +109,12 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
override public void HandleLMB() {
|
override public void HandlePrimaryAttack() {
|
||||||
Player.SkillInUse = true;
|
Player.SkillInUse = true;
|
||||||
|
|
||||||
switch (CurrentState) {
|
switch (CurrentState) {
|
||||||
case AttackState.None:
|
case AttackState.None:
|
||||||
PlayerOriginalSpeed = Player.MoveSpeed;
|
//PlayerOriginalSpeed = Player.MoveSpeed;
|
||||||
|
|
||||||
if ((Time.time - Player.DashTime) <= 0.1f)
|
if ((Time.time - Player.DashTime) <= 0.1f)
|
||||||
ChangeState(AttackState.PhaseCleave, 1.5f);
|
ChangeState(AttackState.PhaseCleave, 1.5f);
|
||||||
@ -122,7 +122,6 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
ChangeState(AttackState.Shockwave, 0, 1.5f);
|
ChangeState(AttackState.Shockwave, 0, 1.5f);
|
||||||
else
|
else
|
||||||
ChangeState(AttackState.BasicAttack1, 0.35f);
|
ChangeState(AttackState.BasicAttack1, 0.35f);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@ -135,16 +134,18 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
ChangeState(AttackState.BasicAttack3, 0.15f);
|
ChangeState(AttackState.BasicAttack3, 0.15f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override public void HandleRMB() {
|
override public void HandleSecondaryAttack() {
|
||||||
Player.SkillInUse = true;
|
Player.SkillInUse = true;
|
||||||
|
|
||||||
switch (CurrentState) {
|
switch (CurrentState) {
|
||||||
case AttackState.None:
|
case AttackState.None:
|
||||||
PlayerOriginalSpeed = Player.MoveSpeed;
|
/*PlayerOriginalSpeed = Player.MoveSpeed*/
|
||||||
|
|
||||||
|
|
||||||
if (Player.IsDashing)
|
if (Player.IsDashing)
|
||||||
ChangeState(AttackState.None);
|
ChangeState(AttackState.None);
|
||||||
@ -165,6 +166,12 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
case AttackState.BasicAttack3:
|
case AttackState.BasicAttack3:
|
||||||
//ChangeState(AttackState.ChargeSurgeB);
|
//ChangeState(AttackState.ChargeSurgeB);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case AttackState.BladeVortex:
|
||||||
|
ChangeState(AttackState.None);
|
||||||
|
//ChangeState(AttackState.ChargeSurgeB);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,12 +184,14 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
|
|
||||||
if (TimeElapsed < Cooldown) return;
|
if (TimeElapsed < Cooldown) return;
|
||||||
CurrentState = state;
|
CurrentState = state;
|
||||||
|
Player.MoveSpeedDampener = (state == AttackState.None) ? 1 : 1 / decreasedSpeed;
|
||||||
if (state == AttackState.None) return;
|
if (state == AttackState.None) return;
|
||||||
Cooldown = cooldown;
|
Cooldown = cooldown;
|
||||||
TextPopUp.SpawnFloatingText(state.ToString(), Color.red, 3);
|
TextPopUp.SpawnFloatingText(state.ToString(), Color.red, 3);
|
||||||
ComboResetTime = resetTime;
|
ComboResetTime = resetTime;
|
||||||
LastComboTime = Time.time;
|
LastComboTime = Time.time;
|
||||||
Player.MoveSpeed = (state == AttackState.None) ? PlayerOriginalSpeed : PlayerOriginalSpeed * decreasedSpeed;
|
|
||||||
|
RotateTowardsMouse();
|
||||||
|
|
||||||
switch (CurrentState) {
|
switch (CurrentState) {
|
||||||
case AttackState.None:
|
case AttackState.None:
|
||||||
@ -197,7 +206,6 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
|
|
||||||
case AttackState.BladeVortex:
|
case AttackState.BladeVortex:
|
||||||
AnimationToPlay = "BladeVortex_";
|
AnimationToPlay = "BladeVortex_";
|
||||||
//Animator.CrossFade(BladeVortex, 0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AttackState.BasicAttack1:
|
case AttackState.BasicAttack1:
|
||||||
@ -215,13 +223,20 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
AttackAnimator.MeleeBasic(3);
|
AttackAnimator.MeleeBasic(3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AttackState.KineticSurgeA:
|
case AttackState.KineticSurgeRelease:
|
||||||
Debug.Log($"Charged Value: {ChargeValue}");
|
VfxKineticSurgeHandler.PlayAll(Player.transform.position);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case AttackState.KineticSurgeB:
|
public void RotateTowardsMouse() {
|
||||||
Debug.Log($"Charged Value: {ChargeValue}");
|
return;
|
||||||
break;
|
Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||||
|
Vector2 direction = mouseWorldPos - Player.transform.position;
|
||||||
|
if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y)) {
|
||||||
|
Player.LastDirection = (direction.x > 0) ? Player.Direction.Right : Player.Direction.Left;
|
||||||
|
} else {
|
||||||
|
Player.LastDirection = (direction.y > 0) ? Player.Direction.Up : Player.Direction.Down;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,7 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
[SelectionBase]
|
[SelectionBase]
|
||||||
@ -25,17 +21,21 @@ public class Player : MonoBehaviour {
|
|||||||
[SerializeField] private MeleeFighterClass FighterClass;
|
[SerializeField] private MeleeFighterClass FighterClass;
|
||||||
public AttackAnimatorFactory AttackAnimator;
|
public AttackAnimatorFactory AttackAnimator;
|
||||||
|
|
||||||
|
|
||||||
[Header("Movement Attributes")]
|
[Header("Movement Attributes")]
|
||||||
[SerializeField] public float MoveSpeed = 8;
|
[SerializeField] public float MoveSpeed = 8;
|
||||||
|
[SerializeField] public float MoveSpeedDampener = 1;
|
||||||
[SerializeField] private float DashMultiplier = 60;
|
[SerializeField] private float DashMultiplier = 60;
|
||||||
[SerializeField] private float DriftSpeed = 60;
|
[SerializeField] private float DriftSpeed = 60;
|
||||||
[SerializeField] private float DriftFactorial = 0.85f;
|
[SerializeField] private float DriftFactorial = 0.85f;
|
||||||
|
[SerializeField] private float JumpDelay = 0.5f;
|
||||||
|
|
||||||
[Header("VFX")]
|
[Header("VFX")]
|
||||||
[SerializeField] private GameObject VfxDash;
|
[SerializeField] private GameObject VfxDash;
|
||||||
private VfxHandlerBase VfxDashHandler;
|
private VfxHandlerBase VfxDashHandler;
|
||||||
|
[SerializeField] private GameObject VfxKineticSurge;
|
||||||
|
[HideInInspector] public VfxHandlerBase VfxKineticSurgeHandler;
|
||||||
|
|
||||||
|
private BoxCollider2D[] BoxColliders;
|
||||||
|
|
||||||
|
|
||||||
public Vector2 PrevDirection = Vector2.zero;
|
public Vector2 PrevDirection = Vector2.zero;
|
||||||
@ -48,22 +48,16 @@ public class Player : MonoBehaviour {
|
|||||||
public Vector2 DriftDirection { get; private set; } = Vector2.zero;
|
public Vector2 DriftDirection { get; private set; } = Vector2.zero;
|
||||||
private float Drift = 0;
|
private float Drift = 0;
|
||||||
|
|
||||||
private readonly int AnimMoveRight = Animator.StringToHash("Anim_Player_MoveRight");
|
|
||||||
private readonly int AnimIdleRight = Animator.StringToHash("Anim_Player_IdleRight");
|
|
||||||
|
|
||||||
public bool SkillInUse = false;
|
public bool SkillInUse = false;
|
||||||
//{
|
|
||||||
// get { return Animator.GetBool("SkillActive"); }
|
|
||||||
// set { Animator.SetBool("SkillActive", value); }
|
|
||||||
//}
|
|
||||||
|
|
||||||
private enum Directions { Left, Right, Up, Down }
|
private enum Directions { Left, Right, Up, Down }
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
Builder = GetComponent<BuilderManager>();
|
Builder = GetComponent<BuilderManager>();
|
||||||
|
|
||||||
VfxDashHandler = new VfxHandlerBase(VfxDash, 5, 5);
|
VfxDashHandler = new VfxHandlerBase(VfxDash, 5, 5);
|
||||||
|
VfxKineticSurgeHandler = new VfxHandlerBase(VfxKineticSurge, 5, 5);
|
||||||
FighterClass = new MeleeFighterClass(this);
|
FighterClass = new MeleeFighterClass(this);
|
||||||
|
BoxColliders = GetComponentsInChildren<BoxCollider2D>();
|
||||||
SetClass(1);
|
SetClass(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +66,7 @@ public class Player : MonoBehaviour {
|
|||||||
KeyPressActions();
|
KeyPressActions();
|
||||||
ActiveClass.Tick();
|
ActiveClass.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GatherInput() {
|
private void GatherInput() {
|
||||||
MoveDirection.x = Input.GetAxisRaw("Horizontal");
|
MoveDirection.x = Input.GetAxisRaw("Horizontal");
|
||||||
MoveDirection.y = Input.GetAxisRaw("Vertical");
|
MoveDirection.y = Input.GetAxisRaw("Vertical");
|
||||||
@ -80,6 +75,8 @@ public class Player : MonoBehaviour {
|
|||||||
private void KeyPressActions() {
|
private void KeyPressActions() {
|
||||||
if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)) {
|
if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)) {
|
||||||
Dash(MoveDirection);
|
Dash(MoveDirection);
|
||||||
|
} else if (!IsJumping && Input.GetKeyDown(KeyCode.Space)) {
|
||||||
|
Jump();
|
||||||
} else if (Input.GetKeyDown(KeyCode.F1)) {
|
} else if (Input.GetKeyDown(KeyCode.F1)) {
|
||||||
SetClass(0);
|
SetClass(0);
|
||||||
} else if (Input.GetKeyDown(KeyCode.F2)) {
|
} else if (Input.GetKeyDown(KeyCode.F2)) {
|
||||||
@ -90,17 +87,17 @@ public class Player : MonoBehaviour {
|
|||||||
SetClass(3);
|
SetClass(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(0)) ActiveClass.HandleLMB();
|
|
||||||
else if (Input.GetMouseButtonDown(1)) ActiveClass.HandleRMB();
|
if (Input.GetKeyDown(KeyCode.X)) ActiveClass.HandlePrimaryAttack();
|
||||||
|
else if (Input.GetKeyDown(KeyCode.C)) ActiveClass.HandleSecondaryAttack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Dash(Vector2 direction) {
|
private void Dash(Vector2 direction) {
|
||||||
if (SkillInUse) return;
|
|
||||||
if (Drift > 0.5f) return;
|
if (Drift > 0.5f) return;
|
||||||
IsDashing = true;
|
IsDashing = true;
|
||||||
DashTime = Time.time;
|
DashTime = Time.time;
|
||||||
|
|
||||||
RigidBody.linearVelocity = direction.normalized * MoveSpeed * DashMultiplier;
|
RigidBody.linearVelocity = (direction.normalized * MoveSpeed * DashMultiplier) / MoveSpeedDampener;
|
||||||
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg + 180;
|
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg + 180;
|
||||||
if (direction.normalized != Vector2.zero)
|
if (direction.normalized != Vector2.zero)
|
||||||
VfxDashHandler.PlayAll(this.transform.position, Quaternion.Euler(0f, 0f, angle));
|
VfxDashHandler.PlayAll(this.transform.position, Quaternion.Euler(0f, 0f, angle));
|
||||||
@ -109,6 +106,22 @@ public class Player : MonoBehaviour {
|
|||||||
IsDashing = false;
|
IsDashing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Jump() {
|
||||||
|
IsJumping = true;
|
||||||
|
foreach (var col in BoxColliders)
|
||||||
|
col.enabled = false;
|
||||||
|
|
||||||
|
StartCoroutine(ResetJumpAfterDelay());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator ResetJumpAfterDelay() {
|
||||||
|
yield return new WaitForSeconds(JumpDelay);
|
||||||
|
foreach (var col in BoxColliders)
|
||||||
|
col.enabled = true;
|
||||||
|
|
||||||
|
IsJumping = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void SetClass(int classIdx) {
|
private void SetClass(int classIdx) {
|
||||||
Builder.SetBuildMode(classIdx == 3);
|
Builder.SetBuildMode(classIdx == 3);
|
||||||
ActiveClass = FighterClass;
|
ActiveClass = FighterClass;
|
||||||
@ -138,7 +151,7 @@ public class Player : MonoBehaviour {
|
|||||||
private void MovementUpdate() {
|
private void MovementUpdate() {
|
||||||
if (IsDashing) return;
|
if (IsDashing) return;
|
||||||
|
|
||||||
RigidBody.linearVelocity = MoveDirection.normalized * MoveSpeed;
|
RigidBody.linearVelocity = (MoveDirection.normalized * MoveSpeed) / MoveSpeedDampener;
|
||||||
if (Drift > 0.2f) {
|
if (Drift > 0.2f) {
|
||||||
RigidBody.linearVelocity += DriftDirection * Drift;
|
RigidBody.linearVelocity += DriftDirection * Drift;
|
||||||
Drift *= DriftFactorial;
|
Drift *= DriftFactorial;
|
||||||
@ -165,41 +178,49 @@ public class Player : MonoBehaviour {
|
|||||||
Animator.CrossFade(state, 0);
|
Animator.CrossFade(state, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Direction { Up, Down, Left, Right }
|
public enum Direction { Up, Down, Left, Right }
|
||||||
private Direction LastDirection = Direction.Down;
|
public Direction LastDirection = Direction.Down;
|
||||||
private string GetAnimationState(Vector2 input) {
|
private string GetAnimationState(Vector2 input) {
|
||||||
if (SkillInUse) return ActiveClass.AnimationToPlay;
|
if (SkillInUse) return ActiveClass.AnimationToPlay;
|
||||||
|
if (!IsJumping && input.sqrMagnitude < 0.01f) return "Idle";
|
||||||
|
|
||||||
if (input.sqrMagnitude < 0.01f) {
|
if (Mathf.Abs(input.x) > 0)
|
||||||
return "Idle";
|
|
||||||
//return LastDirection switch {
|
|
||||||
// Direction.Up => "IdleUp",
|
|
||||||
// Direction.Down => "IdleDown",
|
|
||||||
// Direction.Left => "IdleLeft",
|
|
||||||
// Direction.Right => "IdleRight",
|
|
||||||
// _ => "IdleDown"
|
|
||||||
//};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Mathf.Abs(input.x) > Mathf.Abs(input.y)) {
|
|
||||||
LastDirection = (input.x > 0) ? Direction.Right : Direction.Left;
|
LastDirection = (input.x > 0) ? Direction.Right : Direction.Left;
|
||||||
} else {
|
else if (Mathf.Abs(input.y) > 0)
|
||||||
LastDirection = (input.y > 0) ? Direction.Up : Direction.Down;
|
LastDirection = (input.y > 0) ? Direction.Up : Direction.Down;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (IsJumping) return "Jump";
|
||||||
return "Run";
|
return "Run";
|
||||||
|
|
||||||
return LastDirection switch {
|
|
||||||
Direction.Up => "RunUp",
|
|
||||||
Direction.Down => "RunDown",
|
|
||||||
Direction.Left => "RunLeft",
|
|
||||||
Direction.Right => "RunRight",
|
|
||||||
_ => "RunDown"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void OnDrawGizmos() {
|
void OnDrawGizmos() {
|
||||||
|
DrawPlayerDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawPlayerDirection() {
|
||||||
|
if (RigidBody == null) RigidBody = GetComponent<Rigidbody2D>();
|
||||||
|
if (RigidBody == null) return;
|
||||||
|
|
||||||
|
Gizmos.color = Color.cyan;
|
||||||
|
|
||||||
|
Vector3 start = RigidBody.transform.position;
|
||||||
|
Vector3 end = start + (Vector3)(RigidBody.linearVelocity * 1);
|
||||||
|
|
||||||
|
Gizmos.DrawLine(start, end);
|
||||||
|
DrawArrowHead(end, (end - start).normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawArrowHead(Vector3 position, Vector3 direction) {
|
||||||
|
float arrowHeadAngle = 20f;
|
||||||
|
float arrowHeadLength = 0.25f;
|
||||||
|
|
||||||
|
Vector3 right = Quaternion.Euler(0, 0, arrowHeadAngle) * -direction;
|
||||||
|
Vector3 left = Quaternion.Euler(0, 0, -arrowHeadAngle) * -direction;
|
||||||
|
|
||||||
|
Gizmos.DrawLine(position, position + right * arrowHeadLength);
|
||||||
|
Gizmos.DrawLine(position, position + left * arrowHeadLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
Assets/Scripts/Runtime/Tests.meta
Normal file
8
Assets/Scripts/Runtime/Tests.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fb178844c7bd9184982b533840dc48d4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
4997
Assets/VFX/VfxKineticSurge.prefab
Normal file
4997
Assets/VFX/VfxKineticSurge.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/VFX/VfxKineticSurge.prefab.meta
Normal file
7
Assets/VFX/VfxKineticSurge.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0d7c4835b1f550241bb630daef9e33e8
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Reference in New Issue
Block a user