jump实现部分
This commit is contained in:
parent
145674a9fa
commit
78449200c3
File diff suppressed because it is too large
Load Diff
@ -155,10 +155,10 @@ AnimatorStateMachine:
|
||||
m_Position: {x: 340, y: 260, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 381074812473331180}
|
||||
m_Position: {x: 375, y: 325, z: 0}
|
||||
m_Position: {x: 470, y: -200, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 1363684478293623723}
|
||||
m_Position: {x: 410, y: 390, z: 0}
|
||||
m_Position: {x: 730, y: -160, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -1871750871593261253}
|
||||
m_Position: {x: 445, y: 455, z: 0}
|
||||
@ -439,7 +439,8 @@ AnimatorState:
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_StateMachineBehaviours:
|
||||
- {fileID: 3699321330036073150}
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
@ -597,7 +598,8 @@ AnimatorState:
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_StateMachineBehaviours:
|
||||
- {fileID: 1777839211832544646}
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
@ -638,6 +640,20 @@ AnimatorState:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!114 &1777839211832544646
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 489a28a5fabbb684e9e115eb8456d5db, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
RoleID: 0
|
||||
Step: 2
|
||||
--- !u!1102 &2819678479818455320
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
@ -683,6 +699,20 @@ MonoBehaviour:
|
||||
SendCanToNext: 0
|
||||
RoleID: 0
|
||||
NodeType: 0
|
||||
--- !u!114 &3699321330036073150
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 489a28a5fabbb684e9e115eb8456d5db, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
RoleID: 0
|
||||
Step: 1
|
||||
--- !u!1102 &4054845936075069209
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
|
46
Assets/Scripts/Main/AnimeScript/anime_JumpState.cs
Normal file
46
Assets/Scripts/Main/AnimeScript/anime_JumpState.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Game;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum E_JUMP_STEP
|
||||
{
|
||||
None,
|
||||
JumpUp,
|
||||
JumpFall
|
||||
}
|
||||
|
||||
public class anime_JumpState : StateMachineBehaviour
|
||||
{
|
||||
public long RoleID = 0;
|
||||
public E_JUMP_STEP Step;
|
||||
|
||||
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
|
||||
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
RoleID = animator.GetInteger("RoleID");
|
||||
AppEntry.Event.Fire(null, MainPlayerJumpStateEventArgs.Create(RoleID, Step));
|
||||
}
|
||||
|
||||
// OnState}Update is called on each Update frame between OnStateEnter and OnStateExit callbacks
|
||||
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
}
|
||||
|
||||
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
|
||||
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
}
|
||||
|
||||
// OnStateMove is called right after Animator.OnAnimatorMove()
|
||||
//override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
//{
|
||||
// // Implement code that processes and affects root motion
|
||||
//}
|
||||
|
||||
// OnStateIK is called right after Animator.OnAnimatorIK()
|
||||
//override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
//{
|
||||
// // Implement code that sets up animation IK (inverse kinematics)
|
||||
//}
|
||||
}
|
11
Assets/Scripts/Main/AnimeScript/anime_JumpState.cs.meta
Normal file
11
Assets/Scripts/Main/AnimeScript/anime_JumpState.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 489a28a5fabbb684e9e115eb8456d5db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -9,7 +9,6 @@ namespace Game
|
||||
{
|
||||
public Transform MainCamNode;
|
||||
public Transform CamPos;
|
||||
|
||||
public MainRole Player;
|
||||
|
||||
/// <summary>
|
||||
@ -27,12 +26,10 @@ namespace Game
|
||||
MainCamNode = transform.Find("MainCamNode");
|
||||
CamPos = MainCamNode.Find("CamPos");
|
||||
InGame = false;
|
||||
AppEntry.Event.Subscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
AppEntry.Event.Unsubscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
||||
}
|
||||
|
||||
public void ReSetMainPlayer()
|
||||
@ -88,13 +85,23 @@ namespace Game
|
||||
|
||||
Player.InputV2 = GamePlayEntry.Input.InputV2;
|
||||
|
||||
if (GamePlayEntry.Input.Attack
|
||||
&&
|
||||
Player.AttackStep != E_ONCEATTACK_STEP.InAttack
|
||||
)
|
||||
//如果处于攻击 后续不执行
|
||||
if (Player.AttackStep == E_ONCEATTACK_STEP.InAttack)
|
||||
return;
|
||||
|
||||
if (GamePlayEntry.Input.Attack)
|
||||
{
|
||||
//AxibugLog.Debug("DoAttack");
|
||||
DoNextMotionAnimeName();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Player.JumpStep == E_JUMP_STEP.None && GamePlayEntry.Input.Jump)
|
||||
{
|
||||
//AxibugLog.Debug("Jump");
|
||||
//TODO 放在这里是否合适? 动作驱动
|
||||
Player.ChangeJumpState(E_JUMP_STEP.JumpUp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,20 +141,6 @@ namespace Game
|
||||
if(IsEndMotion)
|
||||
GamePlayEntry.Input.mInputMotionData.ClearHistoryMotion();
|
||||
}
|
||||
|
||||
#region ʼþ
|
||||
|
||||
private void OnMainPlayerInAttackEventArgs(object sender, LogicEventArgs e)
|
||||
{
|
||||
MainPlayerOnceAttackEventArgs msg = (MainPlayerOnceAttackEventArgs)e;
|
||||
if (msg == null) throw new GameException("MainPlayerOnceAttackEventArgs is null");
|
||||
if (msg.RoleID == Player.RoleID)
|
||||
{
|
||||
Player.AttackStep = msg.Step;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,12 @@ namespace Game
|
||||
{
|
||||
public Vector2 InputV2 { get { return _InputV2; } }
|
||||
public bool Attack { get { return _Attack; } }
|
||||
public bool Jump { get { return _Jump; } }
|
||||
|
||||
private Vector2 _clickPoint; //鼠标点击ui位置
|
||||
private Vector2 _InputV2;
|
||||
private bool _Attack;
|
||||
private bool _Jump;
|
||||
|
||||
public InputMotionData mInputMotionData = new InputMotionData();
|
||||
|
||||
@ -241,6 +243,8 @@ namespace Game
|
||||
_InputV2.y = Input.GetAxisRaw("Vertical");
|
||||
|
||||
_Attack = Input.GetKeyDown(KeyCode.J);
|
||||
|
||||
_Jump = Input.GetKeyDown(KeyCode.K);
|
||||
}
|
||||
|
||||
void Update_InputKeyCode()
|
||||
|
@ -11,6 +11,8 @@ public class ConstClass
|
||||
public static float FastRunSpeedMultiplier = 3f;
|
||||
public static float FastModeShadowCreateIntervalTime = 0.25f;
|
||||
|
||||
public static float JumpSpeedY = 1;
|
||||
public static float JumpSpeedY_Down = 1;
|
||||
|
||||
public const float CellSize = 1f;
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
using Axibug;
|
||||
using Axibug.Event;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public class MainPlayerJumpStateEventArgs : LogicEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MainPlayerJumpStateEventArgs).GetHashCode();
|
||||
public long RoleID = 0;
|
||||
public E_JUMP_STEP Step = E_JUMP_STEP.None;
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载数据表成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id { get { return EventId; } }
|
||||
|
||||
public static MainPlayerJumpStateEventArgs Create(long roleID,E_JUMP_STEP step)
|
||||
{
|
||||
MainPlayerJumpStateEventArgs s = ReferencePool.Acquire<MainPlayerJumpStateEventArgs>();
|
||||
s.Step = step;
|
||||
s.RoleID = roleID;
|
||||
return s;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
RoleID = 0;
|
||||
Step = E_JUMP_STEP.None;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e78328b65d1102a4a82eb00394ba8909
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,4 +1,5 @@
|
||||
using Axibug;
|
||||
using Axibug.Event;
|
||||
using Axibug.Runtime;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -31,11 +32,15 @@ namespace Game
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
AppEntry.Event.Subscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
||||
AppEntry.Event.Subscribe(MainPlayerJumpStateEventArgs.EventId, OnMainPlayerJumpStateEventArgs);
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
AppEntry.Event.Unsubscribe(MainPlayerOnceAttackEventArgs.EventId, OnMainPlayerInAttackEventArgs);
|
||||
AppEntry.Event.Unsubscribe(MainPlayerJumpStateEventArgs.EventId, OnMainPlayerJumpStateEventArgs);
|
||||
}
|
||||
|
||||
protected override void FixedUpdate()
|
||||
@ -47,16 +52,24 @@ namespace Game
|
||||
const int SnapInterval = 3;
|
||||
int SnapIntervalIndex = 0;
|
||||
|
||||
protected override void Update()
|
||||
/// <summary>
|
||||
/// ¿ìÕÕ¸üÐÂÂß¼
|
||||
/// </summary>
|
||||
void Update_Snap()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
SnapIntervalIndex++;
|
||||
if (SnapIntervalIndex >= SnapInterval)
|
||||
{
|
||||
mRoleSnapshot.AddSnap(mSpriteRenderer.sprite, mBridgeTransfrom.localEulerAngles, transform.position);
|
||||
SnapIntervalIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Update_Snap();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.T))
|
||||
{
|
||||
@ -101,6 +114,21 @@ namespace Game
|
||||
Anime.BackToIdle();
|
||||
}
|
||||
}
|
||||
public override void ChangeJumpState(E_JUMP_STEP jumpStep)
|
||||
{
|
||||
switch (jumpStep)
|
||||
{
|
||||
case E_JUMP_STEP.JumpUp:
|
||||
Anime.SetOtherAnime("jump");
|
||||
break;
|
||||
case E_JUMP_STEP.JumpFall:
|
||||
Anime.SetOtherAnime("JumptoFall");
|
||||
break;
|
||||
case E_JUMP_STEP.None:
|
||||
Anime.BackToIdle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Release()
|
||||
{
|
||||
@ -186,5 +214,28 @@ namespace Game
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ʼþ
|
||||
|
||||
private void OnMainPlayerInAttackEventArgs(object sender, LogicEventArgs e)
|
||||
{
|
||||
MainPlayerOnceAttackEventArgs msg = (MainPlayerOnceAttackEventArgs)e;
|
||||
if (msg == null) throw new GameException("MainPlayerOnceAttackEventArgs is null");
|
||||
if (msg.RoleID == RoleID)
|
||||
{
|
||||
AttackStep = msg.Step;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMainPlayerJumpStateEventArgs(object sender, LogicEventArgs e)
|
||||
{
|
||||
MainPlayerJumpStateEventArgs msg = (MainPlayerJumpStateEventArgs)e;
|
||||
if (msg == null) throw new GameException("MainPlayerJumpState is null");
|
||||
if (msg.RoleID == RoleID)
|
||||
{
|
||||
JumpStep = msg.Step;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -72,5 +72,10 @@ namespace Game
|
||||
GamePlayEntry.RoleMgr.DestroyRole(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ChangeJumpState(E_JUMP_STEP jumpStep)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,6 @@ namespace Game
|
||||
|
||||
public ICharMachineBase Anime => mAnime;
|
||||
|
||||
public Animator AttackBoxAnime;
|
||||
public AttackBox AttackBoxCollider;
|
||||
|
||||
public Vector2 InputV2;
|
||||
|
||||
public E_ONCEATTACK_STEP AttackStep = E_ONCEATTACK_STEP.None;
|
||||
|
||||
public Transform ModelTransfrom { get { return mModelTransfrom; } }
|
||||
public Transform BridgeTransfrom { get { return mBridgeTransfrom; } }
|
||||
|
||||
@ -38,6 +31,12 @@ namespace Game
|
||||
protected Rigidbody mRigidbody;
|
||||
protected Collider mselfCollider;
|
||||
|
||||
public Animator AttackBoxAnime;
|
||||
public AttackBox AttackBoxCollider;
|
||||
|
||||
public Vector2 InputV2;
|
||||
|
||||
public E_ONCEATTACK_STEP AttackStep = E_ONCEATTACK_STEP.None;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
@ -119,14 +118,15 @@ namespace Game
|
||||
protected virtual void Update()
|
||||
{
|
||||
Update_Move();
|
||||
Update_Jump();
|
||||
}
|
||||
protected virtual void FixedUpdate()
|
||||
{
|
||||
FixedUpdate_Move();
|
||||
}
|
||||
|
||||
|
||||
public abstract void MeshChangeMoveState(bool ToMoveState);
|
||||
public abstract void ChangeJumpState(E_JUMP_STEP jumpStep);
|
||||
|
||||
public void MeshChangeDir(bool ToLeftDir)
|
||||
{
|
||||
@ -155,7 +155,8 @@ namespace Game
|
||||
else//刚停止移动
|
||||
{
|
||||
MoveTime = 0;
|
||||
Move_currentVector = Vector3.zero;//清空移动方向
|
||||
//Move_currentVector = Vector3.zero;//清空移动方向
|
||||
Move_currentVector.x = 0;//清空移动方向
|
||||
MeshChangeMoveState(false);
|
||||
}
|
||||
}
|
||||
@ -191,10 +192,14 @@ namespace Game
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InputV2 != Vector2.zero)
|
||||
//if (InputV2 != Vector2.zero)
|
||||
//仅横向移动
|
||||
if (InputV2.x != 0)
|
||||
{
|
||||
isDoMove = true;
|
||||
Move_currentVector = new Vector3(InputV2.x, 0, InputV2.y);
|
||||
//Move_currentVector = new Vector3(InputV2.x, 0, InputV2.y);
|
||||
//仅横向移动
|
||||
Move_currentVector.x = InputV2.x;
|
||||
}
|
||||
|
||||
//AxibugLog.Debug("Move_currentVector =>" + Move_currentVector);
|
||||
@ -230,11 +235,88 @@ namespace Game
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region
|
||||
public float JumpTime = 0;
|
||||
public float Jump_CurrySpeedY = 0;
|
||||
|
||||
|
||||
private E_JUMP_STEP mJumpStep = E_JUMP_STEP.None;
|
||||
public E_JUMP_STEP JumpStep
|
||||
{
|
||||
get { return mJumpStep; }
|
||||
set
|
||||
{
|
||||
if (mJumpStep != value)
|
||||
{
|
||||
mJumpStep = value;
|
||||
switch (value)
|
||||
{
|
||||
case E_JUMP_STEP.JumpUp:
|
||||
SetToUpVec();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Update_Jump()
|
||||
{
|
||||
//if(Move_currentVector.y) 跳跃衰减
|
||||
|
||||
//判断是否在空中
|
||||
|
||||
switch (JumpStep)
|
||||
{
|
||||
case E_JUMP_STEP.JumpUp:
|
||||
Jump_CurrySpeedY -= Time.deltaTime * ConstClass.JumpSpeedY_Down;
|
||||
if (Jump_CurrySpeedY <= 0)
|
||||
{
|
||||
Jump_CurrySpeedY = 0;
|
||||
ChangeJumpState(E_JUMP_STEP.JumpFall);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Move_currentVector.y = Jump_CurrySpeedY;
|
||||
//TODO 判断地面接触
|
||||
AxibugLog.Debug("TerrainEnterNumber->" + TerrainEnterNumber);
|
||||
}
|
||||
|
||||
//
|
||||
void SetToUpVec()
|
||||
{
|
||||
Jump_CurrySpeedY = ConstClass.JumpSpeedY;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 攻击盒子动画机
|
||||
public void DoAtkBox(string AtkBoxAnimeName)
|
||||
{
|
||||
AttackBoxAnime.Play(AtkBoxAnimeName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
bool CheckRayTerrain()
|
||||
{
|
||||
Debug.DrawLine(transform.position, transform.position + Vector3.down, Color.red);
|
||||
return Physics.RaycastAll(transform.position, transform.position + Vector3.down,1, LayerMask.NameToLayer("Terrain")).Length > 0;
|
||||
}
|
||||
|
||||
#region
|
||||
int TerrainEnterNumber;
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.layer == LayerMask.NameToLayer("Terrain"))
|
||||
TerrainEnterNumber++;
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.gameObject.layer == LayerMask.NameToLayer("Terrain"))
|
||||
TerrainEnterNumber--;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user