162 lines
4.4 KiB
C#
162 lines
4.4 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using BansheeGz.BGDatabase;
|
||
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
public class HuntingButton : MonoBehaviour
|
||
|
|
{
|
||
|
|
/*[SerializeField]
|
||
|
|
TextMeshProUGUI needHeartText;
|
||
|
|
|
||
|
|
[SerializeField]
|
||
|
|
Image huntingImage;
|
||
|
|
|
||
|
|
[SerializeField]
|
||
|
|
Image lockIcon;
|
||
|
|
|
||
|
|
[SerializeField]
|
||
|
|
GameObject needHeartUI;
|
||
|
|
|
||
|
|
[SerializeField]
|
||
|
|
string notOrderWarringMessagePopupTitleGUIID;
|
||
|
|
[SerializeField]
|
||
|
|
string notOrderWarringMessagePopupTextGUIID;
|
||
|
|
|
||
|
|
private BGId hutnigDataId;
|
||
|
|
private BGId hutnigDataListId;
|
||
|
|
DB_HuntingData huntingData;
|
||
|
|
|
||
|
|
private Sprite unlockImage = null;
|
||
|
|
private bool isLockState;
|
||
|
|
|
||
|
|
public BGId GetHutnigDataListId()
|
||
|
|
{
|
||
|
|
return hutnigDataListId;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void Start()
|
||
|
|
{
|
||
|
|
if (needHeartText == null || huntingImage == null || lockIcon == null)
|
||
|
|
{
|
||
|
|
//Logging.LogError("huntingImage is not ready");
|
||
|
|
}
|
||
|
|
|
||
|
|
needHeartText.text = gameState.GetPostionCountOfHuntingDataById(hutnigDataId).ToString();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnButtonClick()
|
||
|
|
{
|
||
|
|
base.OnButtonClick();
|
||
|
|
|
||
|
|
// 포션 갯수 확인 후 언락 해제하기
|
||
|
|
OutGamePlayerController playerController = GameInstance.Instance.GameMode.PlayerController as OutGamePlayerController;
|
||
|
|
if (isLockState)
|
||
|
|
{
|
||
|
|
if (gameState != null && gameState.GetNextLockHuntingDataID() == hutnigDataId)
|
||
|
|
{
|
||
|
|
if (DataManager.Instance.GetPheromoneCount() - huntingData.DBF_Potion >= 0)
|
||
|
|
{
|
||
|
|
UnlockHuntingImg();
|
||
|
|
DataManager.Instance.AddUnlockHuntingCount(1);
|
||
|
|
|
||
|
|
DataManager.Instance.MinPheromoneCount(huntingData.DBF_Potion);
|
||
|
|
|
||
|
|
playerController.ShowHuntingScript(hutnigDataId, hutnigDataListId);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
playerController.OpenPopup<NeedHeartPopupSetting>();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
playerController.OpenMessagePopup(notOrderWarringMessagePopupTitleGUIID, notOrderWarringMessagePopupTextGUIID);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
playerController.ShowHuntingScript(hutnigDataId, hutnigDataListId);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void HuntingImgButtonStateByLockData(bool lockData)
|
||
|
|
{
|
||
|
|
if (lockData)
|
||
|
|
{
|
||
|
|
huntingImage.sprite = null;
|
||
|
|
huntingImage.color = new Color(Color.black.r, Color.black.g, Color.black.b, 220.0f);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if (unlockImage != null)
|
||
|
|
{
|
||
|
|
huntingImage.sprite = unlockImage;
|
||
|
|
}
|
||
|
|
huntingImage.color = Color.white;
|
||
|
|
}
|
||
|
|
|
||
|
|
gameState = GameInstance.Instance.GameMode.GameState as OutGameState;
|
||
|
|
bool isLastUnlockHuntingID = gameState.GetNextLockHuntingDataID() == hutnigDataId;
|
||
|
|
|
||
|
|
lockIcon.gameObject.SetActive(isLastUnlockHuntingID == false && lockData == true);
|
||
|
|
|
||
|
|
if (needHeartUI != null)
|
||
|
|
{
|
||
|
|
needHeartUI.SetActive(isLastUnlockHuntingID);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnEnable()
|
||
|
|
{
|
||
|
|
HuntingImgButtonStateByLockData(isLockState);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void InitHuntingImgButton(BGId id, BGId listID, bool isLock)
|
||
|
|
{
|
||
|
|
hutnigDataId = id;
|
||
|
|
hutnigDataListId = listID;
|
||
|
|
isLockState = isLock;
|
||
|
|
|
||
|
|
huntingData = DB_HuntingData.GetEntity(id);
|
||
|
|
|
||
|
|
if (huntingData != null)
|
||
|
|
{
|
||
|
|
if (DataBaseManager.Instance.LoadUnlockHuntingImageHandle[huntingData.GetDBF_UnlockListImageAddressablesAddress()].Status == AsyncOperationStatus.Succeeded)
|
||
|
|
{
|
||
|
|
unlockImage = DataBaseManager.Instance.LoadUnlockHuntingImageHandle[huntingData.GetDBF_UnlockListImageAddressablesAddress()].Result;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
HuntingImgButtonStateByLockData(isLockState);
|
||
|
|
|
||
|
|
if (needHeartUI != null)
|
||
|
|
{
|
||
|
|
// 나중에 언락 데이터에 따라 바뀐다.
|
||
|
|
//needHeartUI.SetActive(IsLatestUnlockHuntingImg(id.ToString()));
|
||
|
|
//needHeartUI.SetActive(isLock);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void UnlockHuntingImg()
|
||
|
|
{
|
||
|
|
if (isLockState)
|
||
|
|
{
|
||
|
|
isLockState = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
HuntingImgButtonStateByLockData(isLockState);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void LockHuntingImg()
|
||
|
|
{
|
||
|
|
if (!isLockState)
|
||
|
|
{
|
||
|
|
isLockState = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
HuntingImgButtonStateByLockData(isLockState);
|
||
|
|
}*/
|
||
|
|
}
|