RandomGFGoStop/Assets/Scripts/UI/GamePanel/GamePanel_Effect.cs

332 lines
13 KiB
C#
Raw Blame History

using CodeJay.Enum;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class GamePanel_Effect : MonoBehaviour
{
[SerializeField] private TMPro.TextMeshProUGUI TMP;
[SerializeField] private UnityEngine.UI.Image PlayerTurnDirectImage;
public GameObject[] gos_EffectGo;
public GameObject go_Godori, go_Ddadak, go_Be3Gwang, go_3Gwang, go_4Gwang, go_5Gwang, go_nagari, go_Bbuk, go_Stop;
public GameObject go_SSackssri, go_Kiss, go_Chodan, go_Chungdan, go_Hongdan, go_muhyo, go_jabbuk, go_eatbbuk;
public GameObject go_eatmybbuk, go_Firstbbuk, go_ChongTong, go_Shake, go_Bonus, go_SangdaeBonus;
public GameObject go_bomb, go_double;
private Dictionary<EEffectAnimationKey, int> _dictAnimTriggerHash = new Dictionary<EEffectAnimationKey, int>();
private Dictionary<EEffectDirectType, float> _dicEffectDurations = new Dictionary<EEffectDirectType, float>();
private System.Collections.IEnumerator _eDirect = null;
private void Awake()
{
for (EEffectDirectType i = 0; i < EEffectDirectType.Max; i++)
_dicEffectDurations.Add(i, 1.3f);
_dicEffectDurations[EEffectDirectType.NoneCard] = 0.5f;
_dicEffectDurations[EEffectDirectType.Normal] = 0.25f;
_dicEffectDurations[EEffectDirectType.Bonus] = 0.5f;
TMP.enabled = false;
for (EEffectAnimationKey i = 0; i < EEffectAnimationKey.Max; i++)
{
_dictAnimTriggerHash.Add(i, Animator.StringToHash(i.ToString()));
}
if (GameManager.Instance != null)
{
GameManager.Event.RegistEvent(EEventType.OnGameEnd, this.OnGameEnd);
}
}
private void OnDestroy()
{
if (GameManager.Instance != null)
{
GameManager.Event.RegistEvent(EEventType.OnGameEnd, this.OnGameEnd);
}
}
private void OnGameEnd()
{
if (_eDirect != null)
StopCoroutine(_eDirect);
StopAllCoroutines();
TMP.enabled = false;
if (DOTween.IsTweening(PlayerTurnDirectImage))
PlayerTurnDirectImage.DOKill();
}
public float GetEffectDuration(EEffectDirectType effectType)
{
if (_dicEffectDurations.ContainsKey(effectType))
return _dicEffectDurations[effectType] / GamePanel.GameSpeed;
else
return 1f / GamePanel.GameSpeed;
}
public void PlayerTurnDirectEnabled(bool b)
{
PlayerTurnDirectImage.enabled = b;
if (b)
{
PlayerTurnDirectImage.DOColor(new Color(1, 1, 0, 1), 1f).From(new Color(1, 1, 0, 0.5f)).SetLoops(-1, LoopType.Yoyo).SetRecyclable();
}
else
{
if (DOTween.IsTweening(PlayerTurnDirectImage))
PlayerTurnDirectImage.DOKill();
}
}
public float Direct(EEffectDirectType type, bool isPlayer)
{
//TMP.text = isPlayer ? "" : "<22><><EFBFBD> ";
if (_eDirect != null)
StopCoroutine(_eDirect);
_eDirect = coroDirect(type, isPlayer);
StartCoroutine(_eDirect);
return this.GetEffectDuration(type);
}
public IEnumerator Direct(ECombinationType combinationType, bool isPlayer)
{
TMP.text = isPlayer ? "" : "<22><><EFBFBD> ";
if (_eDirect != null)
StopCoroutine(_eDirect);
EEffectDirectType type = EEffectDirectType.Max;
switch (combinationType)
{
case ECombinationType.Hongdan:
type = EEffectDirectType.Hongdan;
break;
case ECombinationType.Chungdan:
type = EEffectDirectType.Chungdan;
break;
case ECombinationType.Chodan:
type = EEffectDirectType.Chodan;
break;
case ECombinationType.Godori:
type = EEffectDirectType.Godori;
break;
case ECombinationType.Be_Three_Ghwang:
type = EEffectDirectType.Be_Three_Ghwang;
break;
case ECombinationType.Three_Ghwang:
type = EEffectDirectType.Three_Ghwang;
break;
case ECombinationType.Four_Ghwang:
type = EEffectDirectType.Four_Ghwang;
break;
case ECombinationType.Five_Ghwang:
type = EEffectDirectType.Five_Ghwang;
break;
}
_eDirect = coroDirect(type, isPlayer);
yield return StartCoroutine(_eDirect);
}
public IEnumerator GoDirect(int goNumber, bool isPlayer)
{
//TMP.text = isPlayer ? "" : "<22><><EFBFBD> ";
//TMP.text += goNumber.ToString() + "<22><>!";
TMP.enabled = false;
//string triggerTxt = "Go" + string.Format("{0:D2}", goNumber);
//EffectAnimator.SetTrigger(triggerTxt);
DSUtil.InActivateGameObjects(gos_EffectGo, goNumber - 1);
GameManager.Sound.PlayGoVoice(goNumber);
yield return new WaitForSeconds(1f);
DSUtil.InActivateGameObjects(gos_EffectGo);
TMP.enabled = false;
_eDirect = null;
}
public IEnumerator NagariEffect()
{
go_nagari.SetActive(true);
yield return new WaitForSeconds(2f);
go_nagari.SetActive(false);
_eDirect = null;
}
private System.Collections.IEnumerator coroDirect(EEffectDirectType type, bool isPlayer)
{
TMP.enabled = false;
switch (type)
{
case EEffectDirectType.NoneCard:
TMP.enabled = true;
//TMP.text += "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
break;
case EEffectDirectType.Hongdan:
go_Hongdan.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Hongdan_1);
GameManager.Sound.PlayVoice(EVoiceType.Hongdan_Voice);
yield return new WaitForSeconds(1f);
go_Hongdan.SetActive(false);
break;
case EEffectDirectType.Chungdan:
go_Chungdan.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Chungdan_1);
GameManager.Sound.PlayVoice(EVoiceType.Chungdan_Voice);
yield return new WaitForSeconds(1f);
go_Chungdan.SetActive(false);
break;
case EEffectDirectType.Chodan:
go_Chodan.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Chodan_1);
GameManager.Sound.PlayVoice(EVoiceType.Chodan_Voice);
yield return new WaitForSeconds(1f);
go_Chodan.SetActive(false);
break;
case EEffectDirectType.Godori:
go_Godori.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Godori_2);
GameManager.Sound.PlayVoice(EVoiceType.Godori_Voice);
yield return new WaitForSeconds(1f);
go_Godori.SetActive(false);
break;
case EEffectDirectType.Be_Three_Ghwang:
go_Be3Gwang.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Bee_Three_Ghwang);
GameManager.Sound.PlayVoice(EVoiceType.Be_Three_Gwhang);
yield return new WaitForSeconds(1f);
go_Be3Gwang.SetActive(false);
break;
case EEffectDirectType.Three_Ghwang:
go_3Gwang.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Three_Gwhang_1);
GameManager.Sound.PlayVoice(EVoiceType.Samgwang_Voice);
yield return new WaitForSeconds(1f);
go_3Gwang.SetActive(false);
break;
case EEffectDirectType.Four_Ghwang:
go_4Gwang.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Four_Ghwang);
GameManager.Sound.PlayVoice(EVoiceType.Sagwang_Voice);
yield return new WaitForSeconds(1f);
go_4Gwang.SetActive(false);
break;
case EEffectDirectType.Five_Ghwang:
go_5Gwang.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Five_Ghwang);
GameManager.Sound.PlayVoice(EVoiceType.Ogwang_Voice);
yield return new WaitForSeconds(1f);
go_5Gwang.SetActive(false);
break;
case EEffectDirectType.FirstBbug:
go_Firstbbuk.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Bbug_2);
GameManager.Sound.PlayVoice(EVoiceType.Bbug_1_Voice);
yield return new WaitForSeconds(1f);
go_Firstbbuk.SetActive(false);
break;
case EEffectDirectType.Bbug:
go_Bbuk.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Bbug_2);
GameManager.Sound.PlayVoice(EVoiceType.Bbug_1_Voice);
yield return new WaitForSeconds(1f);
go_Bbuk.SetActive(false);
break;
case EEffectDirectType.Bbug_Own:
go_jabbuk.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Bbug_2);
GameManager.Sound.PlayVoice(EVoiceType.Bbug_1_Voice);
yield return new WaitForSeconds(1f);
go_jabbuk.SetActive(false);
break;
case EEffectDirectType.GetBbug:
go_eatbbuk.SetActive(true);
yield return new WaitForSeconds(1f);
go_eatbbuk.SetActive(false);
break;
case EEffectDirectType.GetBbug_Own:
go_eatmybbuk.SetActive(true);
yield return new WaitForSeconds(1f);
go_eatmybbuk.SetActive(false);
break;
case EEffectDirectType.Kiss:
go_Kiss.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Kiss);
GameManager.Sound.PlayVoice(EVoiceType.Kiss_Voice);
yield return new WaitForSeconds(1f);
go_Kiss.SetActive(false);
break;
case EEffectDirectType.Clean:
go_SSackssri.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Clean_2);
GameManager.Sound.PlayVoice(EVoiceType.Clear_Voice_1);
yield return new WaitForSeconds(1f);
go_SSackssri.SetActive(false);
break;
case EEffectDirectType.Bell:
go_Shake.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Shake);
GameManager.Sound.PlayVoice(EVoiceType.Shake_Voice);
yield return new WaitForSeconds(1f);
go_Shake.SetActive(false);
break;
case EEffectDirectType.Bomb_Double:
case EEffectDirectType.Bomb_Triple:
go_bomb.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Bomb_1);
GameManager.Sound.PlayVoice(EVoiceType.Bomb_Voice);
yield return new WaitForSeconds(1f);
go_bomb.SetActive(false);
break;
case EEffectDirectType.Normal:
TMP.enabled = true;
break;
case EEffectDirectType.Selectable:
TMP.enabled = true;
break;
case EEffectDirectType.Bonus:
TMP.enabled = false;
if (isPlayer == true)
go_Bonus.SetActive(true);
else
go_SangdaeBonus.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Bonus);
yield return new WaitForSeconds(1f);
go_Bonus.SetActive(false);
go_SangdaeBonus.SetActive(false);
break;
case EEffectDirectType.Stop:
go_Stop.SetActive(false);
go_Stop.SetActive(true);
GameManager.Sound.PlayVoice(EVoiceType.Stop_1_Voice);
yield return new WaitForSeconds(1f);
go_Stop.SetActive(false);
break;
case EEffectDirectType.Ddadak:
go_Ddadak.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Ddadag_1);
GameManager.Sound.PlayVoice(EVoiceType.Ddadag_Voice);
yield return new WaitForSeconds(1f);
go_Ddadak.SetActive(false);
break;
case EEffectDirectType.Double:
go_double.SetActive(true);
GameManager.Sound.PlaySFX(ESFXType.Godori_2);
yield return new WaitForSeconds(1f);
go_Ddadak.SetActive(false);
break;
}
//yield return new WaitForSeconds(_dicEffectDurations[type]);
//TMP.enabled = false;
_eDirect = null;
}
}