修改角色包
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua {
|
||||
public class PlayerCharacter : ICharacter {
|
||||
public Animator animator;
|
||||
public Movement movement;
|
||||
|
||||
private void Awake() => kinesis = new PlayerKinesisIdle();
|
||||
|
||||
public override void Updatekinesis(Ikinesis kinesis) {
|
||||
if (!this.kinesis.Interrupt) { return; }
|
||||
this.kinesis = kinesis;
|
||||
|
||||
//播放动画
|
||||
animator.Play(this.kinesis.AnimName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28866a6768c3e7441aa12caefd6217b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace MuHua {
|
||||
public class PlayerController : MonoBehaviour {
|
||||
public Transform cameraController; // 相机对象
|
||||
public PlayerCharacter character;
|
||||
|
||||
private Vector2 moveInput;
|
||||
|
||||
private void Update() {
|
||||
if (moveInput == Vector2.zero) { return; }
|
||||
// 获取相机的前向和右向
|
||||
Vector3 cameraForward = cameraController.transform.forward;
|
||||
Vector3 cameraRight = cameraController.transform.right;
|
||||
|
||||
// 忽略相机的y轴
|
||||
cameraForward.y = 0;
|
||||
cameraRight.y = 0;
|
||||
|
||||
// 归一化向量
|
||||
cameraForward.Normalize();
|
||||
cameraRight.Normalize();
|
||||
|
||||
// 计算相对于相机的移动方向
|
||||
Vector3 moveDirection = (cameraForward * moveInput.y + cameraRight * moveInput.x).normalized;
|
||||
|
||||
// 相对于玩家的移动方向
|
||||
Vector3 position = character.transform.position + new Vector3(moveDirection.x, 0, moveDirection.z) * 0.5f;
|
||||
PlayerKinesisMove kinesis = new PlayerKinesisMove(position, character);
|
||||
character.Updatekinesis(kinesis);
|
||||
}
|
||||
|
||||
#region 输入系统
|
||||
public void OnMove(InputValue inputValue) {
|
||||
// 获取移动输入
|
||||
moveInput = inputValue.Get<Vector2>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73bafdf07b08fc246ab173a5e555629e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff61e8e49afe14548a5ec4151e14ab34
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua {
|
||||
public class PlayerKinesisAttack : Ikinesis {
|
||||
|
||||
public string animName = "Attack01";
|
||||
public bool animEnd = false;
|
||||
|
||||
public override string AnimName => animName;
|
||||
public override bool Interrupt => animEnd;
|
||||
|
||||
public override void AnimationEnd() => animEnd = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c910b7b6bba29d4381c9bb1d615ff77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua {
|
||||
public class PlayerKinesisIdle : Ikinesis {
|
||||
public override string AnimName => "Idle";
|
||||
public override bool Interrupt => true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 190d2b1706b7e0b42b9700950c4e2c18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua {
|
||||
public class PlayerKinesisMove : Ikinesis {
|
||||
public Vector3 position;
|
||||
public Movement movement;
|
||||
public Animator animator;
|
||||
public PlayerCharacter character;
|
||||
public Ikinesis transition = new PlayerKinesisIdle();
|
||||
|
||||
public override string AnimName => "Move";
|
||||
public override bool Interrupt => true;
|
||||
|
||||
public PlayerKinesisMove(Vector3 position, PlayerCharacter character) {
|
||||
this.position = position;
|
||||
this.movement = character.movement;
|
||||
this.animator = character.animator;
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
if (movement.UpdateMove(position)) { character.Updatekinesis(transition); }
|
||||
|
||||
animator.SetFloat("MoveSpeed", movement.CurrentSpeed);
|
||||
animator.SetFloat("MoveX", movement.Direction.x);
|
||||
animator.SetFloat("MoveZ", movement.Direction.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c4416dfc61926e439368a6fd3b26675
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user