2022-05-23 13:39:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class PanelTopBar : BasePanel
|
|
|
|
|
|
{
|
2022-07-04 11:17:39 +00:00
|
|
|
|
public Action DelDiamondRefresh;
|
2022-05-23 13:39:59 +00:00
|
|
|
|
public Action DelCoinRefresh;
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
[SerializeField] RectTransform mRctDiamond;
|
|
|
|
|
|
[SerializeField] RectTransform mRctCoin;
|
|
|
|
|
|
[SerializeField] ResShower mDiamondShower;
|
|
|
|
|
|
[SerializeField] ResShower mCoinShower;
|
2022-05-23 13:39:59 +00:00
|
|
|
|
[SerializeField] GameObject mGobBP;
|
|
|
|
|
|
[SerializeField] Text mTxtPlayerBP;
|
|
|
|
|
|
[SerializeField] Text mTxtEnemyBP;
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnOpen()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnOpen();
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
mCoinShower.DelResRefresh = NotifyCoinRefresh;
|
|
|
|
|
|
mCoinShower.Init();
|
2022-05-23 13:39:59 +00:00
|
|
|
|
RefreshCoin();
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
mRctDiamond.anchoredPosition = new Vector2(-(mRctCoin.sizeDelta.x + 55), mRctDiamond.anchoredPosition.y);
|
|
|
|
|
|
mDiamondShower.DelResRefresh = NotifyDiamondRefresh;
|
|
|
|
|
|
mDiamondShower.Init();
|
|
|
|
|
|
RefreshDiamond();
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
ShowBP(GameConfig.Instance.IsDebug);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
public void FlyDiamond(Vector3 pPos, int pAdd)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pAdd > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
mDiamondShower.FlyRes(pPos, Mathf.Clamp(pAdd, 1, 20), pAdd, PlayerData.Instance.Diamond);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void PopDiamond(int pDelta)
|
|
|
|
|
|
{
|
|
|
|
|
|
mDiamondShower.PopResChange(pDelta);
|
|
|
|
|
|
RefreshDiamond();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RefreshDiamond()
|
|
|
|
|
|
{
|
|
|
|
|
|
mDiamondShower.RefreshRes(PlayerData.Instance.Diamond);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
public void FlyCoin(Vector3 pPos, int pAdd)
|
|
|
|
|
|
{
|
2022-07-04 11:17:39 +00:00
|
|
|
|
if (pAdd > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
mCoinShower.FlyRes(pPos, Mathf.Clamp(pAdd / 50, 3, 20), pAdd, PlayerData.Instance.Coin);
|
|
|
|
|
|
}
|
2022-05-23 13:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void PopCoin(int pDelta)
|
|
|
|
|
|
{
|
2022-07-04 11:17:39 +00:00
|
|
|
|
mCoinShower.PopResChange(pDelta);
|
2022-05-23 13:39:59 +00:00
|
|
|
|
RefreshCoin();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RefreshCoin()
|
|
|
|
|
|
{
|
2022-07-04 11:17:39 +00:00
|
|
|
|
mCoinShower.RefreshRes(PlayerData.Instance.Coin);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void NotifyDiamondRefresh()
|
|
|
|
|
|
{
|
|
|
|
|
|
DelDiamondRefresh?.Invoke();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void NotifyCoinRefresh()
|
|
|
|
|
|
{
|
|
|
|
|
|
DelCoinRefresh?.Invoke();
|
2022-05-23 13:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowBP(bool pShow)
|
|
|
|
|
|
{
|
|
|
|
|
|
mGobBP.SetActive(pShow);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetPlayerBP(int pPlayerBP)
|
|
|
|
|
|
{
|
|
|
|
|
|
mTxtPlayerBP.text = "Player:" + pPlayerBP.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetEnemyBP(int pEnemyBP)
|
|
|
|
|
|
{
|
|
|
|
|
|
mTxtEnemyBP.text = "Enemy:" + pEnemyBP.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|