edit: attempted polish but failed
This commit is contained in:
parent
d59a00fdd3
commit
0001809418
58 changed files with 11705 additions and 140 deletions
45
Assets/Scripts/EntityScripts/BoardVisuals.cs
Normal file
45
Assets/Scripts/EntityScripts/BoardVisuals.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Lemon.GenericLib.VFX;
|
||||
|
||||
public class BoardVisuals : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("Runtime")]
|
||||
[Space]
|
||||
[Header("Refereces")]
|
||||
[SerializeField] private float shakeDuration = 0.1f;
|
||||
private GameBoard gameBoard;
|
||||
private CameraController cameraController;
|
||||
|
||||
|
||||
private bool initialized = false;
|
||||
|
||||
private void CheckInit()
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
//initialization code here
|
||||
gameBoard = GetComponent<GameBoard>();
|
||||
cameraController = CameraController.instanceCC;
|
||||
gameBoard.onDrop += shakeOnDrop;
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
CheckInit();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
CheckInit();
|
||||
gameBoard.onDrop -= shakeOnDrop;
|
||||
}
|
||||
|
||||
private void shakeOnDrop() {
|
||||
CheckInit();
|
||||
if (gameBoard.controlledByPlayer) cameraController?.ApplyScreenShake(shakeDuration, true);
|
||||
}
|
||||
}
|
11
Assets/Scripts/EntityScripts/BoardVisuals.cs.meta
Normal file
11
Assets/Scripts/EntityScripts/BoardVisuals.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 638bc47cbd1ff1d4ca0da9eb2373d01d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
84
Assets/Scripts/EntityScripts/TileVisuals.cs
Normal file
84
Assets/Scripts/EntityScripts/TileVisuals.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Lemon.GenericLib.VFX;
|
||||
|
||||
public class TileVisuals : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("Runtime")]
|
||||
[Space]
|
||||
[Header("Refereces")]
|
||||
private TileDrawer tileDrawer;
|
||||
[SerializeField] private HitFlash frontFlash;
|
||||
[SerializeField] private HitFlash backFlash;
|
||||
[SerializeField] private float flashDuration;
|
||||
[SerializeField] private float shakeDuration = 0.2f;
|
||||
private float entireDuration = 1.5f;
|
||||
private VFX_Manager vfxManager;
|
||||
private CameraController cameraController;
|
||||
private bool isPlayer;
|
||||
private bool initialized = false;
|
||||
|
||||
|
||||
private void CheckInit()
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
//initialization code here
|
||||
tileDrawer = GetComponent<TileDrawer>();
|
||||
entireDuration = tileDrawer.board.CollapseCycleTime;
|
||||
isPlayer = tileDrawer.board.controlledByPlayer;
|
||||
tileDrawer.onStateChange += updateVisuals;
|
||||
vfxManager = VFX_Manager.insatnceVFXM;
|
||||
cameraController = CameraController.instanceCC;
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CheckInit();
|
||||
}
|
||||
|
||||
|
||||
private void updateVisuals(TileDrawer.TileState tileState){
|
||||
CheckInit();
|
||||
switch (tileState)
|
||||
{
|
||||
case TileDrawer.TileState.idle:
|
||||
break;
|
||||
case TileDrawer.TileState.pending:
|
||||
StopCoroutine(FlashingCoroutine());
|
||||
StartCoroutine(FlashingCoroutine());
|
||||
break;
|
||||
case TileDrawer.TileState.poof:
|
||||
vfxManager?.spawnVFX("Explosion", transform.position);
|
||||
vfxManager?.spawnVFX("ParticlePuff", transform.position);
|
||||
if (isPlayer) {
|
||||
Debug.Log("bro!!!'");
|
||||
cameraController?.ApplyScreenShake(shakeDuration,10, true); //why does this not work!!!
|
||||
}
|
||||
|
||||
break;
|
||||
case TileDrawer.TileState.dropped:
|
||||
vfxManager?.spawnVFX("ParticlePound", transform.position + (Vector3.down * 0.5f));
|
||||
break;
|
||||
case TileDrawer.TileState.none:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator FlashingCoroutine() {
|
||||
frontFlash.Flash(flashDuration);
|
||||
//backFlash.Flash(flashDuration);
|
||||
yield return new WaitForSeconds(entireDuration - (flashDuration * 3));
|
||||
frontFlash.Flash(flashDuration);
|
||||
// backFlash.Flash(flashDuration);
|
||||
yield return new WaitForSeconds(flashDuration * 2);
|
||||
frontFlash.Flash(flashDuration);
|
||||
//backFlash.Flash(flashDuration);
|
||||
}
|
||||
}
|
11
Assets/Scripts/EntityScripts/TileVisuals.cs.meta
Normal file
11
Assets/Scripts/EntityScripts/TileVisuals.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ba56949b19f58e34da285c0974ae5092
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue