移除ECM2

This commit is contained in:
2025-05-11 21:42:51 +08:00
parent aadd564c38
commit a7bf033ca9
726 changed files with 0 additions and 138648 deletions

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 0da0459c0549421aa847206c393566c6
timeCreated: 1700110443

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 04bd0a6d231620948b6e1f8642516c2d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 9a760961c1fb48c9a63d8126fd4299a1
timeCreated: 1700174902

View File

@@ -1,90 +0,0 @@
using UnityEngine;
namespace ECM2.Walkthrough.Ex41
{
/// <summary>
/// This example shows how to extend a Character (through inheritance) to perform a sprint ability.
/// This uses one of the new methods (introduced in v1.4) OnBeforeSimulationUpdate,
/// to easily modify the character's state within Character's simulation loop.
/// </summary>
public class SprintableCharacter : Character
{
[Space(15.0f)]
public float maxSprintSpeed = 10.0f;
private bool _isSprinting;
private bool _sprintInputPressed;
/// <summary>
/// Request the character to start to sprint.
/// </summary>
public void Sprint()
{
_sprintInputPressed = true;
}
/// <summary>
/// Request the character to stop sprinting.
/// </summary>
public void StopSprinting()
{
_sprintInputPressed = false;
}
public bool IsSprinting()
{
return _isSprinting;
}
/// <summary>
/// Determines if the character is able to sprint in its current state.
/// </summary>
private bool CanSprint()
{
// A character can only sprint if:
// A character is in its walking movement mode and not crouched
return IsWalking() && !IsCrouched();
}
/// <summary>
/// Start / stops a requested sprint.
/// </summary>
private void CheckSprintInput()
{
if (!_isSprinting && _sprintInputPressed && CanSprint())
{
_isSprinting = true;
}
else if (_isSprinting && (!_sprintInputPressed || !CanSprint()))
{
_isSprinting = false;
}
}
/// <summary>
/// Override GetMaxSpeed method to return maxSprintSpeed while sprinting.
/// </summary>
public override float GetMaxSpeed()
{
return _isSprinting ? maxSprintSpeed : base.GetMaxSpeed();
}
protected override void OnBeforeSimulationUpdate(float deltaTime)
{
// Call base method implementation
base.OnBeforeSimulationUpdate(deltaTime);
// Handle sprint
CheckSprintInput();
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 0d88021f925b47469d907d1488264b49
timeCreated: 1700110471

View File

@@ -1,69 +0,0 @@
using ECM2.Examples;
using UnityEngine.InputSystem;
namespace ECM2.Walkthrough.Ex41
{
/// <summary>
/// Extends CharacterInput adding support for Sprint InputAction.
/// </summary>
public class SprintableCharacterInput : CharacterInput
{
private SprintableCharacter _sprintableCharacter;
/// <summary>
/// Sprint InputAction.
/// </summary>
public InputAction sprintInputAction { get; set; }
/// <summary>
/// Sprint InputAction handler.
/// </summary>
public virtual void OnSprint(InputAction.CallbackContext context)
{
if (context.started)
_sprintableCharacter.Sprint();
else if (context.canceled)
_sprintableCharacter.StopSprinting();
}
protected override void InitPlayerInput()
{
base.InitPlayerInput();
// Setup Sprint input action handlers
sprintInputAction = inputActionsAsset.FindAction("Sprint");
if (sprintInputAction != null)
{
sprintInputAction.started += OnSprint;
sprintInputAction.canceled += OnSprint;
sprintInputAction.Enable();
}
}
protected override void DeinitPlayerInput()
{
base.DeinitPlayerInput();
if (sprintInputAction != null)
{
sprintInputAction.started -= OnSprint;
sprintInputAction.canceled -= OnSprint;
sprintInputAction.Disable();
sprintInputAction = null;
}
}
protected override void Awake()
{
base.Awake();
_sprintableCharacter = character as SprintableCharacter;
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: aae1b8010de5d4a4ea1f944d9fe09bcc

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 5af609ff5be14b28b526cb974a6662fa
timeCreated: 1700115834

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 4c37c58624030d74a9972d4a9d21fa15
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3deb2cb5bf2b15b4297ac3a7369fb3bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,109 +0,0 @@
using UnityEngine;
namespace ECM2.Walkthrough.Ex42
{
/// <summary>
/// This example shows how to extend a Character (through composition) to perform a sprint ability.
/// This one use the new simulation OnBeforeSimulationUpdate event (introduced in v1.4),
/// to easily modify the character's state within Character's simulation loop.
/// </summary>
public class SprintAbility : MonoBehaviour
{
[Space(15.0f)]
public float maxSprintSpeed = 10.0f;
private Character _character;
private bool _isSprinting;
private bool _sprintInputPressed;
private float _cachedMaxWalkSpeed;
/// <summary>
/// Request the character to start to sprint.
/// </summary>
public void Sprint()
{
_sprintInputPressed = true;
}
/// <summary>
/// Request the character to stop sprinting.
/// </summary>
public void StopSprinting()
{
_sprintInputPressed = false;
}
/// <summary>
/// Return true if the character is sprinting, false otherwise.
/// </summary>
public bool IsSprinting()
{
return _isSprinting;
}
/// <summary>
/// Determines if the character, is able to sprint in its current state.
/// </summary>
private bool CanSprint()
{
return _character.IsWalking() && !_character.IsCrouched();
}
/// <summary>
/// Handles sprint input and adjusts character speed accordingly.
/// </summary>
private void CheckSprintInput()
{
if (!_isSprinting && _sprintInputPressed && CanSprint())
{
_isSprinting = true;
_cachedMaxWalkSpeed = _character.maxWalkSpeed;
_character.maxWalkSpeed = maxSprintSpeed;
}
else if (_isSprinting && (!_sprintInputPressed || !CanSprint()))
{
_isSprinting = false;
_character.maxWalkSpeed = _cachedMaxWalkSpeed;
}
}
private void OnBeforeSimulationUpdated(float deltaTime)
{
// Handle sprinting
CheckSprintInput();
}
private void Awake()
{
// Cache character
_character = GetComponent<Character>();
}
private void OnEnable()
{
// Subscribe to Character BeforeSimulationUpdated event
_character.BeforeSimulationUpdated += OnBeforeSimulationUpdated;
}
private void OnDisable()
{
// Un-Subscribe from Character BeforeSimulationUpdated event
_character.BeforeSimulationUpdated -= OnBeforeSimulationUpdated;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ea4bc13934a49484bb0606e7a1ff4f76
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,76 +0,0 @@
using ECM2.Examples;
using UnityEngine.InputSystem;
namespace ECM2.Walkthrough.Ex42
{
/// <summary>
/// Extends CharacterInput adding support to handle the Sprint Ability.
/// </summary>
public class SprintAbilityInput : CharacterInput
{
// The Sprint Ability
private SprintAbility _sprintAbility;
/// <summary>
/// Sprint InputAction.
/// </summary>
public InputAction sprintInputAction { get; set; }
/// <summary>
/// Sprint InputAction handler.
/// </summary>
public virtual void OnSprint(InputAction.CallbackContext context)
{
if (context.started)
_sprintAbility.Sprint();
else if (context.canceled)
_sprintAbility.StopSprinting();
}
protected override void InitPlayerInput()
{
base.InitPlayerInput();
// Setup Sprint input action handlers
sprintInputAction = inputActionsAsset.FindAction("Sprint");
if (sprintInputAction != null)
{
sprintInputAction.started += OnSprint;
sprintInputAction.canceled += OnSprint;
sprintInputAction.Enable();
}
}
protected override void DeinitPlayerInput()
{
base.DeinitPlayerInput();
if (sprintInputAction != null)
{
sprintInputAction.started -= OnSprint;
sprintInputAction.canceled -= OnSprint;
sprintInputAction.Disable();
sprintInputAction = null;
}
}
protected override void Awake()
{
// Call base method implementation (a MUST)
base.Awake();
// Cache character sprint ability component
_sprintAbility = GetComponent<SprintAbility>();
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 4213399d96084b888c737cbc95143458
timeCreated: 1700116698

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 6d26fb9929014f51915cce2a9f023be5
timeCreated: 1700267762

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 357780a279e73d64f9b373214e2dcd3c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 92438bd78d11492aac3ba50f0a94bb22
timeCreated: 1700267822

View File

@@ -1,192 +0,0 @@
using UnityEngine;
namespace ECM2.Walkthrough.Ex43
{
/// <summary>
/// This example shows how to extend a Character (through inheritance) adding a custom movement mode;
/// in this case, a Dash mechanic.
/// </summary>
public class DashingCharacter : Character
{
#region ENUMS
public enum ECustomMovementMode
{
None,
Dashing
}
#endregion
#region EDITOR EXPOSED FIELDS
[Space(15.0f)]
[Tooltip("Is the character able to Dash?")]
public bool canEverDash = true;
[Tooltip("Dash initial impulse.")]
public float dashImpulse = 20.0f;
[Tooltip("Dash duration in seconds.")]
public float dashDuration = 0.15f;
#endregion
#region FIELDS
protected float _dashingTime;
protected bool _dashInputPressed;
#endregion
#region PROPERTIES
/// <summary>
/// Ture if dash input is pressed, false otherwise.
/// </summary>
protected bool dashInputPressed => _dashInputPressed;
#endregion
#region METHODS
/// <summary>
/// Is the character currently dashing?
/// </summary>
public bool IsDashing()
{
return movementMode == MovementMode.Custom && customMovementMode == (int)ECustomMovementMode.Dashing;
}
/// <summary>
/// Request to perform a dash.
/// The request is processed on the next simulation update.
/// Call this from an input event (such as a button 'down' event).
/// </summary>
public void Dash()
{
_dashInputPressed = true;
}
/// <summary>
/// Request to stop dashing.
/// The request is processed on the next simulation update.
/// Call this from an input event (such as a button 'up' event).
/// </summary>
public void StopDashing()
{
_dashInputPressed = false;
}
/// <summary>
/// Determines if the Character is able to dash in its current state.
/// Defaults to Walking or Falling while NOT crouched.
/// </summary>
public bool IsDashAllowed()
{
if (IsCrouched())
return false;
return canEverDash && (IsWalking() || IsFalling());
}
/// <summary>
/// Perform dash.
/// </summary>
protected virtual void DoDash()
{
// Apply dash impulse along input direction (if any) or along character's forward
Vector3 dashDirection = GetMovementDirection();
if (dashDirection.isZero())
dashDirection = GetForwardVector();
Vector3 dashDirection2D = dashDirection.onlyXZ().normalized;
SetVelocity(dashDirection2D * dashImpulse);
// Change to dashing movement mode
SetMovementMode(MovementMode.Custom, (int)ECustomMovementMode.Dashing);
// Lock rotation towards dashing direction
if (rotationMode == RotationMode.OrientRotationToMovement)
SetRotation(Quaternion.LookRotation(dashDirection2D));
}
/// <summary>
/// Reset dashing state and exit dashing movement mode.
/// </summary>
protected virtual void ResetDashState()
{
// Reset dashing state
_dashingTime = 0.0f;
_dashInputPressed = false;
// Clear dashing impulse
SetVelocity(Vector3.zero);
// Falling is auto-manged state so its safe to use as an exit state.
SetMovementMode(MovementMode.Falling);
}
/// <summary>
/// Update dashing movement mode.
/// </summary>
protected virtual void DashingMovementMode(float deltaTime)
{
// This prevents the character from rotate towards a movement direction
SetMovementDirection(Vector3.zero);
// Update dash timer...
_dashingTime += deltaTime;
if (_dashingTime >= dashDuration)
{
// If completed, exit dash state
ResetDashState();
}
}
protected override void OnBeforeSimulationUpdate(float deltaTime)
{
// Call base method implementation
base.OnBeforeSimulationUpdate(deltaTime);
// Attempts to start a requested dash
if (!IsDashing() && dashInputPressed && IsDashAllowed())
DoDash();
}
protected override void CustomMovementMode(float deltaTime)
{
// Call base method implementation
base.CustomMovementMode(deltaTime);
// Update dashing movement mode
if (customMovementMode == (int)ECustomMovementMode.Dashing)
DashingMovementMode(deltaTime);
}
#endregion
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: fab4444b2b79402da8541e78d971cd89
timeCreated: 1700267844

View File

@@ -1,73 +0,0 @@
using ECM2.Examples;
using UnityEngine.InputSystem;
namespace ECM2.Walkthrough.Ex43
{
/// <summary>
/// Extends CharacterInput adding support to handle Dash mechanic.
/// </summary>
public class DashingCharacterInput : CharacterInput
{
private DashingCharacter _dashingCharacter;
/// <summary>
/// Dash InputAction.
/// </summary>
public InputAction dashInputAction { get; set; }
/// <summary>
/// Sprint InputAction handler.
/// </summary>
public virtual void OnDash(InputAction.CallbackContext context)
{
if (context.started)
_dashingCharacter.Dash();
else if (context.canceled)
_dashingCharacter.StopDashing();
}
protected override void InitPlayerInput()
{
base.InitPlayerInput();
// Setup Sprint input action handlers
dashInputAction = inputActionsAsset.FindAction("Interact");
if (dashInputAction != null)
{
dashInputAction.started += OnDash;
dashInputAction.canceled += OnDash;
dashInputAction.Enable();
}
}
protected override void DeinitPlayerInput()
{
base.DeinitPlayerInput();
if (dashInputAction != null)
{
dashInputAction.started -= OnDash;
dashInputAction.canceled -= OnDash;
dashInputAction.Disable();
dashInputAction = null;
}
}
protected override void Awake()
{
// Call base method implementation (a MUST)
base.Awake();
// Cache DashingCharacter
_dashingCharacter = character as DashingCharacter;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 870821bf5541ca240b0f6eebcb635f97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: