Add JumpPad feature with prefab and adapter implementation

This commit is contained in:
2025-12-12 22:27:28 +01:00
parent a6d486abb7
commit 3774fb9900
9 changed files with 332 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
using System;
using UnityEngine;
namespace Infrastructure.Unity
{
public class JumpPadAdapter : MonoBehaviour
{
[SerializeField] private float jumpForce = 15f;
[SerializeField] private ParticleSystem jumpVfx;
private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent<PlayerController>(out var player))
{
var vel = player.Rigidbody.linearVelocity;
vel.y = 0f;
player.Rigidbody.linearVelocity = vel;
player.Rigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
if (jumpVfx) jumpVfx.Play();
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5de94b384aac49a7baa41967735126b0
timeCreated: 1765574197

View File

@@ -9,6 +9,7 @@ namespace Infrastructure.Unity
[Header("Prefabs")]
[SerializeField] private TileViewAdapter tilePrefab;
[SerializeField] private ParticleSystem tileBreakVfxPrefab;
[SerializeField] private JumpPadAdapter jumpPadPrefab;
[Header("Settings")]
[SerializeField] private int gridSizeX = 10;
@@ -44,6 +45,14 @@ namespace Infrastructure.Unity
var pos = new Vector3(coord.x - xOffset, yOffset, coord.y - zOffset);
CreateTile(pos, $"{floorIndex}_{coord.x}_{coord.y}", floorIndex, soundManager, allTiles, tileViews);
}
if (floorIndex > 0 && jumpPadPrefab)
{
var validSpot = coordinates[Random.Range(0, coordinates.Count)];
var padPos = new Vector3(validSpot.x - xOffset, yOffset + 0.6f, validSpot.y - zOffset);
Instantiate(jumpPadPrefab, padPos, Quaternion.identity, transform);
}
}
private void CreateTile(Vector3 position, string id, int floorIndex, SoundManager soundManager,