move to 3d

This commit is contained in:
2026-06-22 17:04:35 +03:00
parent 5fbe7391d3
commit 57ac96e577
7 changed files with 440 additions and 513 deletions
+1 -1
View File
@@ -313,7 +313,7 @@ AnimatorState:
m_MirrorParameterActive: 0 m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0 m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: a0447cbe7f357b24f9a7801fc6a16453, type: 2} m_Motion: {fileID: 7400000, guid: 338fe03d4e50c43408a233110291c45e, type: 2}
m_Tag: m_Tag:
m_SpeedParameter: m_SpeedParameter:
m_MirrorParameter: m_MirrorParameter:
+50
View File
@@ -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: BlockWithGrass
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
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dcc7052cbcee8c841825fd9f6e2a349c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
+325 -485
View File
File diff suppressed because it is too large Load Diff
+29
View File
@@ -1,3 +1,4 @@
using System.Collections;
using UnityEngine; using UnityEngine;
public class Hammer : MonoBehaviour public class Hammer : MonoBehaviour
@@ -8,6 +9,8 @@ public class Hammer : MonoBehaviour
private bool _hasCollided = false; private bool _hasCollided = false;
private Rigidbody2D _rigidbody; private Rigidbody2D _rigidbody;
private Collider2D _collider; private Collider2D _collider;
private bool _canHit = false;
private Coroutine _disableHitCoroutine;
private void Awake() private void Awake()
{ {
@@ -61,6 +64,11 @@ public class Hammer : MonoBehaviour
private void ProcessHit(Collider2D collider, Vector2 impactVelocity, Vector2 contactPoint) private void ProcessHit(Collider2D collider, Vector2 impactVelocity, Vector2 contactPoint)
{ {
// Only process hits when the hammer is allowed to hit (activated by input)
if (!_canHit)
return;
StartCoroutine(ResetCollisionCoroutine());
// Check for enemy collision (stun) // Check for enemy collision (stun)
var enemy = collider.gameObject.GetComponent<Character>(); var enemy = collider.gameObject.GetComponent<Character>();
if (enemy != null) if (enemy != null)
@@ -83,6 +91,21 @@ public class Hammer : MonoBehaviour
EmitImpactNoise(contactPoint); EmitImpactNoise(contactPoint);
} }
public void ActivateHit(float duration)
{
_canHit = true;
if (_disableHitCoroutine != null)
StopCoroutine(_disableHitCoroutine);
_disableHitCoroutine = StartCoroutine(DisableHitAfter(duration));
}
private IEnumerator DisableHitAfter(float duration)
{
yield return new WaitForSeconds(duration);
_canHit = false;
_disableHitCoroutine = null;
}
private void HandleEnemyCollision(Character enemy, Vector2 impactVelocity) private void HandleEnemyCollision(Character enemy, Vector2 impactVelocity)
{ {
// Apply stun to enemy // Apply stun to enemy
@@ -106,4 +129,10 @@ public class Hammer : MonoBehaviour
} }
} }
private IEnumerator ResetCollisionCoroutine()
{
yield return new WaitForSeconds(0.25f);
_hasCollided = false;
}
} }
+2 -2
View File
@@ -26,7 +26,7 @@ public class BreakableWall : MapElement
public override void Hit() public override void Hit()
{ {
IsEnabled = false; IsEnabled = false;
_boxCollider.isTrigger = true; _boxCollider.enabled = false;
_spriteRenderer.enabled = IsEnabled; _spriteRenderer.enabled = IsEnabled;
Instantiate(_hitParticles, transform.position, Quaternion.identity); Instantiate(_hitParticles, transform.position, Quaternion.identity);
@@ -55,7 +55,7 @@ public class BreakableWall : MapElement
print("Character is dead"); print("Character is dead");
} }
IsEnabled = true; IsEnabled = true;
_boxCollider.isTrigger = false; _boxCollider.enabled = true;
_spriteRenderer.enabled = IsEnabled; _spriteRenderer.enabled = IsEnabled;
_needRespawn = false; _needRespawn = false;
} }
+12 -12
View File
@@ -12,8 +12,8 @@ public abstract class Character : MonoBehaviour
[SerializeField] [SerializeField]
private LayerMask _mapLayer; private LayerMask _mapLayer;
private Rigidbody2D _body; private Rigidbody _body;
private CapsuleCollider2D _capsuleCollider; private CapsuleCollider _capsuleCollider;
protected bool _isOnBridge; protected bool _isOnBridge;
private bool _isOnLadder = false; private bool _isOnLadder = false;
@@ -31,8 +31,8 @@ public abstract class Character : MonoBehaviour
public void Init() public void Init()
{ {
_body = GetComponent<Rigidbody2D>(); _body = GetComponent<Rigidbody>();
_capsuleCollider = GetComponent<CapsuleCollider2D>(); _capsuleCollider = GetComponent<CapsuleCollider>();
_cellSize = new Vector2(0.6f, 1f); _cellSize = new Vector2(0.6f, 1f);
} }
@@ -98,11 +98,11 @@ public abstract class Character : MonoBehaviour
if (_isOnLadder || _isOnBridge) if (_isOnLadder || _isOnBridge)
{ {
_body.gravityScale = 0; //_body.gravityScale = 0;
} }
else else
{ {
_body.gravityScale = 1; //_body.gravityScale = 1;
} }
if (_isFalling) if (_isFalling)
{ {
@@ -125,12 +125,12 @@ public abstract class Character : MonoBehaviour
private bool CanClimbUp() private bool CanClimbUp()
{ {
var rayCastHit = Physics2D.Raycast(_capsuleCollider.bounds.center, Vector2.down, _capsuleCollider.size.y / 2,_mapLayer); // var rayCastHit = Physics2D.Raycast(_capsuleCollider.bounds.center, Vector2.down, _capsuleCollider.size.y / 2,_mapLayer);
if(rayCastHit) // if(rayCastHit)
if(rayCastHit.collider.transform.GetComponent<MapElement>().ElementSO.ElementType==MapElementType.Ladder) // if(rayCastHit.collider.transform.GetComponent<MapElement>().ElementSO.ElementType==MapElementType.Ladder)
{ // {
return true; // return true;
} // }
return false; return false;
} }