Fire off impulses on booster taps

This commit is contained in:
Michal Pikulski
2025-11-06 18:57:10 +01:00
parent d01859cec0
commit 1b1ea65744
4 changed files with 102 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using AppleHills.Data.CardSystem;
@@ -7,8 +7,10 @@ using Pixelplacement;
using UI.Core;
using UI.CardSystem.DragDrop;
using UI.DragAndDrop.Core;
using Unity.Cinemachine;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UI;
namespace UI.CardSystem
{
@@ -35,6 +37,7 @@ namespace UI.CardSystem
[Header("Settings")]
[SerializeField] private float cardRevealDelay = 0.5f;
[SerializeField] private float boosterDisappearDuration = 0.5f;
[SerializeField] private CinemachineImpulseSource impulseSource;
private int _availableBoosterCount;
private BoosterPackDraggable _currentBoosterInCenter;
@@ -212,12 +215,22 @@ namespace UI.CardSystem
{
Debug.Log($"[BoosterOpeningPage] Booster tapped: {currentTaps}/{maxTaps}");
// Calculate shake intensity (increases with each tap)
float shakeIntensity = currentTaps / (float)maxTaps;
float shakeAmount = 10f + (shakeIntensity * 30f); // 10 to 40 units
// TODO: Shake visual feedback
// This would be handled by BoosterPackVisual if we add a shake method
// Fire Cinemachine impulse with random velocity (excluding Z)
if (impulseSource != null)
{
// Generate random velocity vector (X and Y only, Z = 0)
Vector3 randomVelocity = new Vector3(
Random.Range(-1f, 1f),
Random.Range(-1f, 1f),
0f
);
// Normalize to ensure consistent strength
randomVelocity.Normalize();
// Generate the impulse with strength 1 and random velocity
impulseSource.GenerateImpulse(randomVelocity);
}
}
/// <summary>