feat: basic two player one keyboard input
This commit is contained in:
parent
4b95e9a9ff
commit
730fe6f183
637
Assets/Input/InputActionMaps.cs
Normal file
637
Assets/Input/InputActionMaps.cs
Normal file
@ -0,0 +1,637 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||
// version 1.6.3
|
||||
// from Assets/Input/InputActionMaps.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;
|
||||
|
||||
public partial class @InputActionMaps: IInputActionCollection2, IDisposable
|
||||
{
|
||||
public InputActionAsset asset { get; }
|
||||
public @InputActionMaps()
|
||||
{
|
||||
asset = InputActionAsset.FromJson(@"{
|
||||
""name"": ""InputActionMaps"",
|
||||
""maps"": [
|
||||
{
|
||||
""name"": ""Player"",
|
||||
""id"": ""048b594b-7049-4378-97bf-bf33615ac9a2"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Thrust"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""f49115e0-8e49-49d0-86d9-b401b5dc9a7e"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Steer"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""b81175da-8d47-46a1-8d25-39d0aad32a7d"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Reset"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""6ab0c9d5-b21f-4819-b5c8-ad277a1246c7"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Boost"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""c8819d8c-8dc4-4eb6-ae07-132d6fffbed4"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": ""ArrowUpDown"",
|
||||
""id"": ""a4cf021d-ea53-421e-acc3-5512320a66c6"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Negative"",
|
||||
""id"": ""c57f6563-83fc-4287-947b-517897d60b48"",
|
||||
""path"": ""<Keyboard>/downArrow"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 1"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Positive"",
|
||||
""id"": ""887dfb71-2069-4f93-85bf-feb5d766a4e0"",
|
||||
""path"": ""<Keyboard>/upArrow"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 1"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""SW"",
|
||||
""id"": ""530564dc-8d85-4da2-9dfe-de7226088d53"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""638cd1c8-871c-4144-bc85-fd97073775e3"",
|
||||
""path"": ""<Keyboard>/s"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 2"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""41279947-f349-4d74-87f6-0150117546bc"",
|
||||
""path"": ""<Keyboard>/w"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 2"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Triggers"",
|
||||
""id"": ""c23f737f-7d0b-44c9-adf2-af79bc907fe5"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""efa56efa-cdbd-4a0c-942d-d9f63f34b41d"",
|
||||
""path"": ""<Gamepad>/leftTrigger"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""b09aaa96-ba43-4e88-a893-f68100d60f5d"",
|
||||
""path"": ""<Gamepad>/rightTrigger"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""DPAD"",
|
||||
""id"": ""553d2d70-1e91-4da5-a081-0d8b5932ed7f"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""6d3b6aec-4165-44ff-b470-0757bf24e204"",
|
||||
""path"": ""<Gamepad>/dpad/down"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""ad2cd039-33a1-4217-88a3-a92cbe881eff"",
|
||||
""path"": ""<Gamepad>/dpad/up"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Buttons"",
|
||||
""id"": ""c2bb8b7b-6b05-402f-8efd-88ee0b799a0b"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""1f63525a-edbb-407f-9cc0-46c47fb83195"",
|
||||
""path"": ""<Gamepad>/buttonWest"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""dea46670-a213-4f87-b233-2da9e13c61d8"",
|
||||
""path"": ""<Gamepad>/buttonSouth"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Thrust"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""ArrowLeftRight"",
|
||||
""id"": ""9fb0a522-e3c2-4a96-abba-243a4d975417"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""8244e67c-862d-4290-81d9-166e37693466"",
|
||||
""path"": ""<Keyboard>/leftArrow"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 1"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""76453859-ad22-4689-8468-2f8f70a0e62f"",
|
||||
""path"": ""<Keyboard>/rightArrow"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 1"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""AD"",
|
||||
""id"": ""37147163-13e3-42c9-bd71-b98dd06b17d7"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""9ab0d63e-3836-40bf-969a-dd963113eb4b"",
|
||||
""path"": ""<Keyboard>/a"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 2"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""2bb17c0d-1ff6-446d-8963-7e83b44007fe"",
|
||||
""path"": ""<Keyboard>/d"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 2"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""DPAD"",
|
||||
""id"": ""2d7e4f88-0f00-440f-a4d9-4ed030ca5aee"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""ea165035-cea6-44cb-9cdf-9d004a1c27e8"",
|
||||
""path"": ""<Gamepad>/dpad/left"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""5a0913b9-2745-49df-9996-df7f530dab22"",
|
||||
""path"": ""<Gamepad>/dpad/right"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""LeftStickX"",
|
||||
""id"": ""42630580-938e-4cab-9747-35f1ea15fc9a"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""30818f05-cc2e-42f8-a656-a9237d9ae1ff"",
|
||||
""path"": ""<Gamepad>/leftStick/left"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""5939b118-47b4-4558-9b18-23d77cc433c1"",
|
||||
""path"": ""<Gamepad>/leftStick/right"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Steer"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""8c09092a-7323-4f5c-80df-19bfe90a207c"",
|
||||
""path"": ""<Keyboard>/r"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 1;Keyboard 2"",
|
||||
""action"": ""Reset"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""b50ff906-5e23-4bd0-b5b7-98aeb46a2284"",
|
||||
""path"": ""<Gamepad>/select"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Reset"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""f76aad49-c115-4d72-a860-b674c8489543"",
|
||||
""path"": ""<Keyboard>/ctrl"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 1"",
|
||||
""action"": ""Boost"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""90de50d0-0adf-41c0-b8d2-ffd9ff0d55f2"",
|
||||
""path"": ""<Keyboard>/shift"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard 2"",
|
||||
""action"": ""Boost"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""175de4ed-6b10-420d-bc46-5abf4b21486f"",
|
||||
""path"": ""<Gamepad>/buttonEast"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Boost"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""a7d544cb-7418-4091-bb4a-5e24cafb4bec"",
|
||||
""path"": ""<Gamepad>/leftShoulder"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Controller"",
|
||||
""action"": ""Boost"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": [
|
||||
{
|
||||
""name"": ""Controller"",
|
||||
""bindingGroup"": ""Controller"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<Gamepad>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Keyboard 1"",
|
||||
""bindingGroup"": ""Keyboard 1"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<Keyboard>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Keyboard 2"",
|
||||
""bindingGroup"": ""Keyboard 2"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<Keyboard>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}");
|
||||
// Player
|
||||
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
|
||||
m_Player_Thrust = m_Player.FindAction("Thrust", throwIfNotFound: true);
|
||||
m_Player_Steer = m_Player.FindAction("Steer", throwIfNotFound: true);
|
||||
m_Player_Reset = m_Player.FindAction("Reset", throwIfNotFound: true);
|
||||
m_Player_Boost = m_Player.FindAction("Boost", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Object.Destroy(asset);
|
||||
}
|
||||
|
||||
public InputBinding? bindingMask
|
||||
{
|
||||
get => asset.bindingMask;
|
||||
set => asset.bindingMask = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputDevice>? devices
|
||||
{
|
||||
get => asset.devices;
|
||||
set => asset.devices = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||
|
||||
public bool Contains(InputAction action)
|
||||
{
|
||||
return asset.Contains(action);
|
||||
}
|
||||
|
||||
public IEnumerator<InputAction> GetEnumerator()
|
||||
{
|
||||
return asset.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
asset.Enable();
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
asset.Disable();
|
||||
}
|
||||
|
||||
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||
|
||||
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||
{
|
||||
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||
}
|
||||
|
||||
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_Thrust;
|
||||
private readonly InputAction m_Player_Steer;
|
||||
private readonly InputAction m_Player_Reset;
|
||||
private readonly InputAction m_Player_Boost;
|
||||
public struct PlayerActions
|
||||
{
|
||||
private @InputActionMaps m_Wrapper;
|
||||
public PlayerActions(@InputActionMaps wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @Thrust => m_Wrapper.m_Player_Thrust;
|
||||
public InputAction @Steer => m_Wrapper.m_Player_Steer;
|
||||
public InputAction @Reset => m_Wrapper.m_Player_Reset;
|
||||
public InputAction @Boost => m_Wrapper.m_Player_Boost;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
public bool enabled => Get().enabled;
|
||||
public static implicit operator InputActionMap(PlayerActions set) { return set.Get(); }
|
||||
public void AddCallbacks(IPlayerActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_PlayerActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_PlayerActionsCallbackInterfaces.Add(instance);
|
||||
@Thrust.started += instance.OnThrust;
|
||||
@Thrust.performed += instance.OnThrust;
|
||||
@Thrust.canceled += instance.OnThrust;
|
||||
@Steer.started += instance.OnSteer;
|
||||
@Steer.performed += instance.OnSteer;
|
||||
@Steer.canceled += instance.OnSteer;
|
||||
@Reset.started += instance.OnReset;
|
||||
@Reset.performed += instance.OnReset;
|
||||
@Reset.canceled += instance.OnReset;
|
||||
@Boost.started += instance.OnBoost;
|
||||
@Boost.performed += instance.OnBoost;
|
||||
@Boost.canceled += instance.OnBoost;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IPlayerActions instance)
|
||||
{
|
||||
@Thrust.started -= instance.OnThrust;
|
||||
@Thrust.performed -= instance.OnThrust;
|
||||
@Thrust.canceled -= instance.OnThrust;
|
||||
@Steer.started -= instance.OnSteer;
|
||||
@Steer.performed -= instance.OnSteer;
|
||||
@Steer.canceled -= instance.OnSteer;
|
||||
@Reset.started -= instance.OnReset;
|
||||
@Reset.performed -= instance.OnReset;
|
||||
@Reset.canceled -= instance.OnReset;
|
||||
@Boost.started -= instance.OnBoost;
|
||||
@Boost.performed -= instance.OnBoost;
|
||||
@Boost.canceled -= instance.OnBoost;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IPlayerActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_PlayerActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
public void SetCallbacks(IPlayerActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_PlayerActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_PlayerActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
public PlayerActions @Player => new PlayerActions(this);
|
||||
private int m_ControllerSchemeIndex = -1;
|
||||
public InputControlScheme ControllerScheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_ControllerSchemeIndex == -1) m_ControllerSchemeIndex = asset.FindControlSchemeIndex("Controller");
|
||||
return asset.controlSchemes[m_ControllerSchemeIndex];
|
||||
}
|
||||
}
|
||||
private int m_Keyboard1SchemeIndex = -1;
|
||||
public InputControlScheme Keyboard1Scheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Keyboard1SchemeIndex == -1) m_Keyboard1SchemeIndex = asset.FindControlSchemeIndex("Keyboard 1");
|
||||
return asset.controlSchemes[m_Keyboard1SchemeIndex];
|
||||
}
|
||||
}
|
||||
private int m_Keyboard2SchemeIndex = -1;
|
||||
public InputControlScheme Keyboard2Scheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Keyboard2SchemeIndex == -1) m_Keyboard2SchemeIndex = asset.FindControlSchemeIndex("Keyboard 2");
|
||||
return asset.controlSchemes[m_Keyboard2SchemeIndex];
|
||||
}
|
||||
}
|
||||
public interface IPlayerActions
|
||||
{
|
||||
void OnThrust(InputAction.CallbackContext context);
|
||||
void OnSteer(InputAction.CallbackContext context);
|
||||
void OnReset(InputAction.CallbackContext context);
|
||||
void OnBoost(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
11
Assets/Input/InputActionMaps.cs.meta
Normal file
11
Assets/Input/InputActionMaps.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe00474875c3cc94bbbf8cbf03d828c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -8,7 +8,7 @@ ScriptedImporter:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 0
|
||||
generateWrapperCode: 1
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
|
||||
@ -125,7 +125,7 @@ Material:
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
- _base_alpha: 0.41
|
||||
- _impact_amplitude: 0.08
|
||||
- _impact_amplitude: 0
|
||||
- _impact_anim: 0
|
||||
- _impact_blend: 0
|
||||
- _impact_density: 20
|
||||
@ -145,6 +145,6 @@ Material:
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
- _impact_origin: {r: 1, g: 0, b: -0.3, a: 1}
|
||||
- _rotation: {r: 0.1, g: 0, b: 0, a: 1}
|
||||
- _rotation: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _shield_color: {r: 0, g: 1, b: 0.7743149, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
||||
@ -90,6 +90,7 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 6850768006170588356}
|
||||
- {fileID: 8774249858192466318}
|
||||
- {fileID: 6166152332587307364}
|
||||
- {fileID: 8696699156449457255}
|
||||
- {fileID: 5758221365909025383}
|
||||
- {fileID: 7227660392512793521}
|
||||
@ -185,7 +186,7 @@ MonoBehaviour:
|
||||
m_ActionId: c8819d8c-8dc4-4eb6-ae07-132d6fffbed4
|
||||
m_ActionName: Player/Boost[/Keyboard/ctrl,/Keyboard/shift,/XInputControllerWindows/buttonEast,/XInputControllerWindows/leftShoulder]
|
||||
m_NeverAutoSwitchControlSchemes: 1
|
||||
m_DefaultControlScheme:
|
||||
m_DefaultControlScheme: Controller
|
||||
m_DefaultActionMap: Player
|
||||
m_SplitScreenIndex: -1
|
||||
m_Camera: {fileID: 0}
|
||||
@ -301,6 +302,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2b6244fd2a6ceee4ab8504fadf75ae20, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cameraOperator: {fileID: 0}
|
||||
thrustAcceleration: 1500
|
||||
steerVelocity: 300
|
||||
normalMaxVelocity: 25
|
||||
@ -317,8 +319,10 @@ MonoBehaviour:
|
||||
boostAntiGravityFactor: 0.8
|
||||
tackleStunFactor: 0.1
|
||||
tackleStunTime: 0.6
|
||||
tacklePowerFactor: 50
|
||||
tacklePowerFactor: 30
|
||||
boostUI: {fileID: 4200181511080825266}
|
||||
playerInput: {fileID: 0}
|
||||
instanceID: 0
|
||||
--- !u!1 &4451848836747234632
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -402,6 +406,61 @@ MeshRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!1 &7665455622387539610
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6166152332587307364}
|
||||
- component: {fileID: 1551560316097652998}
|
||||
m_Layer: 7
|
||||
m_Name: BodyArea
|
||||
m_TagString: Vulnerable
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6166152332587307364
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7665455622387539610}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5458316571244832082}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!136 &1551560316097652998
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7665455622387539610}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 1
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.57511306
|
||||
m_Height: 2.3651605
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: -0.2, z: 0}
|
||||
--- !u!1 &8319233940171307812
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -37,6 +37,7 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 2763216851625110643}
|
||||
- {fileID: 1065332109104514168}
|
||||
- {fileID: 2323253733787261421}
|
||||
- {fileID: 3900807414520724371}
|
||||
- {fileID: 2308728980078667632}
|
||||
m_Father: {fileID: 0}
|
||||
@ -131,7 +132,7 @@ MonoBehaviour:
|
||||
m_ActionId: c8819d8c-8dc4-4eb6-ae07-132d6fffbed4
|
||||
m_ActionName: Player/Boost[/Keyboard/ctrl,/Keyboard/shift,/XInputControllerWindows/buttonEast,/XInputControllerWindows/leftShoulder]
|
||||
m_NeverAutoSwitchControlSchemes: 1
|
||||
m_DefaultControlScheme:
|
||||
m_DefaultControlScheme: Controller
|
||||
m_DefaultActionMap: Player
|
||||
m_SplitScreenIndex: -1
|
||||
m_Camera: {fileID: 0}
|
||||
@ -247,6 +248,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2b6244fd2a6ceee4ab8504fadf75ae20, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cameraOperator: {fileID: 0}
|
||||
thrustAcceleration: 1500
|
||||
steerVelocity: 300
|
||||
normalMaxVelocity: 25
|
||||
@ -257,14 +259,16 @@ MonoBehaviour:
|
||||
maximumDrag: 6
|
||||
torqueDrag: 10
|
||||
maxBoostCapacity: 3
|
||||
minBoostCapacity: 1
|
||||
minBoostCapacity: 0.6
|
||||
boostMagnitude: 2.5
|
||||
outsideBoostRate: 0
|
||||
boostAntiGravityFactor: 0.8
|
||||
tackleStunFactor: 0.1
|
||||
tackleStunTime: 0.6
|
||||
tacklePowerFactor: 50
|
||||
tacklePowerFactor: 30
|
||||
boostUI: {fileID: 3576024133074538910}
|
||||
playerInput: {fileID: 0}
|
||||
instanceID: 0
|
||||
--- !u!1 &3218284673077589540
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -456,6 +460,61 @@ CapsuleCollider:
|
||||
m_Height: 1.3338675
|
||||
m_Direction: 0
|
||||
m_Center: {x: -0.000009298325, y: -0.025820732, z: 0}
|
||||
--- !u!1 &7085924197508447212
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2323253733787261421}
|
||||
- component: {fileID: 7345168250516523601}
|
||||
m_Layer: 7
|
||||
m_Name: BodyArea
|
||||
m_TagString: Vulnerable
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2323253733787261421
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7085924197508447212}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4137950278346515597}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!136 &7345168250516523601
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7085924197508447212}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 1
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.57511306
|
||||
m_Height: 2.3651605
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: -0.2, z: 0}
|
||||
--- !u!1001 &8054534206256546014
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -321,10 +321,6 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Player Gray
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2068562511677553606, guid: 105162f72bf50c84aaf92b1ca494ed3b, type: 3}
|
||||
propertyPath: m_NeverAutoSwitchControlSchemes
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4137950278346515597, guid: 105162f72bf50c84aaf92b1ca494ed3b, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -10
|
||||
@ -365,6 +361,10 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8932415214367391550, guid: 105162f72bf50c84aaf92b1ca494ed3b, type: 3}
|
||||
propertyPath: cameraOperator
|
||||
value:
|
||||
objectReference: {fileID: 963194229}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@ -550,108 +550,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
zone: {fileID: 1361581065}
|
||||
announcements: {fileID: 2052728261}
|
||||
--- !u!1 &895482937
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 895482939}
|
||||
- component: {fileID: 895482938}
|
||||
- component: {fileID: 895482940}
|
||||
m_Layer: 0
|
||||
m_Name: PlayerManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &895482938
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 895482937}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 621567455fd1c4ceb811cc8a00b6a1a5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_NotificationBehavior: 2
|
||||
m_MaxPlayerCount: 2
|
||||
m_AllowJoining: 1
|
||||
m_JoinBehavior: 0
|
||||
m_PlayerJoinedEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 895482940}
|
||||
m_TargetAssemblyTypeName: PlayerManager, Assembly-CSharp
|
||||
m_MethodName: OnPlayerJoined
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
m_PlayerLeftEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_JoinAction:
|
||||
m_UseReference: 0
|
||||
m_Action:
|
||||
m_Name:
|
||||
m_Type: 0
|
||||
m_ExpectedControlType:
|
||||
m_Id:
|
||||
m_Processors:
|
||||
m_Interactions:
|
||||
m_SingletonActionBindings: []
|
||||
m_Flags: 0
|
||||
m_Reference: {fileID: 0}
|
||||
m_PlayerPrefab: {fileID: 2111858426991004505, guid: d247a5257c4a6774399dc902f311b653, type: 3}
|
||||
m_SplitScreen: 0
|
||||
m_MaintainAspectRatioInSplitScreen: 0
|
||||
m_FixedNumberOfSplitScreens: -1
|
||||
m_SplitScreenRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
--- !u!4 &895482939
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 895482937}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -9.660311, y: -6.734341, z: 64.1785}
|
||||
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!114 &895482940
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 895482937}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: af7ba7ecba068a342ac96ba1df059373, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
cameraOperator: {fileID: 963194229}
|
||||
minPlayerCount: 2
|
||||
--- !u!1 &963194225
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -802,124 +701,6 @@ MonoBehaviour:
|
||||
mipBias: 0
|
||||
varianceClampScale: 0.9
|
||||
contrastAdaptiveSharpening: 0
|
||||
--- !u!1 &1026075974
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1026075977}
|
||||
- component: {fileID: 1026075976}
|
||||
- component: {fileID: 1026075975}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!114 &1026075975
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1026075974}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Version: 3
|
||||
m_UsePipelineSettings: 1
|
||||
m_AdditionalLightsShadowResolutionTier: 2
|
||||
m_LightLayerMask: 1
|
||||
m_RenderingLayers: 1
|
||||
m_CustomShadowLayers: 0
|
||||
m_ShadowLayerMask: 1
|
||||
m_ShadowRenderingLayers: 1
|
||||
m_LightCookieSize: {x: 1, y: 1}
|
||||
m_LightCookieOffset: {x: 0, y: 0}
|
||||
m_SoftShadowQuality: 0
|
||||
--- !u!108 &1026075976
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1026075974}
|
||||
m_Enabled: 0
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 0
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &1026075977
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1026075974}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -50}
|
||||
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!1001 &1119422545
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -972,10 +753,10 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9136370446038472296, guid: d247a5257c4a6774399dc902f311b653, type: 3}
|
||||
propertyPath: m_NeverAutoSwitchControlSchemes
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7382138887082377466, guid: d247a5257c4a6774399dc902f311b653, type: 3}
|
||||
propertyPath: cameraOperator
|
||||
value:
|
||||
objectReference: {fileID: 963194229}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@ -1176,9 +957,6 @@ PrefabInstance:
|
||||
- targetCorrespondingSourceObject: {fileID: -8098169881513260187, guid: 303177f7648454b4fb8179c1378dd1ec, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1361581065}
|
||||
- targetCorrespondingSourceObject: {fileID: -8098169881513260187, guid: 303177f7648454b4fb8179c1378dd1ec, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1361581068}
|
||||
m_SourcePrefab: {fileID: 3150474306388093854, guid: 303177f7648454b4fb8179c1378dd1ec, type: 3}
|
||||
--- !u!1 &1361581064 stripped
|
||||
GameObject:
|
||||
@ -1218,20 +996,6 @@ BoxCollider:
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 1.5, y: 0.1, z: 1.5}
|
||||
m_Center: {x: 0, y: 0, z: -0.75}
|
||||
--- !u!114 &1361581068
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1361581064}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1211ce015fd3676469a8844316d4b944, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
zone: {fileID: 0}
|
||||
announcements: {fileID: 0}
|
||||
--- !u!1 &1659830375
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1613,10 +1377,8 @@ SceneRoots:
|
||||
m_Roots:
|
||||
- {fileID: 796181415}
|
||||
- {fileID: 2052728260}
|
||||
- {fileID: 895482939}
|
||||
- {fileID: 963194228}
|
||||
- {fileID: 8179556}
|
||||
- {fileID: 1026075977}
|
||||
- {fileID: 2000082937}
|
||||
- {fileID: 1185564593}
|
||||
- {fileID: 1748381166}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
@ -8,34 +9,48 @@ public class Announcments : MonoBehaviour
|
||||
{
|
||||
[SerializeField] TextMeshProUGUI announcementText;
|
||||
|
||||
private float announcmentTime;
|
||||
private float remainingTime;
|
||||
|
||||
void Start()
|
||||
{
|
||||
announcementText.enabled = false;
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
if (!announcementText.enabled)
|
||||
{
|
||||
announcementText.enabled = true;
|
||||
}
|
||||
remainingTime -= Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
announcementText.enabled = false;
|
||||
remainingTime = 0;
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AnnounceText(string text, float time)
|
||||
{
|
||||
announcementText.text = text;
|
||||
announcementText.enabled = true;
|
||||
remainingTime = time;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public void AnnounceText(string text)
|
||||
{
|
||||
announcementText.text = text;
|
||||
announcementText.enabled = true;
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
public void StopAnnouncement()
|
||||
{
|
||||
announcementText.text = String.Empty;
|
||||
remainingTime = 0;
|
||||
announcementText.enabled = false;
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ using static UnityEngine.Mathf;
|
||||
public class CameraOperator : MonoBehaviour
|
||||
{
|
||||
private Dictionary<int, GameObject> players = new Dictionary<int, GameObject>();
|
||||
|
||||
public void AddPlayer(GameObject player)
|
||||
{
|
||||
players[player.GetInstanceID()] = player;
|
||||
|
||||
@ -1,13 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using Palmmedia.ReportGenerator.Core.Reporting.Builders;
|
||||
using UnityEditor.Experimental.Licensing;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Users;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
using UnityEngine.SceneManagement;
|
||||
using static InputActionMaps;
|
||||
|
||||
public enum GameState { Starting, Match, End, Paused }
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
|
||||
public static GameManager GM { get; private set; }
|
||||
[SerializeField] ZoneRules zone;
|
||||
[SerializeField] Announcments announcements;
|
||||
private bool gameLost = false;
|
||||
[SerializeField] int minPlayerCount = 2;
|
||||
public GameState currentState { get; private set; }
|
||||
private Dictionary<int, PlayerController> players = new Dictionary<int, PlayerController>();
|
||||
private Dictionary<int, string> playerControlSchemes = new Dictionary<int, string>();
|
||||
private float restartMatchTime = 0;
|
||||
private ControlSchemeDetection controlSchemeDetector;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (GM == null)
|
||||
{
|
||||
GM = this;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
@ -15,7 +38,7 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
restartMatchTime -= Time.deltaTime;
|
||||
}
|
||||
else if (gameLost)
|
||||
else if (currentState == GameState.End)
|
||||
{
|
||||
restartMatchTime = 0;
|
||||
StartNewMatch();
|
||||
@ -24,6 +47,16 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
currentState = GameState.Starting;
|
||||
controlSchemeDetector = new ControlSchemeDetection();
|
||||
controlSchemeDetector.ControlSchemeDetected += AssignPlayerControls;
|
||||
controlSchemeDetector.EnableDetection();
|
||||
announcements.AnnounceText("You both press a key \n on your controll scheme of choice \n to start the match");
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
void StartMatch()
|
||||
{
|
||||
if (zone != null)
|
||||
{
|
||||
@ -31,18 +64,21 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
if (announcements != null)
|
||||
{
|
||||
announcements.StopAnnouncement();
|
||||
announcements.AnnounceText("Match Start", 1.6f);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckLosingCondition(GameObject go)
|
||||
{
|
||||
if (!go.CompareTag("Player") || gameLost)
|
||||
if (!go.CompareTag("Player") || currentState == GameState.End)
|
||||
return;
|
||||
gameLost = true;
|
||||
currentState = GameState.End;
|
||||
Destroy(go);
|
||||
announcements.AnnounceText(go.name + " has lost the match", 2f);
|
||||
restartMatchTime = 2.2f;
|
||||
players.Clear();
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
private void StartNewMatch()
|
||||
@ -51,4 +87,97 @@ public class GameManager : MonoBehaviour
|
||||
SceneManager.LoadScene(currentSceneName);
|
||||
}
|
||||
|
||||
public void RegisterPlayer(PlayerController pc)
|
||||
{
|
||||
if (!players.ContainsKey(pc.instanceID))
|
||||
{
|
||||
players[pc.instanceID] = pc;
|
||||
}
|
||||
}
|
||||
|
||||
private void AssignPlayerControls(object sender, string controlScheme)
|
||||
{
|
||||
if (players.Count < minPlayerCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (players.Count <= playerControlSchemes.Count)
|
||||
{
|
||||
controlSchemeDetector.DisableDetection();
|
||||
currentState = GameState.Match;
|
||||
StartMatch();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (int playerId in players.Keys)
|
||||
{
|
||||
if (playerControlSchemes.ContainsValue(controlScheme))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (playerControlSchemes.ContainsKey(playerId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PlayerController pc = players[playerId];
|
||||
if (controlScheme.Contains("Keyboard"))
|
||||
{
|
||||
pc.playerInput.SwitchCurrentControlScheme(controlScheme, Keyboard.current);
|
||||
}
|
||||
else if (controlScheme.Contains("Controller"))
|
||||
{
|
||||
pc.playerInput.SwitchCurrentControlScheme(controlScheme, Gamepad.current);
|
||||
}
|
||||
playerControlSchemes[playerId] = controlScheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ControlSchemeDetection : IPlayerActions
|
||||
{
|
||||
InputActionMaps actionMaps;
|
||||
public event EventHandler<string> ControlSchemeDetected;
|
||||
|
||||
public ControlSchemeDetection()
|
||||
{
|
||||
actionMaps = new InputActionMaps();
|
||||
actionMaps.Player.SetCallbacks(this);
|
||||
}
|
||||
|
||||
public void EnableDetection()
|
||||
{
|
||||
actionMaps.Player.Enable();
|
||||
}
|
||||
public void DisableDetection()
|
||||
{
|
||||
actionMaps.Player.Disable();
|
||||
}
|
||||
|
||||
public void OnBoost(InputAction.CallbackContext context)
|
||||
{
|
||||
readControlScheme(context);
|
||||
}
|
||||
|
||||
public void OnReset(InputAction.CallbackContext context)
|
||||
{
|
||||
readControlScheme(context);
|
||||
}
|
||||
|
||||
public void OnSteer(InputAction.CallbackContext context)
|
||||
{
|
||||
readControlScheme(context);
|
||||
}
|
||||
|
||||
public void OnThrust(InputAction.CallbackContext context)
|
||||
{
|
||||
readControlScheme(context);
|
||||
}
|
||||
|
||||
public void readControlScheme(InputAction.CallbackContext context)
|
||||
{
|
||||
int bindingIndex = context.action.GetBindingIndexForControl(context.control);
|
||||
InputBinding binding = context.action.bindings[bindingIndex];
|
||||
string controlScheme = binding.groups.Split(';')[0];
|
||||
ControlSchemeDetected.Invoke(this, controlScheme);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using GLTFast.Schema;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
@ -8,6 +7,7 @@ using static AffectingForcesManager;
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
// Private variables
|
||||
[SerializeField] private CameraOperator cameraOperator;
|
||||
[SerializeField] private float thrustAcceleration = 400;
|
||||
[SerializeField] private float steerVelocity = 30;
|
||||
[SerializeField] private float normalMaxVelocity = 10;
|
||||
@ -28,6 +28,7 @@ public class PlayerController : MonoBehaviour
|
||||
[SerializeField, Range(0, 1000)] private float tacklePowerFactor = 10f;
|
||||
[SerializeField] private BoostCapacityUI boostUI;
|
||||
private AffectingForcesManager forceManager;
|
||||
public PlayerInput playerInput;
|
||||
private Rigidbody body;
|
||||
private Vector3 currentGravity = new Vector3();
|
||||
// Saves the current input value for thrust
|
||||
@ -41,7 +42,7 @@ public class PlayerController : MonoBehaviour
|
||||
private float tackledTime = 0f;
|
||||
// Current Zone the player occupies
|
||||
private Zone zone = Zone.NimbleZone;
|
||||
private int instanceID;
|
||||
public int instanceID;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@ -50,6 +51,7 @@ public class PlayerController : MonoBehaviour
|
||||
forceManager = GameObject.FindGameObjectWithTag("ForceManager").GetComponent<AffectingForcesManager>();
|
||||
}
|
||||
body = GetComponent<Rigidbody>();
|
||||
playerInput = GetComponent<PlayerInput>();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
@ -58,12 +60,17 @@ public class PlayerController : MonoBehaviour
|
||||
instanceID = gameObject.GetInstanceID();
|
||||
boostCapacity = maxBoostCapacity;
|
||||
boostUI.SetMinBoostRatio(minBoostCapacity / maxBoostCapacity);
|
||||
GameManager.GM.RegisterPlayer(this);
|
||||
cameraOperator.AddPlayer(gameObject);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
|
||||
{
|
||||
if (GameManager.GM.currentState == GameState.Starting)
|
||||
{
|
||||
return;
|
||||
}
|
||||
zone = forceManager.GetZoneOfInstance(instanceID);
|
||||
//BoostStateUpdate(Time.deltaTime);
|
||||
// Rotate the vehicle with the current steer velocity
|
||||
|
||||
Loading…
Reference in New Issue
Block a user