2022-02-09 08:35:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
2022-02-09 11:36:47 +00:00
|
|
|
|
using DG.Tweening;
|
2022-02-09 08:35:01 +00:00
|
|
|
|
|
|
|
|
|
|
public class PanelGame : BasePanel
|
|
|
|
|
|
{
|
|
|
|
|
|
public Action<int[]> DelPlay;
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] Text mTxtTitle;
|
|
|
|
|
|
[SerializeField] Button mBtnLevel;
|
|
|
|
|
|
[SerializeField] Button mBtnMenu;
|
|
|
|
|
|
[SerializeField] ButtonEndings mBtnEndings;
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] ButtonSlot[] mBtnSlots;
|
|
|
|
|
|
[SerializeField] GameObject[] mGobArrows;
|
|
|
|
|
|
[SerializeField] ButtonSound[] mBtnSounds;
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] GameObject mGobPlay;
|
|
|
|
|
|
[SerializeField] Button mBtnPlay;
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] GameObject mGobPlayProgress;
|
|
|
|
|
|
[SerializeField] Image mImgPlayProgress;
|
|
|
|
|
|
|
2022-02-09 11:36:47 +00:00
|
|
|
|
[SerializeField] Animator mAtrAction;
|
|
|
|
|
|
[SerializeField] GameObject mGobOpMask;
|
|
|
|
|
|
|
2022-02-09 08:35:01 +00:00
|
|
|
|
private int mTotalSlot;
|
|
|
|
|
|
private int mCurSlotIndex;
|
|
|
|
|
|
private int[] mSoundOrder;
|
|
|
|
|
|
|
2022-02-09 11:36:47 +00:00
|
|
|
|
private PanelGameAni mAni;
|
|
|
|
|
|
|
2022-02-09 08:35:01 +00:00
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
UIUtils.BindBtn(mBtnLevel, OnClickLevel);
|
|
|
|
|
|
UIUtils.BindBtn(mBtnMenu, OnClickMenu);
|
|
|
|
|
|
UIUtils.BindBtn(mBtnPlay, OnClickPlay);
|
|
|
|
|
|
|
|
|
|
|
|
mBtnEndings.DelClick = OnClickEndings;
|
2022-02-09 11:36:47 +00:00
|
|
|
|
|
|
|
|
|
|
mAni = GetComponent<PanelGameAni>();
|
2022-02-09 08:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
LevelData tLvData = GameConfig.Instance.GetLevelData(PlayerData.Instance.CurrentLevelID);
|
|
|
|
|
|
|
|
|
|
|
|
mTxtTitle.text = tLvData.LevelName;
|
2022-02-09 12:07:40 +00:00
|
|
|
|
mBtnEndings.Init(PlayerData.Instance.CurrentLevelID, PlayerData.Instance.EndingCountOfLevel(PlayerData.Instance.CurrentLevelID), tLvData.Endings.Count);
|
2022-02-09 08:35:01 +00:00
|
|
|
|
|
|
|
|
|
|
mTotalSlot = tLvData.SlotCount;
|
|
|
|
|
|
mCurSlotIndex = 0;
|
|
|
|
|
|
mSoundOrder = new int[mTotalSlot];
|
|
|
|
|
|
for (int i = 0; i < mSoundOrder.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
mSoundOrder[i] = -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mBtnSlots.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
mBtnSlots[i].gameObject.SetActive(i < mTotalSlot);
|
|
|
|
|
|
mBtnSlots[i].Init(i);
|
|
|
|
|
|
mBtnSlots[i].ShowCurrent(i == mCurSlotIndex);
|
|
|
|
|
|
mBtnSlots[i].DelClick = OnClickSlot;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mGobArrows.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
mGobArrows[i].SetActive(i < mTotalSlot - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < mBtnSounds.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
mBtnSounds[i].Init(i);
|
|
|
|
|
|
mBtnSounds[i].SetSoundPic(ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetSoundPic(PlayerData.Instance.CurrentLevelID, i)));
|
|
|
|
|
|
mBtnSounds[i].DelClick = OnClickSound;
|
|
|
|
|
|
}
|
2022-02-09 11:36:47 +00:00
|
|
|
|
|
|
|
|
|
|
mGobPlay.SetActive(false);
|
|
|
|
|
|
mGobPlayProgress.SetActive(false);
|
|
|
|
|
|
mAtrAction.gameObject.SetActive(false);
|
|
|
|
|
|
mGobOpMask.SetActive(false);
|
|
|
|
|
|
|
|
|
|
|
|
mAni.Init();
|
2022-02-09 08:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickLevel()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickMenu()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickEndings()
|
|
|
|
|
|
{
|
2022-02-10 04:26:52 +00:00
|
|
|
|
PanelEndings tUIEndings = UIManager.Instance.OpenUI<PanelEndings>();
|
|
|
|
|
|
tUIEndings.Init(PlayerData.Instance.CurrentLevelID);
|
2022-02-09 08:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickPlay()
|
2022-02-09 11:36:47 +00:00
|
|
|
|
{
|
|
|
|
|
|
mGobPlay.SetActive(false);
|
|
|
|
|
|
mGobOpMask.SetActive(true);
|
2022-02-09 12:28:20 +00:00
|
|
|
|
for (int i = 0; i < mBtnSlots.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
mBtnSlots[i].ShowCurrent(false);
|
|
|
|
|
|
}
|
2022-02-09 11:36:47 +00:00
|
|
|
|
|
|
|
|
|
|
mAni.ReadyPlay(0.5f);
|
|
|
|
|
|
TimerManager.Instance.Schedule(Action, 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Action()
|
|
|
|
|
|
{
|
|
|
|
|
|
mAtrAction.gameObject.SetActive(true);
|
|
|
|
|
|
mAtrAction.Play("Action");
|
|
|
|
|
|
|
|
|
|
|
|
TimerManager.Instance.Schedule(StartPlay, 1.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void StartPlay()
|
2022-02-09 08:35:01 +00:00
|
|
|
|
{
|
|
|
|
|
|
DelPlay?.Invoke(mSoundOrder);
|
|
|
|
|
|
|
2022-02-09 11:36:47 +00:00
|
|
|
|
mGobPlayProgress.SetActive(true);
|
|
|
|
|
|
mImgPlayProgress.fillAmount = 0;
|
|
|
|
|
|
mImgPlayProgress.DOFillAmount(1, mSoundOrder.Length * 1.5f).SetEase(Ease.Linear);
|
2022-02-09 08:35:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickSlot(int pIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
mCurSlotIndex = pIndex;
|
|
|
|
|
|
for (int i = 0; i < mBtnSlots.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
mBtnSlots[i].ShowCurrent(i == mCurSlotIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickSound(int pIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
mSoundOrder[mCurSlotIndex] = pIndex;
|
|
|
|
|
|
mBtnSlots[mCurSlotIndex].SetSoundPic(ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetSoundPic(PlayerData.Instance.CurrentLevelID, pIndex)));
|
|
|
|
|
|
if (mCurSlotIndex < mTotalSlot - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
OnClickSlot(mCurSlotIndex + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AudioManager.Instance.PlaySound(ResourceManager.Instance.LoadRes<AudioClip>(Const.Path.GetSound(PlayerData.Instance.CurrentLevelID, pIndex)));
|
|
|
|
|
|
|
|
|
|
|
|
CheckOrder();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CheckOrder()
|
|
|
|
|
|
{
|
|
|
|
|
|
bool tAllSet = true;
|
|
|
|
|
|
for (int i = 0; i < mSoundOrder.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mSoundOrder[i] < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
tAllSet = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mGobPlay.SetActive(tAllSet);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|