Initial commit
This commit is contained in:
8
Assets/Darkmatter/Code/App.meta
Normal file
8
Assets/Darkmatter/Code/App.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93a4de42455f8314a8c151cad36eeae7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Darkmatter/Code/App/AppAssembly.asmdef
Normal file
19
Assets/Darkmatter/Code/App/AppAssembly.asmdef
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "AppAssembly",
|
||||
"rootNamespace": "Darkmatter.App",
|
||||
"references": [
|
||||
"GUID:cf1df9e1968a94c4686f2fbe5ef907fc",
|
||||
"GUID:23f9a018fbd2e1242a0525718cc761d6",
|
||||
"GUID:00bcf444fe1ffd8468345b96caa37633",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Darkmatter/Code/App/AppAssembly.asmdef.meta
Normal file
7
Assets/Darkmatter/Code/App/AppAssembly.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 634a2668b4427c140ab4cd0b6ff07cf0
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/App/Installers.meta
Normal file
8
Assets/Darkmatter/Code/App/Installers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b97998e69a0f10b49982804ea1cbc704
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Darkmatter/Code/App/Installers/GameLifetimeScope.cs
Normal file
31
Assets/Darkmatter/Code/App/Installers/GameLifetimeScope.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
using UnityEngine;
|
||||
using Darkmatter.Core;
|
||||
using Darkmatter.Presentation;
|
||||
using Darkmatter.Domain;
|
||||
|
||||
namespace Darkmatter.App
|
||||
{
|
||||
public class GameLifetimeScope : LifetimeScope
|
||||
{
|
||||
[SerializeField] private InputReaderSO inputReader;
|
||||
[SerializeField] private PlayerMotor playerMotor;
|
||||
[SerializeField] private PlayerAnimController playerAnim;
|
||||
[SerializeField] private PlayerConfigSO playerConfig;
|
||||
[SerializeField] private CameraConfigSO cameraConfig;
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterEntryPoint<PlayerController>(Lifetime.Scoped);
|
||||
|
||||
|
||||
builder.RegisterComponent<IPlayerAnim>(playerAnim);
|
||||
builder.RegisterComponent<IInputReader>(inputReader);
|
||||
builder.RegisterComponent<IPlayerPawn>(playerMotor);
|
||||
|
||||
builder.RegisterComponent(playerConfig);
|
||||
builder.RegisterComponent(cameraConfig);
|
||||
builder.Register<PlayerStateMachine>(Lifetime.Scoped);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90318e5b70a6fc243bdcac1edeafdc26
|
||||
8
Assets/Darkmatter/Code/Core.meta
Normal file
8
Assets/Darkmatter/Code/Core.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ac8a646cb9db814691d916d36df5d42
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Core/Attributes.meta
Normal file
8
Assets/Darkmatter/Code/Core/Attributes.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca988c75cd51455438944bcbd9e51e4a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
473
Assets/Darkmatter/Code/Core/Attributes/GameInputAction.cs
Normal file
473
Assets/Darkmatter/Code/Core/Attributes/GameInputAction.cs
Normal file
@@ -0,0 +1,473 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||
// version 1.16.0
|
||||
// from Assets/Darkmatter/Code/Core/Attributes/GameInputAction.inputactions
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Provides programmatic access to <see cref="InputActionAsset" />, <see cref="InputActionMap" />, <see cref="InputAction" /> and <see cref="InputControlScheme" /> instances defined in asset "Assets/Darkmatter/Code/Core/Attributes/GameInputAction.inputactions".
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// using namespace UnityEngine;
|
||||
/// using UnityEngine.InputSystem;
|
||||
///
|
||||
/// // Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface.
|
||||
/// public class Example : MonoBehaviour, MyActions.IPlayerActions
|
||||
/// {
|
||||
/// private MyActions_Actions m_Actions; // Source code representation of asset.
|
||||
/// private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map.
|
||||
///
|
||||
/// void Awake()
|
||||
/// {
|
||||
/// m_Actions = new MyActions_Actions(); // Create asset object.
|
||||
/// m_Player = m_Actions.Player; // Extract action map object.
|
||||
/// m_Player.AddCallbacks(this); // Register callback interface IPlayerActions.
|
||||
/// }
|
||||
///
|
||||
/// void OnDestroy()
|
||||
/// {
|
||||
/// m_Actions.Dispose(); // Destroy asset object.
|
||||
/// }
|
||||
///
|
||||
/// void OnEnable()
|
||||
/// {
|
||||
/// m_Player.Enable(); // Enable all actions within map.
|
||||
/// }
|
||||
///
|
||||
/// void OnDisable()
|
||||
/// {
|
||||
/// m_Player.Disable(); // Disable all actions within map.
|
||||
/// }
|
||||
///
|
||||
/// #region Interface implementation of MyActions.IPlayerActions
|
||||
///
|
||||
/// // Invoked when "Move" action is either started, performed or canceled.
|
||||
/// public void OnMove(InputAction.CallbackContext context)
|
||||
/// {
|
||||
/// Debug.Log($"OnMove: {context.ReadValue<Vector2>()}");
|
||||
/// }
|
||||
///
|
||||
/// // Invoked when "Attack" action is either started, performed or canceled.
|
||||
/// public void OnAttack(InputAction.CallbackContext context)
|
||||
/// {
|
||||
/// Debug.Log($"OnAttack: {context.ReadValue<float>()}");
|
||||
/// }
|
||||
///
|
||||
/// #endregion
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public partial class @GameInputAction: IInputActionCollection2, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the underlying asset instance.
|
||||
/// </summary>
|
||||
public InputActionAsset asset { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance.
|
||||
/// </summary>
|
||||
public @GameInputAction()
|
||||
{
|
||||
asset = InputActionAsset.FromJson(@"{
|
||||
""version"": 1,
|
||||
""name"": ""GameInputAction"",
|
||||
""maps"": [
|
||||
{
|
||||
""name"": ""Player"",
|
||||
""id"": ""27b49db9-cdaa-4c5d-b2ad-d831b5dc2c1e"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Move"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""8bfb6cfb-d9e7-4ba7-a313-08b747a63a32"",
|
||||
""expectedControlType"": ""Vector2"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Look"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""ed597e1d-41bd-4f1e-8f95-fb3c1d4b429d"",
|
||||
""expectedControlType"": ""Vector2"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Jump"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""53dba523-5d33-4853-aa2d-e8ab36d30935"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Shoot"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""be355a51-5e28-496b-b053-9b146c674a73"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": ""2D Vector"",
|
||||
""id"": ""1374b7a8-751a-479d-bac6-a369bdf8c06c"",
|
||||
""path"": ""2DVector"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""up"",
|
||||
""id"": ""06bce7b9-5889-4c8f-8113-e0f2d7a2032e"",
|
||||
""path"": ""<Keyboard>/w"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""down"",
|
||||
""id"": ""36b8831d-57f9-48f6-afe4-ac3358177cfa"",
|
||||
""path"": ""<Keyboard>/s"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""left"",
|
||||
""id"": ""31559f64-86a8-4335-bf3f-fa7075672b1c"",
|
||||
""path"": ""<Keyboard>/a"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""right"",
|
||||
""id"": ""18cbab68-cfe2-4665-8cf1-87508fa7bc7f"",
|
||||
""path"": ""<Keyboard>/d"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""7cea6552-cc07-4fb9-8719-e5232ff6386f"",
|
||||
""path"": ""<Mouse>/delta"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Look"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""2d15cf45-d15c-4d32-b8d4-65e5f0305405"",
|
||||
""path"": ""<Keyboard>/space"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Jump"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""ffac9107-c879-4a8d-88bf-58909dcf769b"",
|
||||
""path"": ""<Mouse>/leftButton"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Shoot"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": []
|
||||
}");
|
||||
// Player
|
||||
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
|
||||
m_Player_Move = m_Player.FindAction("Move", throwIfNotFound: true);
|
||||
m_Player_Look = m_Player.FindAction("Look", throwIfNotFound: true);
|
||||
m_Player_Jump = m_Player.FindAction("Jump", throwIfNotFound: true);
|
||||
m_Player_Shoot = m_Player.FindAction("Shoot", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
~@GameInputAction()
|
||||
{
|
||||
UnityEngine.Debug.Assert(!m_Player.enabled, "This will cause a leak and performance issues, GameInputAction.Player.Disable() has not been called.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys this asset and all associated <see cref="InputAction"/> instances.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Object.Destroy(asset);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindingMask" />
|
||||
public InputBinding? bindingMask
|
||||
{
|
||||
get => asset.bindingMask;
|
||||
set => asset.bindingMask = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.devices" />
|
||||
public ReadOnlyArray<InputDevice>? devices
|
||||
{
|
||||
get => asset.devices;
|
||||
set => asset.devices = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.controlSchemes" />
|
||||
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Contains(InputAction)" />
|
||||
public bool Contains(InputAction action)
|
||||
{
|
||||
return asset.Contains(action);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.GetEnumerator()" />
|
||||
public IEnumerator<InputAction> GetEnumerator()
|
||||
{
|
||||
return asset.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEnumerable.GetEnumerator()" />
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Enable()" />
|
||||
public void Enable()
|
||||
{
|
||||
asset.Enable();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Disable()" />
|
||||
public void Disable()
|
||||
{
|
||||
asset.Disable();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindings" />
|
||||
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindAction(string, bool)" />
|
||||
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||
{
|
||||
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindBinding(InputBinding, out InputAction)" />
|
||||
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||
{
|
||||
return asset.FindBinding(bindingMask, out action);
|
||||
}
|
||||
|
||||
// Player
|
||||
private readonly InputActionMap m_Player;
|
||||
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
|
||||
private readonly InputAction m_Player_Move;
|
||||
private readonly InputAction m_Player_Look;
|
||||
private readonly InputAction m_Player_Jump;
|
||||
private readonly InputAction m_Player_Shoot;
|
||||
/// <summary>
|
||||
/// Provides access to input actions defined in input action map "Player".
|
||||
/// </summary>
|
||||
public struct PlayerActions
|
||||
{
|
||||
private @GameInputAction m_Wrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of the input action map wrapper class.
|
||||
/// </summary>
|
||||
public PlayerActions(@GameInputAction wrapper) { m_Wrapper = wrapper; }
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/Move".
|
||||
/// </summary>
|
||||
public InputAction @Move => m_Wrapper.m_Player_Move;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/Look".
|
||||
/// </summary>
|
||||
public InputAction @Look => m_Wrapper.m_Player_Look;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/Jump".
|
||||
/// </summary>
|
||||
public InputAction @Jump => m_Wrapper.m_Player_Jump;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/Shoot".
|
||||
/// </summary>
|
||||
public InputAction @Shoot => m_Wrapper.m_Player_Shoot;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action map instance.
|
||||
/// </summary>
|
||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Enable()" />
|
||||
public void Enable() { Get().Enable(); }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Disable()" />
|
||||
public void Disable() { Get().Disable(); }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.enabled" />
|
||||
public bool enabled => Get().enabled;
|
||||
/// <summary>
|
||||
/// Implicitly converts an <see ref="PlayerActions" /> to an <see ref="InputActionMap" /> instance.
|
||||
/// </summary>
|
||||
public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); }
|
||||
/// <summary>
|
||||
/// Adds <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||
/// </summary>
|
||||
/// <param name="instance">Callback instance.</param>
|
||||
/// <remarks>
|
||||
/// If <paramref name="instance" /> is <c>null</c> or <paramref name="instance"/> have already been added this method does nothing.
|
||||
/// </remarks>
|
||||
/// <seealso cref="PlayerActions" />
|
||||
public void AddCallbacks(IPlayerActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_PlayerActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_PlayerActionsCallbackInterfaces.Add(instance);
|
||||
@Move.started += instance.OnMove;
|
||||
@Move.performed += instance.OnMove;
|
||||
@Move.canceled += instance.OnMove;
|
||||
@Look.started += instance.OnLook;
|
||||
@Look.performed += instance.OnLook;
|
||||
@Look.canceled += instance.OnLook;
|
||||
@Jump.started += instance.OnJump;
|
||||
@Jump.performed += instance.OnJump;
|
||||
@Jump.canceled += instance.OnJump;
|
||||
@Shoot.started += instance.OnShoot;
|
||||
@Shoot.performed += instance.OnShoot;
|
||||
@Shoot.canceled += instance.OnShoot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Calling this method when <paramref name="instance" /> have not previously been registered has no side-effects.
|
||||
/// </remarks>
|
||||
/// <seealso cref="PlayerActions" />
|
||||
private void UnregisterCallbacks(IPlayerActions instance)
|
||||
{
|
||||
@Move.started -= instance.OnMove;
|
||||
@Move.performed -= instance.OnMove;
|
||||
@Move.canceled -= instance.OnMove;
|
||||
@Look.started -= instance.OnLook;
|
||||
@Look.performed -= instance.OnLook;
|
||||
@Look.canceled -= instance.OnLook;
|
||||
@Jump.started -= instance.OnJump;
|
||||
@Jump.performed -= instance.OnJump;
|
||||
@Jump.canceled -= instance.OnJump;
|
||||
@Shoot.started -= instance.OnShoot;
|
||||
@Shoot.performed -= instance.OnShoot;
|
||||
@Shoot.canceled -= instance.OnShoot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters <param cref="instance" /> and unregisters all input action callbacks via <see cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />
|
||||
public void RemoveCallbacks(IPlayerActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_PlayerActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via <param cref="instance" />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If <paramref name="instance" /> is <c>null</c>, calling this method will only unregister all existing callbacks but not register any new callbacks.
|
||||
/// </remarks>
|
||||
/// <seealso cref="PlayerActions.AddCallbacks(IPlayerActions)" />
|
||||
/// <seealso cref="PlayerActions.RemoveCallbacks(IPlayerActions)" />
|
||||
/// <seealso cref="PlayerActions.UnregisterCallbacks(IPlayerActions)" />
|
||||
public void SetCallbacks(IPlayerActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_PlayerActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_PlayerActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Provides a new <see cref="PlayerActions" /> instance referencing this action map.
|
||||
/// </summary>
|
||||
public PlayerActions @Player => new PlayerActions(this);
|
||||
/// <summary>
|
||||
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Player" which allows adding and removing callbacks.
|
||||
/// </summary>
|
||||
/// <seealso cref="PlayerActions.AddCallbacks(IPlayerActions)" />
|
||||
/// <seealso cref="PlayerActions.RemoveCallbacks(IPlayerActions)" />
|
||||
public interface IPlayerActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Move" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnMove(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Look" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnLook(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Jump" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnJump(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Shoot" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnShoot(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e695ec5d7a02e6429a5df4a6ef6c5c8
|
||||
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"version": 1,
|
||||
"name": "GameInputAction",
|
||||
"maps": [
|
||||
{
|
||||
"name": "Player",
|
||||
"id": "27b49db9-cdaa-4c5d-b2ad-d831b5dc2c1e",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Move",
|
||||
"type": "Value",
|
||||
"id": "8bfb6cfb-d9e7-4ba7-a313-08b747a63a32",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "Look",
|
||||
"type": "Value",
|
||||
"id": "ed597e1d-41bd-4f1e-8f95-fb3c1d4b429d",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "Jump",
|
||||
"type": "Button",
|
||||
"id": "53dba523-5d33-4853-aa2d-e8ab36d30935",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Shoot",
|
||||
"type": "Button",
|
||||
"id": "be355a51-5e28-496b-b053-9b146c674a73",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "2D Vector",
|
||||
"id": "1374b7a8-751a-479d-bac6-a369bdf8c06c",
|
||||
"path": "2DVector",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "up",
|
||||
"id": "06bce7b9-5889-4c8f-8113-e0f2d7a2032e",
|
||||
"path": "<Keyboard>/w",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "down",
|
||||
"id": "36b8831d-57f9-48f6-afe4-ac3358177cfa",
|
||||
"path": "<Keyboard>/s",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "left",
|
||||
"id": "31559f64-86a8-4335-bf3f-fa7075672b1c",
|
||||
"path": "<Keyboard>/a",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "right",
|
||||
"id": "18cbab68-cfe2-4665-8cf1-87508fa7bc7f",
|
||||
"path": "<Keyboard>/d",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "7cea6552-cc07-4fb9-8719-e5232ff6386f",
|
||||
"path": "<Mouse>/delta",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Look",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "2d15cf45-d15c-4d32-b8d4-65e5f0305405",
|
||||
"path": "<Keyboard>/space",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Jump",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "ffac9107-c879-4a8d-88bf-58909dcf769b",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Shoot",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": []
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc05be0d61af0a743bf4ebf3f66a6351
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 1
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
8
Assets/Darkmatter/Code/Core/Contracts.meta
Normal file
8
Assets/Darkmatter/Code/Core/Contracts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dacda5e48fada546bc6f576be3e1510
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Core/Contracts/Player.meta
Normal file
8
Assets/Darkmatter/Code/Core/Contracts/Player.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1df03228b6e72bc4397493f4ed9f8ba7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public interface IHumonoidAnim
|
||||
{
|
||||
void PlayJumpAnim();
|
||||
void PlayMovementAnim(Vector2 velocity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a12b671db097ec4ca9a6d81b9843c9e
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public interface IPlayerAnim : IHumonoidAnim
|
||||
{
|
||||
void PlayShootAnim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b737e58ea9c4574abb8e4c7c5b8eaa0
|
||||
15
Assets/Darkmatter/Code/Core/Contracts/Player/IPlayerPawn.cs
Normal file
15
Assets/Darkmatter/Code/Core/Contracts/Player/IPlayerPawn.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public interface IPlayerPawn
|
||||
{
|
||||
Camera mainCamera { get; }
|
||||
bool isGrounded { get; }
|
||||
|
||||
void Jump(float jumpForce);
|
||||
|
||||
void Move(Vector3 motion);
|
||||
void SetCameraRotation(float pitch, float yaw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2804a4028b617e43a4dc4049b19c5b5
|
||||
8
Assets/Darkmatter/Code/Core/Contracts/Services.meta
Normal file
8
Assets/Darkmatter/Code/Core/Contracts/Services.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3cc373d4ed1bd94ba433029245b72f5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public interface IInputReader
|
||||
{
|
||||
public event Action OnJumpPerformed;
|
||||
public Vector2 moveInput { get; }
|
||||
public Vector2 lookInput { get; }
|
||||
public bool isShooting { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45f4fffcfa5f98247af8885708c3e11d
|
||||
8
Assets/Darkmatter/Code/Core/Contracts/States.meta
Normal file
8
Assets/Darkmatter/Code/Core/Contracts/States.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3d1c4314960db14dbc459d446baba49
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Darkmatter/Code/Core/Contracts/States/IState.cs
Normal file
13
Assets/Darkmatter/Code/Core/Contracts/States/IState.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public interface IState
|
||||
{
|
||||
void Enter();
|
||||
void Update();
|
||||
|
||||
void LateUpdate();
|
||||
void Exit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3508c66c9649d76439537bb7e9532896
|
||||
16
Assets/Darkmatter/Code/Core/CoreAssembly.asmdef
Normal file
16
Assets/Darkmatter/Code/Core/CoreAssembly.asmdef
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "CoreAssembly",
|
||||
"rootNamespace": "Darkmatter.Core",
|
||||
"references": [
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Darkmatter/Code/Core/CoreAssembly.asmdef.meta
Normal file
7
Assets/Darkmatter/Code/Core/CoreAssembly.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf1df9e1968a94c4686f2fbe5ef907fc
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Core/Data.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7270f123c7fea841a3c10737e9f13ba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Core/Data/Camera.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data/Camera.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92f3f5d5f5ea93d44b2a724fb4b4e41f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Darkmatter/Code/Core/Data/Camera/CameraConfigSO.asset
Normal file
17
Assets/Darkmatter/Code/Core/Data/Camera/CameraConfigSO.asset
Normal file
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
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: 0874d02cb2d9daa4883a09464ed19de2, type: 3}
|
||||
m_Name: CameraConfigSO
|
||||
m_EditorClassIdentifier: CoreAssembly::Darkmatter.Core.CameraConfigSO
|
||||
lookSensitivity: 10
|
||||
topClampAngle: 50
|
||||
bottomClampAngle: -30
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e862049a6864bb347903dec038b0ba28
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/Darkmatter/Code/Core/Data/Camera/CameraConfigSO.cs
Normal file
12
Assets/Darkmatter/Code/Core/Data/Camera/CameraConfigSO.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
[CreateAssetMenu(fileName = "CameraConfigSO", menuName = "Scriptable Objects/CameraConfigSO")]
|
||||
public class CameraConfigSO : ScriptableObject
|
||||
{
|
||||
public float lookSensitivity = 10f;
|
||||
public float topClampAngle = 50f;
|
||||
public float bottomClampAngle = -30f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0874d02cb2d9daa4883a09464ed19de2
|
||||
8
Assets/Darkmatter/Code/Core/Data/Input.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data/Input.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 301dfab9095361c4396c288e6108c540
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.asset
Normal file
14
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.asset
Normal file
@@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
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: 94786f68f321b5249b0997193bb0036b, type: 3}
|
||||
m_Name: InputReaderSO
|
||||
m_EditorClassIdentifier: CoreAssembly::Darkmatter.Core.InputReaderSO
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0805b8520c4573a4e99ea101253c2c9f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
57
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.cs
Normal file
57
Assets/Darkmatter/Code/Core/Data/Input/InputReaderSO.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
[CreateAssetMenu(fileName = "InputReaderSO", menuName = "Scriptable Objects/InputReaderSO")]
|
||||
public class InputReaderSO : ScriptableObject, IInputReader, GameInputAction.IPlayerActions
|
||||
{
|
||||
public GameInputAction action;
|
||||
|
||||
public event Action OnJumpPerformed;
|
||||
public bool isShooting { get; private set; }
|
||||
public Vector2 moveInput { get; private set; }
|
||||
public Vector2 lookInput { get; private set; }
|
||||
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
action = new GameInputAction();
|
||||
}
|
||||
action.Enable();
|
||||
action.Player.SetCallbacks(this);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
action.Player.Disable();
|
||||
}
|
||||
public void OnMove(InputAction.CallbackContext context)
|
||||
{
|
||||
moveInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
|
||||
public void OnLook(InputAction.CallbackContext context)
|
||||
{
|
||||
lookInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
{
|
||||
if(context.performed)
|
||||
{
|
||||
OnJumpPerformed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnShoot(InputAction.CallbackContext context)
|
||||
{
|
||||
isShooting = context.ReadValueAsButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94786f68f321b5249b0997193bb0036b
|
||||
8
Assets/Darkmatter/Code/Core/Data/Player.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data/Player.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdb59f39fa76d4d4580e1c5f97feb817
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Darkmatter/Code/Core/Data/Player/PlayerConfigSO.asset
Normal file
17
Assets/Darkmatter/Code/Core/Data/Player/PlayerConfigSO.asset
Normal file
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
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: d868e8202f5ceae4ea496e56b0db9db9, type: 3}
|
||||
m_Name: PlayerConfigSO
|
||||
m_EditorClassIdentifier: CoreAssembly::Darkmatter.Core.PlayerConfigSO
|
||||
moveSpeed: 3
|
||||
jumpForce: 5
|
||||
gravity: -15
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 893990031b7e34e48aec7db96883252f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/Darkmatter/Code/Core/Data/Player/PlayerConfigSO.cs
Normal file
12
Assets/Darkmatter/Code/Core/Data/Player/PlayerConfigSO.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
[CreateAssetMenu(fileName = "PlayerConfigSO", menuName = "Scriptable Objects/PlayerConfigSO")]
|
||||
public class PlayerConfigSO : ScriptableObject
|
||||
{
|
||||
public float moveSpeed = 3.0f;
|
||||
public float jumpForce = 5f;
|
||||
public float gravity = -15f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d868e8202f5ceae4ea496e56b0db9db9
|
||||
8
Assets/Darkmatter/Code/Core/Utility.meta
Normal file
8
Assets/Darkmatter/Code/Core/Utility.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04e91ccf19676b842a97a52f9ac4fd3a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/Darkmatter/Code/Core/Utility/DMUtil.cs
Normal file
12
Assets/Darkmatter/Code/Core/Utility/DMUtil.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public static class DMUtil
|
||||
{
|
||||
public static void Show()
|
||||
{
|
||||
Debug.Log("Showin from utility");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Darkmatter/Code/Core/Utility/DMUtil.cs.meta
Normal file
2
Assets/Darkmatter/Code/Core/Utility/DMUtil.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab244149b74d77646b0246b556a1e7c9
|
||||
8
Assets/Darkmatter/Code/Domain.meta
Normal file
8
Assets/Darkmatter/Code/Domain.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a05f68cccf2d0b740ab6b40a5debb196
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Darkmatter/Code/Domain/DomainAssembly.asmdef
Normal file
18
Assets/Darkmatter/Code/Domain/DomainAssembly.asmdef
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "DomainAssembly",
|
||||
"rootNamespace": "Darkmatter.Domain",
|
||||
"references": [
|
||||
"GUID:cf1df9e1968a94c4686f2fbe5ef907fc",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Darkmatter/Code/Domain/DomainAssembly.asmdef.meta
Normal file
7
Assets/Darkmatter/Code/Domain/DomainAssembly.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23f9a018fbd2e1242a0525718cc761d6
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Domain/Player.meta
Normal file
8
Assets/Darkmatter/Code/Domain/Player.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20d2b82ece3161e438ff1f7d82fb92af
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/Darkmatter/Code/Domain/Player/AirboneState.cs
Normal file
53
Assets/Darkmatter/Code/Domain/Player/AirboneState.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Domain
|
||||
{
|
||||
public class AirboneState : State<PlayerStateMachine>
|
||||
{
|
||||
public AirboneState(PlayerStateMachine runner) : base(runner) { }
|
||||
private IInputReader inputReader => runner.inputReader;
|
||||
private PlayerConfigSO playerConfig => runner.playerConfig;
|
||||
|
||||
|
||||
public override void Enter()
|
||||
{
|
||||
Debug.Log("Entering Player AirboneState ");
|
||||
}
|
||||
public override void Update()
|
||||
{
|
||||
HandlePlayerMovement();
|
||||
CheckForStateBreak();
|
||||
}
|
||||
|
||||
public override void LateUpdate()
|
||||
{
|
||||
HandlePlayerRotation();
|
||||
}
|
||||
|
||||
public override void Exit()
|
||||
{
|
||||
Debug.Log("Exiting Player AriboneState");
|
||||
}
|
||||
|
||||
|
||||
//Airbone Functions
|
||||
private void HandlePlayerMovement()
|
||||
{
|
||||
runner.Move(inputReader.moveInput, playerConfig.moveSpeed);
|
||||
}
|
||||
|
||||
private void HandlePlayerRotation()
|
||||
{
|
||||
runner.RotateCamera(inputReader.lookInput);
|
||||
}
|
||||
|
||||
private void CheckForStateBreak()
|
||||
{
|
||||
if (runner.playerController.isGrounded)
|
||||
{
|
||||
runner.ChangeState(new LocomotionState(runner));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6149b00abd3711242a957f9998722255
|
||||
68
Assets/Darkmatter/Code/Domain/Player/LocomotionState.cs
Normal file
68
Assets/Darkmatter/Code/Domain/Player/LocomotionState.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using Darkmatter.Core;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Domain
|
||||
{
|
||||
public class LocomotionState : State<PlayerStateMachine>
|
||||
{
|
||||
public LocomotionState(PlayerStateMachine runner) : base(runner) { }
|
||||
private IInputReader inputReader => runner.inputReader;
|
||||
private PlayerConfigSO playerConfig => runner.playerConfig;
|
||||
private IPlayerAnim playerAnim => runner.playerAnim;
|
||||
public override void Enter()
|
||||
{
|
||||
Debug.Log("Starting player Locomotion");
|
||||
inputReader.OnJumpPerformed += HandlePlayerJump;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
HandlePlayerMovement();
|
||||
CheckForStateBreak();
|
||||
|
||||
}
|
||||
|
||||
public override void LateUpdate()
|
||||
{
|
||||
HandlePlayerRotation();
|
||||
}
|
||||
|
||||
public override void Exit()
|
||||
{
|
||||
Debug.Log("Exiting Player Locomotion State");
|
||||
inputReader.OnJumpPerformed -= HandlePlayerJump;
|
||||
}
|
||||
|
||||
|
||||
//Locomotion Functions
|
||||
|
||||
private void CheckForStateBreak()
|
||||
{
|
||||
if (!runner.playerController.isGrounded)
|
||||
{
|
||||
runner.ChangeState(new AirboneState(runner));
|
||||
}
|
||||
}
|
||||
|
||||
private void HandlePlayerRotation()
|
||||
{
|
||||
runner.RotateCamera(inputReader.lookInput);
|
||||
}
|
||||
|
||||
private void HandlePlayerMovement()
|
||||
{
|
||||
runner.Move(inputReader.moveInput, playerConfig.moveSpeed);
|
||||
}
|
||||
|
||||
private void HandlePlayerJump()
|
||||
{
|
||||
runner.playerController.Jump(playerConfig.jumpForce);
|
||||
playerAnim.PlayJumpAnim();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 961ad68a3149563478180fcf9d2465b6
|
||||
25
Assets/Darkmatter/Code/Domain/Player/PlayerController.cs
Normal file
25
Assets/Darkmatter/Code/Domain/Player/PlayerController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Domain
|
||||
{
|
||||
public class PlayerController : IStartable, ITickable, ILateTickable
|
||||
{
|
||||
[Inject] private PlayerStateMachine psm;
|
||||
|
||||
public void LateTick()
|
||||
{
|
||||
psm.LateUpdate();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
psm.ChangeState(new LocomotionState(psm));
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
psm.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b238eafe4c049642ae43f347d61a607
|
||||
51
Assets/Darkmatter/Code/Domain/Player/PlayerStateMachine.cs
Normal file
51
Assets/Darkmatter/Code/Domain/Player/PlayerStateMachine.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
namespace Darkmatter.Domain
|
||||
{
|
||||
public class PlayerStateMachine : StateMachine
|
||||
{
|
||||
[Inject] public readonly IPlayerPawn playerController;
|
||||
[Inject] public readonly IInputReader inputReader;
|
||||
[Inject] public readonly IPlayerAnim playerAnim;
|
||||
[Inject] public readonly PlayerConfigSO playerConfig;
|
||||
[Inject] public readonly CameraConfigSO cameraConfig;
|
||||
|
||||
private Vector3 moveDir;
|
||||
private float Yaw;
|
||||
private float pitch;
|
||||
|
||||
public void Move(Vector2 moveInputDir, float moveSpeed)
|
||||
{
|
||||
//player movement with reference to camera
|
||||
Vector3 cameraForward = playerController.mainCamera.transform.forward;
|
||||
Vector3 cameraRight = playerController.mainCamera.transform.right;
|
||||
|
||||
cameraForward.y = 0f;
|
||||
cameraRight.y = 0f;
|
||||
|
||||
cameraForward.Normalize();
|
||||
cameraRight.Normalize();
|
||||
|
||||
moveDir = cameraRight * moveInputDir.x + cameraForward * moveInputDir.y;
|
||||
|
||||
playerController.Move(moveDir * moveSpeed);
|
||||
playerAnim.PlayMovementAnim(moveInputDir);
|
||||
}
|
||||
|
||||
public void RotateCamera(Vector2 lookInput)
|
||||
{
|
||||
//camera rotation logic
|
||||
if (lookInput.sqrMagnitude > 0.01f)
|
||||
{
|
||||
Yaw += lookInput.x * cameraConfig.lookSensitivity * Time.deltaTime;
|
||||
pitch -= lookInput.y * cameraConfig.lookSensitivity * Time.deltaTime;
|
||||
}
|
||||
pitch = Mathf.Clamp(pitch, cameraConfig.bottomClampAngle, cameraConfig.topClampAngle);
|
||||
playerController.SetCameraRotation(pitch, Yaw);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad95801e56eb04840a1f2e4b2101b236
|
||||
8
Assets/Darkmatter/Code/Domain/StateMachine.meta
Normal file
8
Assets/Darkmatter/Code/Domain/StateMachine.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c700d565d4a7ff43ab86d5404cd8c88
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Darkmatter/Code/Domain/StateMachine/State.cs
Normal file
22
Assets/Darkmatter/Code/Domain/StateMachine/State.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Domain
|
||||
{
|
||||
public abstract class State<T> : IState
|
||||
{
|
||||
protected readonly T runner;
|
||||
protected State(T runner)
|
||||
{
|
||||
this.runner = runner;
|
||||
}
|
||||
|
||||
public virtual void Enter() { }
|
||||
|
||||
public virtual void Exit() { }
|
||||
|
||||
public virtual void Update() { }
|
||||
|
||||
public virtual void LateUpdate() { }
|
||||
}
|
||||
}
|
||||
2
Assets/Darkmatter/Code/Domain/StateMachine/State.cs.meta
Normal file
2
Assets/Darkmatter/Code/Domain/StateMachine/State.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e1f935f13391ea4b8a18a2c680cdcf9
|
||||
27
Assets/Darkmatter/Code/Domain/StateMachine/StateMachine.cs
Normal file
27
Assets/Darkmatter/Code/Domain/StateMachine/StateMachine.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Domain
|
||||
{
|
||||
public abstract class StateMachine
|
||||
{
|
||||
public IState CurrentState { get; private set; }
|
||||
public void ChangeState(IState state)
|
||||
{
|
||||
CurrentState?.Exit();
|
||||
CurrentState = state;
|
||||
CurrentState?.Enter();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
CurrentState.Update();
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
CurrentState.LateUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cda261417aa4df34eb86c2271ab5f6d5
|
||||
8
Assets/Darkmatter/Code/Presentation.meta
Normal file
8
Assets/Darkmatter/Code/Presentation.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3716ff60af6d7014390b535fb8a20f26
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Presentation/Animation.meta
Normal file
8
Assets/Darkmatter/Code/Presentation/Animation.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 588d14d62487efd48ae44adbf2cdfbb7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public abstract class HumonoidAnim : MonoBehaviour, IHumonoidAnim
|
||||
{
|
||||
public Animator animator;
|
||||
|
||||
protected readonly int moveXhash = Animator.StringToHash("MoveX");
|
||||
protected readonly int moveYhash = Animator.StringToHash("MoveY");
|
||||
protected readonly int jumpHash = Animator.StringToHash("Jump");
|
||||
|
||||
public void PlayMovementAnim(Vector2 velocity)
|
||||
{
|
||||
animator.SetFloat(moveXhash, velocity.x,0.4f,Time.deltaTime);
|
||||
animator.SetFloat(moveYhash, velocity.y,0.4f, Time.deltaTime);
|
||||
}
|
||||
|
||||
public void PlayJumpAnim()
|
||||
{
|
||||
animator.SetTrigger(jumpHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0456d664cb3848c4bb8a381db3fe819a
|
||||
@@ -0,0 +1,14 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class PlayerAnimController : HumonoidAnim, IPlayerAnim
|
||||
{
|
||||
private readonly int shootHash = Animator.StringToHash("IsShooting");
|
||||
public void PlayShootAnim()
|
||||
{
|
||||
Debug.Log("player Shoot");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bcf4be752bf7ad448fd187a62487726
|
||||
8
Assets/Darkmatter/Code/Presentation/Player.meta
Normal file
8
Assets/Darkmatter/Code/Presentation/Player.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61cdaef640578c9429e0b3f1a12a3e59
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
159
Assets/Darkmatter/Code/Presentation/Player/BulletRenderer.prefab
Normal file
159
Assets/Darkmatter/Code/Presentation/Player/BulletRenderer.prefab
Normal file
@@ -0,0 +1,159 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8503761475068701983
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 543925742380460365}
|
||||
- component: {fileID: 6906598175330505539}
|
||||
- component: {fileID: 8812288568393030278}
|
||||
m_Layer: 0
|
||||
m_Name: BulletRenderer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &543925742380460365
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8503761475068701983}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -9.016138, y: 2.43599, z: 10.534973}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!120 &6906598175330505539
|
||||
LineRenderer:
|
||||
serializedVersion: 3
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8503761475068701983}
|
||||
m_Enabled: 0
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 0
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 0
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_ForceMeshLod: -1
|
||||
m_MeshLodSelectionBias: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: ffcd02750402e264babfe88a9b5f9422, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_GlobalIlluminationMeshLod: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_MaskInteraction: 0
|
||||
m_Positions:
|
||||
- {x: 0.47888803, y: 1.0178367, z: 1.3048704}
|
||||
- {x: -24.632084, y: 1.7695255, z: 0.94831866}
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
widthMultiplier: 1
|
||||
widthCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0.01629239
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
colorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 1, g: 1, b: 1, a: 1}
|
||||
key1: {r: 1, g: 1, b: 1, a: 1}
|
||||
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 65535
|
||||
ctime2: 0
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_ColorSpace: -1
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
numCornerVertices: 0
|
||||
numCapVertices: 0
|
||||
alignment: 0
|
||||
textureMode: 0
|
||||
textureScale: {x: 1, y: 1}
|
||||
shadowBias: 0
|
||||
generateLightingData: 0
|
||||
m_UseWorldSpace: 1
|
||||
m_Loop: 0
|
||||
m_ApplyActiveColorSpace: 1
|
||||
--- !u!114 &8812288568393030278
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8503761475068701983}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c3f99ff473a5f474099e6dd5f8dcde78, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: PresentationAssembly::Darkmatter.Presentation.Gun
|
||||
lineRenderer: {fileID: 6906598175330505539}
|
||||
LifeTime: 0.05
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66690771668559c4d94e4475af123c1e
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/Darkmatter/Code/Presentation/Player/Gun.cs
Normal file
30
Assets/Darkmatter/Code/Presentation/Player/Gun.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class Gun : MonoBehaviour
|
||||
{
|
||||
public LineRenderer lineRenderer;
|
||||
public float LifeTime = 0.05f;
|
||||
|
||||
public void Init(Vector3 start, Vector3 end)
|
||||
{
|
||||
lineRenderer.enabled = true;
|
||||
lineRenderer.SetPosition(0, start);
|
||||
lineRenderer.SetPosition(1, end);
|
||||
Invoke("DisableBullet", LifeTime);
|
||||
}
|
||||
void DisableBullet()
|
||||
{
|
||||
lineRenderer.enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Shoot()
|
||||
{
|
||||
Debug.Log("Shooting");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Darkmatter/Code/Presentation/Player/Gun.cs.meta
Normal file
2
Assets/Darkmatter/Code/Presentation/Player/Gun.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3f99ff473a5f474099e6dd5f8dcde78
|
||||
148
Assets/Darkmatter/Code/Presentation/Player/PlayerMotor.cs
Normal file
148
Assets/Darkmatter/Code/Presentation/Player/PlayerMotor.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using Darkmatter.Core;
|
||||
using Darkmatter.Domain;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class PlayerMotor : MonoBehaviour, IPlayerPawn
|
||||
{
|
||||
|
||||
[Header("LookSetting")]
|
||||
public Camera mainCamera { get; private set; }
|
||||
public Transform cinemachineFollowTarget;
|
||||
|
||||
[Header("MoveSetting")]
|
||||
public CharacterController characterController;
|
||||
|
||||
[Header("GravitySetting")]
|
||||
private float verticalVelocity;
|
||||
public bool isGrounded => IsOnGround();
|
||||
|
||||
[Header("GroundCheckSensorSetting")]
|
||||
public float groundOffset;
|
||||
public float groundCheckRadius;
|
||||
public LayerMask groundLayer;
|
||||
|
||||
[Header("TurnSetting")]
|
||||
public float turnSpeed = 5f;
|
||||
public float smoothing = 10f;
|
||||
[Header("AnimationSetting")]
|
||||
public Animator animator;
|
||||
|
||||
[Header("AimSetting")]
|
||||
public Transform aim;
|
||||
Vector3 mouseWorldPos = Vector3.zero;
|
||||
public Transform muzzlePos;
|
||||
public Gun gun;
|
||||
public float fireRate = 0.1f;
|
||||
float nextFiretime=0;
|
||||
|
||||
|
||||
[Inject] private IInputReader inputReader;
|
||||
[Inject] private PlayerConfigSO playerConfig;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
if(animator==null) animator = GetComponent<Animator>();
|
||||
mainCamera = Camera.main;
|
||||
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
//HandleAim();
|
||||
HandleShooting();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
private void HandleShooting()
|
||||
{
|
||||
float shootingWeight = animator.GetLayerWeight(1);
|
||||
float targetWeight = inputReader.isShooting ? 1 : 0;
|
||||
float setshootingWeight = Mathf.Lerp(shootingWeight, targetWeight, Time.deltaTime * 5);
|
||||
animator.SetLayerWeight(1, setshootingWeight);
|
||||
animator.SetBool("IsShooting", inputReader.isShooting);
|
||||
|
||||
if (!inputReader.isShooting) return;
|
||||
if(Time.time>=nextFiretime)
|
||||
{
|
||||
nextFiretime = Time.time + fireRate;
|
||||
gun.Init(muzzlePos.position, aim.position);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleAim()
|
||||
{
|
||||
Vector2 screenPoint = new Vector2(Screen.width/2, Screen.height/2);
|
||||
Ray ray = mainCamera.ScreenPointToRay(screenPoint);
|
||||
if(Physics.Raycast(ray,out RaycastHit hitPoint, 100f,groundLayer))
|
||||
{
|
||||
mouseWorldPos= hitPoint.point;
|
||||
aim.position = mouseWorldPos;
|
||||
//aim.position = Vector3.Lerp(aim.position, hitPoint.point, Time.deltaTime * smoothing);
|
||||
}
|
||||
|
||||
Vector3 aimDir = (mouseWorldPos - transform.position).normalized;
|
||||
aimDir.y = 0; //
|
||||
Quaternion targetRot = Quaternion.LookRotation(aimDir);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, Time.deltaTime * turnSpeed);
|
||||
}
|
||||
|
||||
|
||||
//state based functions
|
||||
public void Move(Vector3 motion)
|
||||
{
|
||||
ApplyGravity(); //apply gravity before moving
|
||||
Vector3 finalMove = motion;
|
||||
finalMove.y = verticalVelocity;
|
||||
characterController.Move(finalMove * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void SetCameraRotation(float pitch, float yaw)
|
||||
{
|
||||
cinemachineFollowTarget.rotation = Quaternion.Euler(pitch, yaw, 0);
|
||||
HandleAim();
|
||||
//transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0,yaw,0), Time.deltaTime*turnSpeed);
|
||||
}
|
||||
|
||||
public void Jump(float jumpForce)
|
||||
{
|
||||
verticalVelocity = jumpForce;
|
||||
}
|
||||
|
||||
public bool IsOnGround()
|
||||
{
|
||||
Vector3 groundPos = transform.position + Vector3.down * groundOffset;
|
||||
|
||||
return Physics.CheckSphere(
|
||||
groundPos,
|
||||
groundCheckRadius,
|
||||
groundLayer,
|
||||
QueryTriggerInteraction.Ignore
|
||||
);
|
||||
|
||||
}
|
||||
public void ApplyGravity()
|
||||
{
|
||||
if (isGrounded && verticalVelocity < 0f)
|
||||
{
|
||||
verticalVelocity = -2f; // snap to ground
|
||||
}
|
||||
verticalVelocity += playerConfig.gravity * Time.deltaTime;
|
||||
}
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.green;
|
||||
Vector3 groundPos = transform.position + Vector3.down * groundOffset;
|
||||
Gizmos.DrawWireSphere(groundPos, groundCheckRadius);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dd0478b6c34c674aa4378c3ad35088f
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "PresentationAssembly",
|
||||
"rootNamespace": "Darkmatter.Presentation",
|
||||
"references": [
|
||||
"GUID:cf1df9e1968a94c4686f2fbe5ef907fc",
|
||||
"GUID:23f9a018fbd2e1242a0525718cc761d6",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:4307f53044263cf4b835bd812fc161a4"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00bcf444fe1ffd8468345b96caa37633
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user