some issues with breakable walls

This commit is contained in:
2023-06-30 00:55:34 +03:00
parent d7d0f04865
commit f15102d89c
7 changed files with 2446 additions and 83 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ BoxCollider2D:
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 1
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
+1 -47
View File
@@ -451,7 +451,6 @@ GameObject:
- component: {fileID: 1716637651858965058}
- component: {fileID: 1693252312754102175}
- component: {fileID: 2957004661200399871}
- component: {fileID: 7385329991569660597}
m_Layer: 7
m_Name: Player
m_TagString: Player
@@ -476,7 +475,7 @@ Transform:
- {fileID: 4870077556839958209}
- {fileID: 8164636389946526648}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &1716637651858965058
Rigidbody2D:
@@ -549,51 +548,6 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!61 &7385329991569660597
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3931708971405200045}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
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: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -0.09, y: 0.03}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 0.825, y: 0.77175295}
newSize: {x: 0.825, y: 0.77175295}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.45, y: 0.89}
m_EdgeRadius: 0.01
--- !u!1 &4504781120003423342
GameObject:
m_ObjectHideFlags: 0
+57 -22
View File
@@ -458,8 +458,7 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2012902680}
m_Children: []
m_Father: {fileID: 1173618893}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -2953,13 +2952,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 432019649}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.4081335, y: 2.7943485, z: 0}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.6598201, y: 3.9637434, z: 0.08077757}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_Father: {fileID: 1123299336}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &489846349
PrefabInstance:
@@ -3119,7 +3118,7 @@ Transform:
m_Children:
- {fileID: 129193792}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &510997472
Rigidbody2D:
@@ -3234,13 +3233,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.0679536, y: 1.169395, z: -9.919223}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_Father: {fileID: 1123299336}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &519420033
MonoBehaviour:
@@ -4120,6 +4119,41 @@ Transform:
m_CorrespondingSourceObject: {fileID: 7047733282028940670, guid: 934a57b833e872445ac8463836f55a44, type: 3}
m_PrefabInstance: {fileID: 489846349}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1123299335
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1123299336}
m_Layer: 0
m_Name: Settings
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1123299336
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1123299335}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4.0679536, y: -1.169395, z: -0.08077757}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 519420032}
- {fileID: 1997312458}
- {fileID: 432019651}
- {fileID: 1278962562}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1173618891
GameObject:
m_ObjectHideFlags: 0
@@ -4162,13 +4196,14 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 679297304}
- {fileID: 2012902680}
- {fileID: 350695915}
- {fileID: 1314998801}
- {fileID: 1409424113}
- {fileID: 1322461127}
- {fileID: 996611801}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1261849835 stripped
Transform:
@@ -4312,13 +4347,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1278962560}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5, y: 0, z: 3.67}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.9320464, y: 1.169395, z: 3.7507777}
m_LocalScale: {x: 2, y: 2, z: 0}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_Father: {fileID: 1123299336}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1314998800
GameObject:
@@ -5715,13 +5750,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1997312456}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.0679536, y: 1.169395, z: 0.08077757}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_Father: {fileID: 1123299336}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &2001338310 stripped
Transform:
@@ -5764,7 +5799,7 @@ Transform:
- {fileID: 1782147597}
- {fileID: 838187539}
- {fileID: 1261849835}
m_Father: {fileID: 350695915}
m_Father: {fileID: 1173618893}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2068228311
@@ -6082,7 +6117,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 965998752200834250, guid: a7f273d812293e54d92972f62e1f0159, type: 3}
propertyPath: m_RootOrder
value: 2
value: 0
objectReference: {fileID: 0}
- target: {fileID: 965998752200834250, guid: a7f273d812293e54d92972f62e1f0159, type: 3}
propertyPath: m_LocalPosition.x
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: efcff2e58df318a45907362022583f4d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+5 -12
View File
@@ -28,7 +28,7 @@ public abstract class Character : MonoBehaviour
protected bool isAllowVertical = true;
protected bool isAllowRight = true;
protected bool isAllowLeft = true;
float v_movement = 0;
private void Start()
{
_body = GetComponent<Rigidbody2D>();
@@ -41,12 +41,12 @@ public abstract class Character : MonoBehaviour
_isOnBridge = mapElement == MapElementType.Bridge && !_isFalling;
float v_movement = 0;
if (mapElement == MapElementType.Wall || _isOnLadder || _isOnBridge || mapElement == MapElementType.BreakableWall)
{
var leftCheck = GetMapElement(Vector2.left);
var rightCheck = GetMapElement(Vector2.right);
if (leftCheck == MapElementType.Wall)
if (leftCheck == MapElementType.Wall || leftCheck == MapElementType.BreakableWall)
{
isAllowLeft = false;
}
@@ -54,7 +54,7 @@ public abstract class Character : MonoBehaviour
{
isAllowLeft = true;
}
if (rightCheck == MapElementType.Wall)
if (rightCheck == MapElementType.Wall || rightCheck== MapElementType.BreakableWall)
{
isAllowRight = false;
}
@@ -105,7 +105,7 @@ public abstract class Character : MonoBehaviour
private MapElementType GetMapElement(Vector2 direction)
{
var raycastHit = Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, 0.1f, _mapLayer);
var raycastHit = Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, 0.2f, _mapLayer);
if (raycastHit)
{
var mapElement = raycastHit.transform.GetComponent<MapElement>();
@@ -113,13 +113,6 @@ public abstract class Character : MonoBehaviour
{
return MapElementType.Empty;
}
if (mapElement.ElementSO.ElementType == MapElementType.BreakableWall)
{
if (mapElement.GetComponent<BoxCollider2D>().isTrigger)
{
return MapElementType.Empty;
}
}
return mapElement.ElementSO.ElementType;
}
return MapElementType.Empty;
+1 -1
View File
@@ -1,2 +1,2 @@
public enum TreasureType { Coin, Key }
public enum MapElementType {Empty,Wall,Ladder,Bridge,BreakableWall,Water }
public enum MapElementType {Empty,Wall,Ladder,Bridge,BreakableWall,Water,BreakableWall_disabled }