move to 3d
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Ladder
|
||||
m_Shader: {fileID: 4800000, guid: e260cfa7296ee7642b167f1eb5be5023, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AlphaTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MaskTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _EnableExternalAlpha: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a253bbb828ea4844bfb6530c52307ff
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+239
-38
@@ -1368,6 +1368,8 @@ Transform:
|
||||
- {fileID: 1091993837}
|
||||
- {fileID: 2034197306}
|
||||
- {fileID: 627174955}
|
||||
- {fileID: 1480074359}
|
||||
- {fileID: 2097650047}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!19719996 &617249161
|
||||
@@ -1474,7 +1476,7 @@ Transform:
|
||||
m_GameObject: {fileID: 627174954}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -6.512, y: -2.691, z: 0}
|
||||
m_LocalPosition: {x: -6.5, y: -2.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
@@ -2622,6 +2624,118 @@ SpriteRenderer:
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &1480074358
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1480074359}
|
||||
- component: {fileID: 1480074362}
|
||||
- component: {fileID: 1480074361}
|
||||
- component: {fileID: 1480074360}
|
||||
m_Layer: 3
|
||||
m_Name: Cube (2)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1480074359
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1480074358}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -5.5, y: -2.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 617249160}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!65 &1480074360
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1480074358}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &1480074361
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1480074358}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
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: 9452ae1262a74094f8a68013fbcd1834, 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_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &1480074362
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1480074358}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &1504345146
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3383,16 +3497,13 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::MapElement
|
||||
_elementSO: {fileID: 11400000, guid: 8a480e639bc6f0c44815c3b3dd16e0aa, type: 2}
|
||||
--- !u!61 &1828430749
|
||||
BoxCollider2D:
|
||||
--- !u!65 &1828430749
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1828430745}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
@@ -3401,34 +3512,12 @@ BoxCollider2D:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_ForceSendLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ForceReceiveLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ContactCaptureLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_CallbackLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_CompositeOperation: 0
|
||||
m_CompositeOrder: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 1.08, y: 1.96}
|
||||
newSize: {x: 1.08, y: 1.96}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
m_Size: {x: 1.08, y: 1.96}
|
||||
m_EdgeRadius: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 0.4462986, y: 1.96, z: 0.2}
|
||||
m_Center: {x: 0.0051937103, y: 0, z: 0}
|
||||
--- !u!1 &1831474520
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3999,6 +4088,118 @@ Transform:
|
||||
- {fileID: 1923000538}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2097650046
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2097650047}
|
||||
- component: {fileID: 2097650050}
|
||||
- component: {fileID: 2097650049}
|
||||
- component: {fileID: 2097650048}
|
||||
m_Layer: 3
|
||||
m_Name: Cube (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2097650047
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2097650046}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -7.5, y: -2.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 617249160}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!65 &2097650048
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2097650046}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &2097650049
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2097650046}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
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: 9452ae1262a74094f8a68013fbcd1834, 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_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &2097650050
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2097650046}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!1 &2142254918
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4281,7 +4482,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 249451357978777301}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0.8480481, z: 0, w: 0.5299193}
|
||||
m_LocalRotation: {x: 0, y: 0.76604444, z: 0, w: 0.64278764}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@@ -4289,7 +4490,7 @@ Transform:
|
||||
- {fileID: 2543951424218242873}
|
||||
- {fileID: 4930800371010268411}
|
||||
m_Father: {fileID: 7687862676731468201}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 116, z: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 100, z: 0}
|
||||
--- !u!95 &593888134675041392
|
||||
Animator:
|
||||
serializedVersion: 7
|
||||
@@ -5545,9 +5746,9 @@ CapsuleCollider:
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.35
|
||||
m_Height: 1.04
|
||||
m_Height: 0.9225253
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0.5, z: 0}
|
||||
m_Center: {x: 0, y: 0.47289044, z: 0}
|
||||
--- !u!54 &8117888831474612991
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -5573,7 +5774,7 @@ Rigidbody:
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_Constraints: 112
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &8258636392711292803
|
||||
GameObject:
|
||||
|
||||
@@ -50,7 +50,7 @@ public class PlayerController : Character
|
||||
_isHoldingHammer = true;
|
||||
}
|
||||
|
||||
MoveTo(_currentMovement.x, isAllowVertical ? _currentMovement.y : 0);
|
||||
MoveTo(_currentMovement.x, IsAllowVertical ? _currentMovement.y : 0);
|
||||
}
|
||||
|
||||
private void OnMovementChanged(Vector2 movement)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Ladder : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerEnter(Collider collider)
|
||||
{
|
||||
Debug.Log($"Ladder: OnTriggerEnter {collider.name}");
|
||||
if (collider.TryGetComponent<Character>(out var character))
|
||||
{
|
||||
character.IsAllowVertical = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider collider)
|
||||
{
|
||||
Debug.Log($"Ladder: OnTriggerExit {collider.name}");
|
||||
if (collider.TryGetComponent<Character>(out var character))
|
||||
{
|
||||
character.IsAllowVertical = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3d38fc44e58efe4e9fc763685459355
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,13 +7,19 @@ public abstract class Character : MonoBehaviour
|
||||
[SerializeField]
|
||||
protected Animator _animator;
|
||||
[SerializeField]
|
||||
private Transform _visualRoot;
|
||||
[SerializeField]
|
||||
private float _movementSpeed = 1.5f;
|
||||
|
||||
[SerializeField]
|
||||
private LayerMask _mapLayer;
|
||||
|
||||
private Rigidbody _body;
|
||||
private Rigidbody rigidBody;
|
||||
private Rigidbody2D rigidBody2D;
|
||||
private Collider2D _collider2D;
|
||||
private CapsuleCollider _capsuleCollider;
|
||||
private float _lastFlipTime;
|
||||
private const float FlipCooldown = 0.12f;
|
||||
protected bool _isOnBridge;
|
||||
private bool _isOnLadder = false;
|
||||
|
||||
@@ -22,7 +28,7 @@ public abstract class Character : MonoBehaviour
|
||||
|
||||
protected bool isCanGoDown = false;
|
||||
protected bool isCanClimbUp=false;
|
||||
protected bool isAllowVertical = true;
|
||||
public bool IsAllowVertical { get; set; }
|
||||
protected bool isAllowRight = true;
|
||||
protected bool isAllowLeft = true;
|
||||
private Vector2 _cellSize;
|
||||
@@ -31,70 +37,105 @@ public abstract class Character : MonoBehaviour
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_body = GetComponent<Rigidbody>();
|
||||
_capsuleCollider = GetComponent<CapsuleCollider>();
|
||||
_cellSize = new Vector2(0.6f, 1f);
|
||||
}
|
||||
|
||||
protected void MoveTo(float inputHorizontal, float inputVertical)
|
||||
{
|
||||
var block = GetMapElement();
|
||||
|
||||
if (block?.ElementSO.ElementType == MapElementType.Water)
|
||||
rigidBody2D = GetComponent<Rigidbody2D>();
|
||||
if (rigidBody2D != null)
|
||||
{
|
||||
Death();
|
||||
}
|
||||
|
||||
_isOnBridge = block?.ElementSO.ElementType == MapElementType.Bridge && !_isFalling;
|
||||
|
||||
if (block)
|
||||
{
|
||||
isAllowVertical = false;
|
||||
_isFalling = false;
|
||||
float h_movement = inputHorizontal;
|
||||
|
||||
if (h_movement > 0 && !_facingRight || h_movement < 0 && _facingRight)
|
||||
{
|
||||
FlipCharacter();
|
||||
}
|
||||
|
||||
SetWalkingAnimation(h_movement != 0);
|
||||
|
||||
_isOnLadder = block.ElementSO.ElementType == MapElementType.Ladder;
|
||||
|
||||
if (_isOnLadder)
|
||||
{
|
||||
isCanClimbUp=CanClimbUp();
|
||||
isCanGoDown = CanGoDown();
|
||||
float ladderXCenterDistance = Mathf.Abs(transform.position.x - block.transform.position.x);
|
||||
|
||||
float v_movement = inputVertical;
|
||||
isAllowVertical = (ladderXCenterDistance < 0.3f);
|
||||
if(!isCanClimbUp&& v_movement>0)
|
||||
{
|
||||
v_movement=0;
|
||||
}
|
||||
|
||||
if (isAllowVertical)
|
||||
{
|
||||
SetClimbingAnimation(v_movement != 0);
|
||||
_body.linearVelocity = new Vector2(h_movement * _movementSpeed, v_movement * _movementSpeed);
|
||||
}
|
||||
else{
|
||||
_body.linearVelocity = new Vector2(h_movement * _movementSpeed, _body.linearVelocity.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_body.linearVelocity = new Vector2(h_movement * _movementSpeed, _body.linearVelocity.y);
|
||||
}
|
||||
_collider2D = GetComponent<Collider2D>();
|
||||
rigidBody2D.constraints = RigidbodyConstraints2D.FreezeRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isFalling = true;
|
||||
_isOnLadder = false;
|
||||
rigidBody = GetComponent<Rigidbody>();
|
||||
_capsuleCollider = GetComponent<CapsuleCollider>();
|
||||
if (rigidBody != null)
|
||||
{
|
||||
rigidBody.constraints = RigidbodyConstraints.FreezeRotation;
|
||||
}
|
||||
}
|
||||
|
||||
_cellSize = new Vector2(0.6f, 1f);
|
||||
|
||||
if (_visualRoot == null)
|
||||
{
|
||||
if (_animator != null && _animator.transform != transform)
|
||||
{
|
||||
_visualRoot = _animator.transform;
|
||||
}
|
||||
else if (transform.childCount > 0)
|
||||
{
|
||||
_visualRoot = transform.GetChild(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_visualRoot = transform;
|
||||
}
|
||||
}
|
||||
|
||||
if (_animator != null)
|
||||
{
|
||||
_animator.applyRootMotion = false;
|
||||
}
|
||||
}
|
||||
|
||||
private const float MovementFlipThreshold = 0.1f;
|
||||
|
||||
protected void MoveTo(float inputHorizontal, float inputVertical)
|
||||
{
|
||||
_isFalling = false;
|
||||
float h_movement = inputHorizontal;
|
||||
|
||||
if (Mathf.Abs(h_movement) > MovementFlipThreshold)
|
||||
{
|
||||
if (Time.time - _lastFlipTime > FlipCooldown)
|
||||
{
|
||||
if (h_movement > 0 && !_facingRight || h_movement < 0 && _facingRight)
|
||||
{
|
||||
FlipCharacter();
|
||||
_lastFlipTime = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetWalkingAnimation(Mathf.Abs(h_movement) > Mathf.Epsilon);
|
||||
|
||||
//_isOnLadder = block.ElementSO.ElementType == MapElementType.Ladder;
|
||||
|
||||
if (IsAllowVertical)
|
||||
{
|
||||
if (rigidBody2D != null)
|
||||
{
|
||||
rigidBody2D.gravityScale = 0f;
|
||||
float v_movement = inputVertical;
|
||||
SetClimbingAnimation(v_movement != 0);
|
||||
rigidBody2D.velocity = new Vector2(h_movement * _movementSpeed, v_movement * _movementSpeed);
|
||||
}
|
||||
else if (rigidBody != null)
|
||||
{
|
||||
rigidBody.useGravity = false;
|
||||
float v_movement = inputVertical;
|
||||
SetClimbingAnimation(v_movement != 0);
|
||||
rigidBody.velocity = new Vector2(h_movement * _movementSpeed, v_movement * _movementSpeed);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rigidBody2D != null)
|
||||
{
|
||||
rigidBody2D.gravityScale = 1f;
|
||||
rigidBody2D.velocity = new Vector2(h_movement * _movementSpeed, rigidBody2D.velocity.y);
|
||||
}
|
||||
else if (rigidBody != null)
|
||||
{
|
||||
rigidBody.useGravity = true;
|
||||
rigidBody.velocity = new Vector3(h_movement * _movementSpeed, rigidBody.velocity.y, 0f);
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// _isFalling = true;
|
||||
// _isOnLadder = false;
|
||||
// }
|
||||
|
||||
|
||||
if (_isOnLadder || _isOnBridge)
|
||||
{
|
||||
@@ -104,17 +145,17 @@ public abstract class Character : MonoBehaviour
|
||||
{
|
||||
//_body.gravityScale = 1;
|
||||
}
|
||||
if (_isFalling)
|
||||
{
|
||||
_body.linearVelocity = new Vector2(0, _body.linearVelocity.y);
|
||||
SetWalkingAnimation(false);
|
||||
// if (_isFalling)
|
||||
// {
|
||||
// _body.linearVelocity = new Vector2(0, _body.linearVelocity.y);
|
||||
// SetWalkingAnimation(false);
|
||||
|
||||
if (block?.ElementSO.ElementType == MapElementType.Ladder)
|
||||
{
|
||||
_body.linearVelocity = Vector2.zero;
|
||||
_isOnLadder = true;
|
||||
}
|
||||
}
|
||||
// if (block?.ElementSO.ElementType == MapElementType.Ladder)
|
||||
// {
|
||||
// _body.linearVelocity = Vector2.zero;
|
||||
// _isOnLadder = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -134,110 +175,44 @@ public abstract class Character : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool CanGoDown()
|
||||
{
|
||||
var rayCastHit = Physics2D.RaycastAll(_capsuleCollider.bounds.center, Vector2.down, 0.5f, _mapLayer);
|
||||
var isNoladder = rayCastHit.Any(x => x.collider.transform.GetComponent<MapElement>().ElementSO.ElementType != MapElementType.Ladder);
|
||||
foreach (var hit in rayCastHit)
|
||||
{
|
||||
Debug.DrawLine(hit.point, hit.point + hit.normal.normalized * 0.2f, isNoladder? Color.blue: Color.red);
|
||||
}
|
||||
// private bool CanGoDown()
|
||||
// {
|
||||
// var rayCastHit = Physics2D.RaycastAll(_capsuleCollider.bounds.center, Vector2.down, 0.5f, _mapLayer);
|
||||
// var isNoladder = rayCastHit.Any(x => x.collider.transform.GetComponent<MapElement>().ElementSO.ElementType != MapElementType.Ladder);
|
||||
// foreach (var hit in rayCastHit)
|
||||
// {
|
||||
// Debug.DrawLine(hit.point, hit.point + hit.normal.normalized * 0.2f, isNoladder? Color.blue: Color.red);
|
||||
// }
|
||||
|
||||
if (isNoladder)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// if (isNoladder)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private MapElement GetMapElement()
|
||||
{
|
||||
var collider = BoxCast(_capsuleCollider.bounds.center, _cellSize, 0f, Vector3.forward, .01f, _mapLayer);
|
||||
Color color = Color.red;
|
||||
MapElement mapElement = null;
|
||||
if (collider.Length > 0)
|
||||
{
|
||||
var elements=collider.Select(x=>x.transform.GetComponent<MapElement>());
|
||||
mapElement = elements.Where(x => x.ElementSO.ElementType == MapElementType.Ladder).FirstOrDefault();
|
||||
if(mapElement == null)
|
||||
{
|
||||
mapElement = elements.First();
|
||||
}
|
||||
}
|
||||
|
||||
return mapElement;
|
||||
}
|
||||
// return true;
|
||||
// }
|
||||
|
||||
protected abstract void SetWalkingAnimation(bool isWalking);
|
||||
protected abstract void SetClimbingAnimation(bool isClimbing);
|
||||
|
||||
|
||||
|
||||
private void FlipCharacter()
|
||||
{
|
||||
Vector3 currentScale = gameObject.transform.localScale;
|
||||
currentScale.x *= -1;
|
||||
gameObject.transform.localScale = currentScale;
|
||||
|
||||
_facingRight = !_facingRight;
|
||||
|
||||
var flipTarget = _visualRoot != null ? _visualRoot : transform;
|
||||
var localScale = flipTarget.localScale;
|
||||
localScale.x = Mathf.Abs(localScale.x) * (_facingRight ? 1f : -1f);
|
||||
flipTarget.localScale = localScale;
|
||||
|
||||
if (rigidBody2D != null)
|
||||
{
|
||||
rigidBody2D.angularVelocity = 0f;
|
||||
}
|
||||
else if (rigidBody != null)
|
||||
{
|
||||
rigidBody.angularVelocity = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
static public Collider2D[] BoxCast(Vector2 origin, Vector2 size, float angle, Vector2 direction, float distance, int mask)
|
||||
{
|
||||
//RaycastHit2D hit = Physics2D.BoxCast(origin, size, angle, direction, distance, mask);
|
||||
var collider = Physics2D.OverlapBoxAll(origin, size, angle, mask);
|
||||
//Setting up the points to draw the cast
|
||||
Vector2 p1, p2, p3, p4, p5, p6, p7, p8;
|
||||
float w = size.x * 0.5f;
|
||||
float h = size.y * 0.5f;
|
||||
p1 = new Vector2(-w, h);
|
||||
p2 = new Vector2(w, h);
|
||||
p3 = new Vector2(w, -h);
|
||||
p4 = new Vector2(-w, -h);
|
||||
|
||||
Quaternion q = Quaternion.AngleAxis(angle, new Vector3(0, 0, 1));
|
||||
p1 = q * p1;
|
||||
p2 = q * p2;
|
||||
p3 = q * p3;
|
||||
p4 = q * p4;
|
||||
|
||||
p1 += origin;
|
||||
p2 += origin;
|
||||
p3 += origin;
|
||||
p4 += origin;
|
||||
|
||||
Vector2 realDistance = direction.normalized * distance;
|
||||
p5 = p1 + realDistance;
|
||||
p6 = p2 + realDistance;
|
||||
p7 = p3 + realDistance;
|
||||
p8 = p4 + realDistance;
|
||||
|
||||
|
||||
//Drawing the cast
|
||||
Color castColor = collider.Length > 0 ? Color.red : Color.green;
|
||||
Debug.DrawLine(p1, p2, castColor);
|
||||
Debug.DrawLine(p2, p3, castColor);
|
||||
Debug.DrawLine(p3, p4, castColor);
|
||||
Debug.DrawLine(p4, p1, castColor);
|
||||
|
||||
Debug.DrawLine(p5, p6, castColor);
|
||||
Debug.DrawLine(p6, p7, castColor);
|
||||
Debug.DrawLine(p7, p8, castColor);
|
||||
Debug.DrawLine(p8, p5, castColor);
|
||||
|
||||
Debug.DrawLine(p1, p5, Color.grey);
|
||||
Debug.DrawLine(p2, p6, Color.grey);
|
||||
Debug.DrawLine(p3, p7, Color.grey);
|
||||
Debug.DrawLine(p4, p8, Color.grey);
|
||||
|
||||
//collider
|
||||
//if (hit)
|
||||
//{
|
||||
// var color = hit.point.x > origin.x ? Color.yellow : Color.cyan;
|
||||
// Debug.DrawLine(hit.point, hit.point + hit.normal.normalized * 0.2f, color);
|
||||
//}
|
||||
|
||||
return collider;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,143 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00bae9795f9d677449affc8ab36d0ef6
|
||||
TextureImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
213: -1820603028629595944
|
||||
second: BlockWithGrassNormal_0
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 2
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 1
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites:
|
||||
- serializedVersion: 2
|
||||
name: BlockWithGrassNormal_0
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 31
|
||||
y: 69
|
||||
width: 962
|
||||
height: 900
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: -1
|
||||
bones: []
|
||||
spriteID: 8d85881013bebb6e0800000000000000
|
||||
internalID: -1820603028629595944
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable:
|
||||
BlockWithGrassNormal_0: -1820603028629595944
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
@@ -0,0 +1,143 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0e79b22aa2c2cf4897acff5dab9107f
|
||||
TextureImporter:
|
||||
internalIDToNameTable:
|
||||
- first:
|
||||
213: 8046967734326154704
|
||||
second: BlockWithGrassUV_0
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 2
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites:
|
||||
- serializedVersion: 2
|
||||
name: BlockWithGrassUV_0
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 47
|
||||
y: 103
|
||||
width: 930
|
||||
height: 842
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: -1
|
||||
bones: []
|
||||
spriteID: 0d55a8b05829caf60800000000000000
|
||||
internalID: 8046967734326154704
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable:
|
||||
BlockWithGrassUV_0: 8046967734326154704
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b7b001ea8e24b64ab785904b9cfc513
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user