This can be seen as the initial state of the project after the released demo.
The changes include:
- New ship models
- Singleton manager structure to keep project scaleable in the future
- Managing players, their settings, character choices, statistics, match setups, controls etc. in a separate decoupled scene
- Main menu with transitions to the arena scene
- Beginnings of a custom audio solution
- Logging with Log4Net
It is really a complete overhaul of the projects structure and management.
57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
using System;
|
|
using Managers;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.InputSystem.Users;
|
|
using static InputActionMaps;
|
|
|
|
namespace ShipHandling
|
|
{
|
|
public class ShipInputHandler : IDisposable, IPlayerActions
|
|
{
|
|
private readonly ShipState state;
|
|
private readonly InputActionMaps inputActions = new();
|
|
public InputUser user;
|
|
public ShipInputHandler(ShipState shipState, InputDevice device, string controlScheme)
|
|
{
|
|
state = shipState;
|
|
user = InputUser.PerformPairingWithDevice(device);
|
|
user.AssociateActionsWithUser(inputActions);
|
|
user.ActivateControlScheme(controlScheme);
|
|
inputActions.Player.SetCallbacks(this);
|
|
inputActions.Player.Enable();
|
|
}
|
|
|
|
public void OnThrust(InputAction.CallbackContext context)
|
|
{
|
|
state.thrustInput = context.ReadValue<float>();
|
|
}
|
|
|
|
public void OnSteer(InputAction.CallbackContext context)
|
|
{
|
|
state.steerInput = context.ReadValue<float>();
|
|
}
|
|
|
|
public void OnBoost(InputAction.CallbackContext context)
|
|
{
|
|
state.boostInput = context.ReadValue<float>();
|
|
}
|
|
|
|
public void OnReset(InputAction.CallbackContext context)
|
|
{
|
|
if (Debug.isDebugBuild)
|
|
{
|
|
state.reset = true;
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
inputActions.Player.Disable();
|
|
inputActions.Player.RemoveCallbacks(this);
|
|
user.UnpairDevicesAndRemoveUser();
|
|
}
|
|
|
|
}
|
|
}
|