任务:编写操控地图

1.添加基本操作:移动、跳跃、交互和攻击的按键监听,编写好了父类,使用时只需要继承PlayerControl,然后重写里面的函数即可,注释和摘要齐全,如无必要请勿修改

我是每天上班提醒小助手,今天你上班了吗?😺
This commit is contained in:
Roman 2022-03-11 22:42:57 +08:00
parent c780a1948b
commit e10d588cf5
11 changed files with 1042 additions and 0 deletions

8
Assets/InputAssets.meta Normal file
View File

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

View File

@ -0,0 +1,424 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.3.0
// from Assets/InputAssets/PlayerC.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 @PlayerC : IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @PlayerC()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""PlayerC"",
""maps"": [
{
""name"": ""Normal"",
""id"": ""a9509238-4ac2-4968-9104-7e40d5ee5be8"",
""actions"": [
{
""name"": ""Move"",
""type"": ""Value"",
""id"": ""4850f4e1-f2c9-4d5c-bd75-a8673acfb61a"",
""expectedControlType"": ""Axis"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""Atk"",
""type"": ""Button"",
""id"": ""514296f3-ecfc-4870-85d4-dd364fe8773e"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Jump"",
""type"": ""Button"",
""id"": ""abed25a0-995f-4034-84f5-d751e6bc0a7f"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Interact"",
""type"": ""Button"",
""id"": ""b014aa44-5a26-4e36-b7b0-2bf89fc8617c"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": ""Keyboard"",
""id"": ""dfa90ca2-5172-40a9-a51c-0302d90846b4"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Move"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""034d425f-6336-4c6d-a571-d5bc9a090686"",
""path"": ""<Keyboard>/a"",
""interactions"": """",
""processors"": """",
""groups"": ""Normal"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""d58eeeaf-86a4-4adc-acb8-c647c77cd7b4"",
""path"": ""<Keyboard>/d"",
""interactions"": """",
""processors"": """",
""groups"": ""Normal"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""GamePad"",
""id"": ""a4b44fd8-a2cb-4a05-ab0d-ac14de8d17b6"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Move"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""ca1377ed-502a-4c18-b5da-542b0ab2f78a"",
""path"": ""<Gamepad>/leftStick/left"",
""interactions"": """",
""processors"": """",
""groups"": ""Normal"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""be7d0a09-9192-417e-b737-ea3e160f4156"",
""path"": ""<Gamepad>/leftStick/right"",
""interactions"": """",
""processors"": """",
""groups"": ""Normal"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""74439205-ca18-4731-809e-9db029435012"",
""path"": ""<Keyboard>/j"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Atk"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""41256d78-e271-4ffe-a025-708f7f7dd055"",
""path"": ""<Gamepad>/buttonWest"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Atk"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""d26afab9-340e-4c38-905f-576f82ce664c"",
""path"": ""<Gamepad>/buttonSouth"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""310e0ce7-9635-4c78-bf18-8b46b039dbb4"",
""path"": ""<Keyboard>/k"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""56e4c8f3-5f31-4e4c-b216-914499d0d7a8"",
""path"": ""<Keyboard>/f"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Interact"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""d38f2194-30e2-45a5-a803-89534727cf65"",
""path"": ""<Gamepad>/buttonWest"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Interact"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
{
""name"": ""Null"",
""id"": ""d35487bf-8b39-4ef8-932a-e057537f5cff"",
""actions"": [
{
""name"": ""New action"",
""type"": ""Button"",
""id"": ""8227df78-160c-4425-939a-fb42da1254ef"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": """",
""id"": ""522de362-9c2e-4df0-8a98-33364cf3737b"",
""path"": """",
""interactions"": """",
""processors"": """",
""groups"": ""Normal"",
""action"": ""New action"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": [
{
""name"": ""Normal"",
""bindingGroup"": ""Normal"",
""devices"": [
{
""devicePath"": ""<Gamepad>"",
""isOptional"": true,
""isOR"": false
},
{
""devicePath"": ""<Keyboard>"",
""isOptional"": true,
""isOR"": false
}
]
}
]
}");
// Normal
m_Normal = asset.FindActionMap("Normal", throwIfNotFound: true);
m_Normal_Move = m_Normal.FindAction("Move", throwIfNotFound: true);
m_Normal_Atk = m_Normal.FindAction("Atk", throwIfNotFound: true);
m_Normal_Jump = m_Normal.FindAction("Jump", throwIfNotFound: true);
m_Normal_Interact = m_Normal.FindAction("Interact", throwIfNotFound: true);
// Null
m_Null = asset.FindActionMap("Null", throwIfNotFound: true);
m_Null_Newaction = m_Null.FindAction("New action", 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);
}
// Normal
private readonly InputActionMap m_Normal;
private INormalActions m_NormalActionsCallbackInterface;
private readonly InputAction m_Normal_Move;
private readonly InputAction m_Normal_Atk;
private readonly InputAction m_Normal_Jump;
private readonly InputAction m_Normal_Interact;
public struct NormalActions
{
private @PlayerC m_Wrapper;
public NormalActions(@PlayerC wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_Normal_Move;
public InputAction @Atk => m_Wrapper.m_Normal_Atk;
public InputAction @Jump => m_Wrapper.m_Normal_Jump;
public InputAction @Interact => m_Wrapper.m_Normal_Interact;
public InputActionMap Get() { return m_Wrapper.m_Normal; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(NormalActions set) { return set.Get(); }
public void SetCallbacks(INormalActions instance)
{
if (m_Wrapper.m_NormalActionsCallbackInterface != null)
{
@Move.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnMove;
@Move.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnMove;
@Move.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnMove;
@Atk.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnAtk;
@Atk.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnAtk;
@Atk.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnAtk;
@Jump.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnJump;
@Interact.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
@Interact.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
@Interact.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
}
m_Wrapper.m_NormalActionsCallbackInterface = instance;
if (instance != null)
{
@Move.started += instance.OnMove;
@Move.performed += instance.OnMove;
@Move.canceled += instance.OnMove;
@Atk.started += instance.OnAtk;
@Atk.performed += instance.OnAtk;
@Atk.canceled += instance.OnAtk;
@Jump.started += instance.OnJump;
@Jump.performed += instance.OnJump;
@Jump.canceled += instance.OnJump;
@Interact.started += instance.OnInteract;
@Interact.performed += instance.OnInteract;
@Interact.canceled += instance.OnInteract;
}
}
}
public NormalActions @Normal => new NormalActions(this);
// Null
private readonly InputActionMap m_Null;
private INullActions m_NullActionsCallbackInterface;
private readonly InputAction m_Null_Newaction;
public struct NullActions
{
private @PlayerC m_Wrapper;
public NullActions(@PlayerC wrapper) { m_Wrapper = wrapper; }
public InputAction @Newaction => m_Wrapper.m_Null_Newaction;
public InputActionMap Get() { return m_Wrapper.m_Null; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(NullActions set) { return set.Get(); }
public void SetCallbacks(INullActions instance)
{
if (m_Wrapper.m_NullActionsCallbackInterface != null)
{
@Newaction.started -= m_Wrapper.m_NullActionsCallbackInterface.OnNewaction;
@Newaction.performed -= m_Wrapper.m_NullActionsCallbackInterface.OnNewaction;
@Newaction.canceled -= m_Wrapper.m_NullActionsCallbackInterface.OnNewaction;
}
m_Wrapper.m_NullActionsCallbackInterface = instance;
if (instance != null)
{
@Newaction.started += instance.OnNewaction;
@Newaction.performed += instance.OnNewaction;
@Newaction.canceled += instance.OnNewaction;
}
}
}
public NullActions @Null => new NullActions(this);
private int m_NormalSchemeIndex = -1;
public InputControlScheme NormalScheme
{
get
{
if (m_NormalSchemeIndex == -1) m_NormalSchemeIndex = asset.FindControlSchemeIndex("Normal");
return asset.controlSchemes[m_NormalSchemeIndex];
}
}
public interface INormalActions
{
void OnMove(InputAction.CallbackContext context);
void OnAtk(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnInteract(InputAction.CallbackContext context);
}
public interface INullActions
{
void OnNewaction(InputAction.CallbackContext context);
}
}

View File

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

View File

@ -0,0 +1,227 @@
{
"name": "PlayerC",
"maps": [
{
"name": "Normal",
"id": "a9509238-4ac2-4968-9104-7e40d5ee5be8",
"actions": [
{
"name": "Move",
"type": "Value",
"id": "4850f4e1-f2c9-4d5c-bd75-a8673acfb61a",
"expectedControlType": "Axis",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Atk",
"type": "Button",
"id": "514296f3-ecfc-4870-85d4-dd364fe8773e",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Jump",
"type": "Button",
"id": "abed25a0-995f-4034-84f5-d751e6bc0a7f",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Interact",
"type": "Button",
"id": "b014aa44-5a26-4e36-b7b0-2bf89fc8617c",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "Keyboard",
"id": "dfa90ca2-5172-40a9-a51c-0302d90846b4",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Move",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "034d425f-6336-4c6d-a571-d5bc9a090686",
"path": "<Keyboard>/a",
"interactions": "",
"processors": "",
"groups": "Normal",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "d58eeeaf-86a4-4adc-acb8-c647c77cd7b4",
"path": "<Keyboard>/d",
"interactions": "",
"processors": "",
"groups": "Normal",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "GamePad",
"id": "a4b44fd8-a2cb-4a05-ab0d-ac14de8d17b6",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Move",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "ca1377ed-502a-4c18-b5da-542b0ab2f78a",
"path": "<Gamepad>/leftStick/left",
"interactions": "",
"processors": "",
"groups": "Normal",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "be7d0a09-9192-417e-b737-ea3e160f4156",
"path": "<Gamepad>/leftStick/right",
"interactions": "",
"processors": "",
"groups": "Normal",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "74439205-ca18-4731-809e-9db029435012",
"path": "<Keyboard>/j",
"interactions": "",
"processors": "",
"groups": "",
"action": "Atk",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "41256d78-e271-4ffe-a025-708f7f7dd055",
"path": "<Gamepad>/buttonWest",
"interactions": "",
"processors": "",
"groups": "",
"action": "Atk",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "d26afab9-340e-4c38-905f-576f82ce664c",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "310e0ce7-9635-4c78-bf18-8b46b039dbb4",
"path": "<Keyboard>/k",
"interactions": "",
"processors": "",
"groups": "",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "56e4c8f3-5f31-4e4c-b216-914499d0d7a8",
"path": "<Keyboard>/f",
"interactions": "",
"processors": "",
"groups": "",
"action": "Interact",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "d38f2194-30e2-45a5-a803-89534727cf65",
"path": "<Gamepad>/buttonWest",
"interactions": "",
"processors": "",
"groups": "",
"action": "Interact",
"isComposite": false,
"isPartOfComposite": false
}
]
},
{
"name": "Null",
"id": "d35487bf-8b39-4ef8-932a-e057537f5cff",
"actions": [
{
"name": "New action",
"type": "Button",
"id": "8227df78-160c-4425-939a-fb42da1254ef",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "",
"id": "522de362-9c2e-4df0-8a98-33364cf3737b",
"path": "",
"interactions": "",
"processors": "",
"groups": "Normal",
"action": "New action",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": [
{
"name": "Normal",
"bindingGroup": "Normal",
"devices": [
{
"devicePath": "<Gamepad>",
"isOptional": true,
"isOR": false
},
{
"devicePath": "<Keyboard>",
"isOptional": true,
"isOR": false
}
]
}
]
}

View File

@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 52fa29fa6b2d9da41929715d6ccd69c1
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 1
wrapperCodePath:
wrapperClassName:
wrapperCodeNamespace:

View File

@ -0,0 +1,251 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1721685559
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1721685562}
- component: {fileID: 1721685561}
- component: {fileID: 1721685560}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1721685560
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1721685559}
m_Enabled: 1
--- !u!20 &1721685561
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1721685559}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1721685562
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1721685559}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1768031467
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1768031469}
- component: {fileID: 1768031468}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1768031468
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1768031467}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 02b642358c4be914281c3462ff8eab86, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1768031469
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1768031467}
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_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

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

View File

@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using Sirenix.OdinInspector;
/// <summary>
/// 玩家的控制器部分,玩家主类必须继承这个类才能对控制做出反应
/// </summary>
public class PlayerControl : MonoBehaviour
{
private PlayerC playerC;
/// <summary>
/// 此帧输入方向,-1为左1为右0此帧不输入
/// </summary>
[SerializeField][ReadOnly][Header("此帧输入方向,-1为左1为右0表示此帧不输入")]
protected int inputDir;
void Start()
{
playerC = new PlayerC();
//playerC.Enable();
playerC.Normal.Enable();
//为事件订阅方法
//为移动操作订阅方法
playerC.Normal.Move.performed += ctx => OnMove(ctx);
playerC.Normal.Move.canceled += ctx => { inputDir = 0; };
//为攻击操作订阅方法
playerC.Normal.Atk.performed += ctx => OnAtk();
//为跳跃操作订阅方法
playerC.Normal.Jump.performed += ctx => OnJump();
//为交互操作订阅方法
playerC.Normal.Interact.performed += ctx => OnInteract();
}
/// <summary>
/// 当有移动输入的时候触发,因为涉及读值重些的时候记得必须Base
/// </summary>
protected virtual void OnMove(InputAction.CallbackContext ctx){
//根据读值设置记录的输入方向
if(ctx.ReadValue<float>() > 0){
inputDir = 1;
}else if(ctx.ReadValue<float>() < 0){
inputDir = -1;
}
if(ctx.ReadValue<float>().Equals(0f)){
inputDir = 0;
}
}
/// <summary>
/// 按下攻击时触发
/// </summary>
protected virtual void OnAtk(){}
/// <summary>
/// 按下跳跃时触发
/// </summary>
protected virtual void OnJump(){}
/// <summary>
/// 按下交互时触发
/// </summary>
protected virtual void OnInteract(){}
}

View File

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

View File

@ -8,3 +8,23 @@ C# parse time : 672ms
candidates check time : 52ms
console write time : 32ms
[api-updater (non-obsolete-error-filter)] 2022/3/11 22:33:29 : Starting D:/unity/Editor/2020.3.30f1c1/Editor/Data/Tools/ScriptUpdater/APIUpdater.NonObsoleteApiUpdaterDetector.exe
[api-updater (non-obsolete-error-filter)]
----------------------------------
jit/startup time : 660.5614ms
moved types parse time: 50ms
candidates parse time : 1ms
C# parse time : -1ms
candidates check time : -1ms
console write time : -1ms
[api-updater (non-obsolete-error-filter)] 2022/3/11 22:34:57 : Starting D:/unity/Editor/2020.3.30f1c1/Editor/Data/Tools/ScriptUpdater/APIUpdater.NonObsoleteApiUpdaterDetector.exe
[api-updater (non-obsolete-error-filter)]
----------------------------------
jit/startup time : 71.0488ms
moved types parse time: 49ms
candidates parse time : 1ms
C# parse time : -1ms
candidates check time : -1ms
console write time : -1ms

View File

@ -17,6 +17,9 @@ EditorUserSettings:
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036cdafbfb5831243c3d3204283a097df7ee3d2cfb
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
flags: 0