implementing goblin death, need to find way deactivate it for time

This commit is contained in:
2023-07-26 23:12:52 +03:00
parent acdd8b7d16
commit 9085da5e23
6 changed files with 536 additions and 400 deletions
File diff suppressed because it is too large Load Diff
+196 -87
View File
@@ -147,12 +147,12 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 17312387} m_GameObject: {fileID: 17312387}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.4586916, y: 5.3785906, z: 0.006108283} m_LocalPosition: {x: -5.4586916, y: 2.68, z: 0.006108283}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &21717978 --- !u!1001 &21717978
PrefabInstance: PrefabInstance:
@@ -427,17 +427,17 @@ CompositeCollider2D:
Y: -39999960 Y: -39999960
- X: 79999896 - X: 79999896
Y: -49999900 Y: -49999900
- X: -19999900 - X: 100
Y: -49999900 Y: -49999900
- X: -19999900 - X: 100
Y: -39999960 Y: -39999960
- X: -19999960 - X: 41
Y: -39999900 Y: -39999900
- X: -30000040 - X: -10000041
Y: -39999900 Y: -39999900
- X: -30000100 - X: -10000100
Y: -39999960 Y: -39999960
- X: -30000100 - X: -10000100
Y: -49999900 Y: -49999900
- X: -109999904 - X: -109999904
Y: -49999900 Y: -49999900
@@ -465,10 +465,10 @@ CompositeCollider2D:
- {x: 8.999974, y: -3.99999} - {x: 8.999974, y: -3.99999}
- {x: 7.9999895, y: -4.0000253} - {x: 7.9999895, y: -4.0000253}
- {x: 7.99996, y: -4.99999} - {x: 7.99996, y: -4.99999}
- {x: -1.99999, y: -4.999961} - {x: 0.00001, y: -4.999961}
- {x: -2.0000253, y: -3.99999} - {x: -0.0000252, y: -3.99999}
- {x: -3.00001, y: -4.0000253} - {x: -1.00001, y: -4.0000253}
- {x: -3.0000393, y: -4.99999} - {x: -1.0000395, y: -4.99999}
- {x: -10.99999, y: -4.999961} - {x: -10.99999, y: -4.999961}
- {x: -11.000026, y: -3.99999} - {x: -11.000026, y: -3.99999}
- {x: -12.00001, y: -4.0000253} - {x: -12.00001, y: -4.0000253}
@@ -831,7 +831,7 @@ Tilemap:
m_TileObjectToInstantiateIndex: 65535 m_TileObjectToInstantiateIndex: 65535
dummyAlignment: 0 dummyAlignment: 0
m_AllTileFlags: 2147483649 m_AllTileFlags: 2147483649
- first: {x: -3, y: -5, z: 0} - first: {x: -1, y: -5, z: 0}
second: second:
serializedVersion: 2 serializedVersion: 2
m_TileIndex: 5 m_TileIndex: 5
@@ -1233,7 +1233,6 @@ Transform:
- {fileID: 1209397942} - {fileID: 1209397942}
- {fileID: 1219386871} - {fileID: 1219386871}
- {fileID: 2048065635} - {fileID: 2048065635}
- {fileID: 2005091895}
- {fileID: 1037873121} - {fileID: 1037873121}
- {fileID: 1490001197} - {fileID: 1490001197}
- {fileID: 1200477712} - {fileID: 1200477712}
@@ -1974,6 +1973,150 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3} m_SourcePrefab: {fileID: 100100000, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
--- !u!1 &609050871
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 609050872}
- component: {fileID: 609050875}
- component: {fileID: 609050874}
- component: {fileID: 609050873}
m_Layer: 3
m_Name: Water
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &609050872
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 609050871}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4, y: -4.627, z: 0}
m_LocalScale: {x: 8, y: 0.76172, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 617249160}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &609050873
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 609050871}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: edf40d39eadb17a4ebb0368b3ac5399a, type: 3}
m_Name:
m_EditorClassIdentifier:
_elementSO: {fileID: 11400000, guid: 59cbe601225090b41a19270c63bc6390, type: 2}
--- !u!61 &609050874
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 609050871}
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, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!212 &609050875
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 609050871}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 1324c38828a739e4ca660eef55a4051b, 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: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -133646357
m_SortingLayer: 2
m_SortingOrder: 0
m_Sprite: {fileID: 7482667652216324306, guid: f50fac695ca5b9d44b880d4f5d3358a6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &617249158 --- !u!1 &617249158
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -2018,8 +2161,9 @@ Transform:
- {fileID: 276473129} - {fileID: 276473129}
- {fileID: 801411103} - {fileID: 801411103}
- {fileID: 324391215} - {fileID: 324391215}
- {fileID: 609050872}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &619094828 stripped --- !u!4 &619094828 stripped
Transform: Transform:
@@ -2477,7 +2621,7 @@ MonoBehaviour:
_movementSpeed: 1.2 _movementSpeed: 1.2
_bonesSide: {fileID: 0} _bonesSide: {fileID: 0}
_bonesBack: {fileID: 0} _bonesBack: {fileID: 0}
_spawnPoint: {fileID: 0} _spawnPoint: {fileID: 1544656458}
_mapLayer: _mapLayer:
serializedVersion: 2 serializedVersion: 2
m_Bits: 8 m_Bits: 8
@@ -2489,13 +2633,13 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 841812201} m_GameObject: {fileID: 841812201}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.8400002, y: 2.746, z: 0} m_LocalPosition: {x: 3.3400002, y: 2.746, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 1262117648} - {fileID: 1262117648}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &871569242 --- !u!1001 &871569242
PrefabInstance: PrefabInstance:
@@ -2971,11 +3115,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3} - target: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 3.5 value: 4.5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3} - target: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: -1.5 value: -0.5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3} - target: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
@@ -3404,67 +3548,6 @@ Transform:
m_CorrespondingSourceObject: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3} m_CorrespondingSourceObject: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3}
m_PrefabInstance: {fileID: 1539049558} m_PrefabInstance: {fileID: 1539049558}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1001 &1539906644
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 324391215}
m_Modifications:
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalPosition.x
value: -0.5
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalPosition.y
value: -4.5
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8175732239415438715, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
propertyPath: m_Name
value: Ladder (8)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
--- !u!1001 &1540980046 --- !u!1001 &1540980046
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -3538,6 +3621,37 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3d1aa56cd139405448c73b1385177b04, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 3d1aa56cd139405448c73b1385177b04, type: 3}
--- !u!1 &1544656458
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1544656459}
m_Layer: 0
m_Name: GoblinsSpawnPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1544656459
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1544656458}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4.5413084, y: 0.93000007, z: 0.006108283}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1573903785 --- !u!1001 &1573903785
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -3971,11 +4085,6 @@ Transform:
m_CorrespondingSourceObject: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3} m_CorrespondingSourceObject: {fileID: 7345322822309755345, guid: 3d1aa56cd139405448c73b1385177b04, type: 3}
m_PrefabInstance: {fileID: 938326545} m_PrefabInstance: {fileID: 938326545}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!4 &2005091895 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7345322822309755345, guid: b38f313f4560587478b6bc53fc9aaf5c, type: 3}
m_PrefabInstance: {fileID: 1539906644}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &2043218686 --- !u!1001 &2043218686
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -4087,7 +4196,7 @@ Transform:
- {fileID: 2142254919} - {fileID: 2142254919}
- {fileID: 1923000538} - {fileID: 1923000538}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &2133847487 stripped --- !u!4 &2133847487 stripped
Transform: Transform:
+11 -3
View File
@@ -26,6 +26,7 @@ public abstract class Character : MonoBehaviour
protected bool _isFalling; protected bool _isFalling;
protected bool _facingRight = true; protected bool _facingRight = true;
protected bool isCanGoDown = false;
protected bool isCanClimbUp=false; protected bool isCanClimbUp=false;
protected bool isAllowVertical = true; protected bool isAllowVertical = true;
protected bool isAllowRight = true; protected bool isAllowRight = true;
@@ -38,6 +39,7 @@ public abstract class Character : MonoBehaviour
_capsuleCollider = GetComponent<CapsuleCollider2D>(); _capsuleCollider = GetComponent<CapsuleCollider2D>();
_cellSize = new Vector2(0.6f, 1f); _cellSize = new Vector2(0.6f, 1f);
Spawn();
} }
protected void Spawn() protected void Spawn()
@@ -74,7 +76,7 @@ public abstract class Character : MonoBehaviour
if (_isOnLadder) if (_isOnLadder)
{ {
isCanClimbUp=CanClimbUp(); isCanClimbUp=CanClimbUp();
isCanGoDown = CanGoDown();
float ladderXCenterDistance = Mathf.Abs(transform.position.x - block.transform.position.x); float ladderXCenterDistance = Mathf.Abs(transform.position.x - block.transform.position.x);
float v_movement = inputVertical; float v_movement = inputVertical;
@@ -143,10 +145,16 @@ public abstract class Character : MonoBehaviour
return false; return false;
} }
private bool CanGoDown()
{
var rayCastHit = Physics2D.RaycastAll(_capsuleCollider.bounds.center, Vector2.down, _capsuleCollider.size.y+0.5f, _mapLayer);
if (rayCastHit.Any(x=>x.collider.transform.GetComponent<MapElement>().ElementSO.ElementType != MapElementType.Ladder))
return false;
return true;
}
private MapElement GetMapElement() private MapElement GetMapElement()
{ {
var collider = BoxCast(_capsuleCollider.bounds.center, _cellSize, 0f, Vector3.forward, .01f, _mapLayer); var collider = BoxCast(_capsuleCollider.bounds.center, _cellSize, 0f, Vector3.forward, .01f, _mapLayer);
Color color = Color.red; Color color = Color.red;
MapElement mapElement = null; MapElement mapElement = null;
+37 -18
View File
@@ -1,11 +1,15 @@
using UnityEditor.Experimental.GraphView; using UnityEngine;
using UnityEngine;
public class EnemyAI : Character public class EnemyAI : Character
{ {
private bool _needRespawn = false;
private int _respawnTimeout = 4;
private float _respawnElementTimer;
protected override void OnDeath() protected override void OnDeath()
{ {
} _needRespawn = true;
}
protected override void SetClimbingAnimation(bool isClimbing) protected override void SetClimbingAnimation(bool isClimbing)
{ {
@@ -17,35 +21,50 @@ public class EnemyAI : Character
private void Update() private void Update()
{ {
if(_needRespawn)
{
_respawnElementTimer -= Time.deltaTime;
if (_respawnElementTimer <= 0)
{
_respawnElementTimer = _respawnTimeout;
_needRespawn = false;
Spawn();
}
return;
}
float horizontal = 0; float horizontal = 0;
float vertical = 0; float vertical = 0;
Vector2 directionToPlayer = Player.Instance.transform.position - transform.position; Vector2 directionToPlayer = Player.Instance.transform.position - transform.position;
directionToPlayer.Normalize(); directionToPlayer.Normalize();
float verticalDistance = Player.Instance.transform.position.y - transform.position.y; float verticalDistance = Player.Instance.transform.position.y - transform.position.y;
if (Mathf.Abs(Player.Instance.transform.position.y - transform.position.y) < 0.1f)
if (verticalDistance > 0 && isCanClimbUp && isAllowVertical)
{ {
horizontal = directionToPlayer.x; vertical = VerticalMove(verticalDistance);
} }
else if (verticalDistance>0 && isCanClimbUp && isAllowVertical) else if (verticalDistance < 0 && isAllowVertical && isCanGoDown)
{ {
vertical =VerticalMove(verticalDistance); vertical = VerticalMove(verticalDistance);
}
else if (verticalDistance<0 && isAllowVertical)
{
vertical =VerticalMove(verticalDistance);
} }
else else
{ {
horizontal = directionToPlayer.x; if (Mathf.Abs(Player.Instance.transform.position.x - transform.position.x) < 0.1f)
} {
print($"horizontal block");
horizontal = 0;
}
else if (directionToPlayer.x < 0)
{ horizontal = -1; }
else if (directionToPlayer.x > 0)
{ horizontal = 1; }
}
print($"horizontal {horizontal}");
if (Input.GetKey(KeyCode.F))
{ horizontal = -1; }
if (Input.GetKey(KeyCode.H))
{ horizontal = 1; }
if (Input.GetKey(KeyCode.T)) if (Input.GetKey(KeyCode.T))
{ vertical = 1; } { vertical = 1; }
if (Input.GetKey(KeyCode.G)) if (Input.GetKey(KeyCode.G))
+4 -3
View File
@@ -15,7 +15,8 @@ public class BreakableWall : MapElement
private void Start() private void Start()
{ {
_boxCollider=GetComponent<BoxCollider2D>(); _respawnElementTimer = _respawnTimeout;
_boxCollider =GetComponent<BoxCollider2D>();
_spriteRenderer= GetComponentInChildren<SpriteRenderer>(); _spriteRenderer= GetComponentInChildren<SpriteRenderer>();
} }
@@ -23,7 +24,7 @@ public class BreakableWall : MapElement
{ {
IsEnabled = false; IsEnabled = false;
_boxCollider.isTrigger=true; _boxCollider.isTrigger=true;
_spriteRenderer.enabled = false; _spriteRenderer.enabled = IsEnabled;
Instantiate(_hitParticles, transform.position, Quaternion.identity); Instantiate(_hitParticles, transform.position, Quaternion.identity);
@@ -46,7 +47,7 @@ public class BreakableWall : MapElement
} }
IsEnabled = true; IsEnabled = true;
_boxCollider.isTrigger = false; _boxCollider.isTrigger = false;
_spriteRenderer.enabled = true; _spriteRenderer.enabled = IsEnabled;
_needRespawn = false; _needRespawn = false;
} }
} }
-1
View File
@@ -47,7 +47,6 @@ public class Player : Character
DontDestroyOnLoad(gameObject); DontDestroyOnLoad(gameObject);
_spriteRenderer = GetComponentInChildren<SpriteRenderer>(); _spriteRenderer = GetComponentInChildren<SpriteRenderer>();
Spawn();
} }
public void AddCoin() public void AddCoin()