This commit is contained in:
2025-05-11 00:46:26 +08:00
parent 366f9e95ec
commit 618f75f911
2404 changed files with 154475 additions and 924730 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 68a3136a575f419d888319ec1ee3a977
timeCreated: 1700173831

View File

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

View File

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

View File

@@ -0,0 +1,92 @@
using UnityEngine;
namespace ECM2.Walkthrough.Ex51
{
/// <summary>
/// This example shows how to handle Character events when extending a Character through inheritance.
/// </summary>
public class PlayerCharacter : Character
{
protected override void OnCollided(ref CollisionResult collisionResult)
{
// Call base method implementation
base.OnCollided(ref collisionResult);
// Add your code here...
Debug.Log($"Collided with {collisionResult.collider.name}");
}
protected override void OnFoundGround(ref FindGroundResult foundGround)
{
// Call base method implementation
base.OnFoundGround(ref foundGround);
// Add your code here...
Debug.Log($"Found {foundGround.collider.name} ground");
}
protected override void OnLanded(Vector3 landingVelocity)
{
// Call base method implementation
base.OnLanded(landingVelocity);
// Add your code here...
Debug.Log($"Landed with {landingVelocity:F4} landing velocity.");
}
protected override void OnCrouched()
{
// Call base method implementation
base.OnCrouched();
// Add your code here...
Debug.Log("Crouched");
}
protected override void OnUnCrouched()
{
// Call base method implementation
base.OnUnCrouched();
// Add your code here...
Debug.Log("UnCrouched");
}
protected override void OnJumped()
{
// Call base method implementation
base.OnJumped();
// Add your code here...
Debug.Log("Jumped!");
// Enable apex notification event
notifyJumpApex = true;
}
protected override void OnReachedJumpApex()
{
// Call base method implementation
base.OnReachedJumpApex();
// Add your code here...
Debug.Log($"Apex reached {GetVelocity():F4}");
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c8d7237bdbeb48bb8206383a09c25b67
timeCreated: 1700173847

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b678c156abb8426bbdf3d7ed245e0c4c
timeCreated: 1700175120

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: badc34f9953d46e7adb11e016d6354a8
timeCreated: 1700175243

View File

@@ -0,0 +1,89 @@
using UnityEngine;
namespace ECM2.Walkthrough.Ex52
{
/// <summary>
/// This example shows how to listen to Character events when extending a Character through composition.
/// </summary>
public class PlayerController : MonoBehaviour
{
// Our controlled Character
[SerializeField]
private Character _character;
protected void OnCollided(ref CollisionResult collisionResult)
{
Debug.Log($"Collided with {collisionResult.collider.name}");
}
protected void OnFoundGround(ref FindGroundResult foundGround)
{
Debug.Log($"Found {foundGround.collider.name} ground");
}
protected void OnLanded(Vector3 landingVelocity)
{
Debug.Log($"Landed with {landingVelocity:F4} landing velocity.");
}
protected void OnCrouched()
{
Debug.Log("Crouched");
}
protected void OnUnCrouched()
{
Debug.Log("UnCrouched");
}
protected void OnJumped()
{
Debug.Log("Jumped!");
// Enable apex notification event
_character.notifyJumpApex = true;
}
protected void OnReachedJumpApex()
{
Debug.Log($"Apex reached {_character.GetVelocity():F4}");
}
private void Awake()
{
// If Character is not assigned, look into this GameObject
if (_character == null)
_character = GetComponent<Character>();
}
private void OnEnable()
{
// Subscribe to Character events
_character.Collided += OnCollided;
_character.FoundGround += OnFoundGround;
_character.Landed += OnLanded;
_character.Crouched += OnCrouched;
_character.UnCrouched += OnUnCrouched;
_character.Jumped += OnJumped;
_character.ReachedJumpApex += OnReachedJumpApex;
}
private void OnDisable()
{
// Un-subscribe from Character events
_character.Collided -= OnCollided;
_character.FoundGround -= OnFoundGround;
_character.Landed -= OnLanded;
_character.Crouched -= OnCrouched;
_character.UnCrouched -= OnUnCrouched;
_character.Jumped -= OnJumped;
_character.ReachedJumpApex -= OnReachedJumpApex;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e2bc2d1320241eb8fae230508f17ce1
timeCreated: 1700175269