코드 정리
This commit is contained in:
@@ -121,7 +121,6 @@ namespace TON
|
|||||||
// duration 동안에는 항상 idle = 공격 쿨타운
|
// duration 동안에는 항상 idle = 공격 쿨타운
|
||||||
if (_currentDuration < _duration)
|
if (_currentDuration < _duration)
|
||||||
return this;
|
return this;
|
||||||
// TODO : 데미지 받을 때
|
|
||||||
|
|
||||||
// 추적 범위에 들어왔을 때
|
// 추적 범위에 들어왔을 때
|
||||||
if (_monsterBase.IsDetect)
|
if (_monsterBase.IsDetect)
|
||||||
@@ -186,7 +185,6 @@ namespace TON
|
|||||||
{
|
{
|
||||||
_monsterBase = monsterBase;
|
_monsterBase = monsterBase;
|
||||||
_monsterBase.IsFinishAttack = false;
|
_monsterBase.IsFinishAttack = false;
|
||||||
|
|
||||||
_lastAttackTime = -_attackDelayTime; // 처음 진입시 바로 공격하도록 설정
|
_lastAttackTime = -_attackDelayTime; // 처음 진입시 바로 공격하도록 설정
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace TON
|
namespace TON
|
||||||
@@ -20,11 +16,8 @@ namespace TON
|
|||||||
|
|
||||||
private PlayerDataManager playerDataManager;
|
private PlayerDataManager playerDataManager;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
InitPopUpActive();
|
|
||||||
|
|
||||||
// 싱글톤으로 PlayerDataManager 접근
|
// 싱글톤으로 PlayerDataManager 접근
|
||||||
playerDataManager = PlayerDataManager.Singleton;
|
playerDataManager = PlayerDataManager.Singleton;
|
||||||
|
|
||||||
@@ -34,189 +27,65 @@ namespace TON
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPopUpActive()
|
|
||||||
{
|
|
||||||
HeartPopUp.SetActive(false);
|
|
||||||
PositionPopUp.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void OnClickLobbyButton()
|
public void OnClickLobbyButton()
|
||||||
{
|
{
|
||||||
Main.Singleton.ChangeScene(SceneType.Lobby);
|
Main.Singleton.ChangeScene(SceneType.Lobby);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClickHeartPopUpButton()
|
// 포션 구매 메서드
|
||||||
|
private void BuyPotion(int price, string potionType, int quantity)
|
||||||
{
|
{
|
||||||
HeartPopUp.SetActive(true);
|
if (playerDataManager.goldAmount >= price)
|
||||||
}
|
|
||||||
|
|
||||||
public void OnClickHeartCloseButton()
|
|
||||||
{
|
|
||||||
HeartPopUp.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnClickPositionPopUpButton()
|
|
||||||
{
|
|
||||||
PositionPopUp.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnClickPositionCloseButton()
|
|
||||||
{
|
|
||||||
PositionPopUp.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnClickBuyHpPotion1Button()
|
|
||||||
{
|
|
||||||
if (playerDataManager.goldAmount >= hpPotionPrice1)
|
|
||||||
{
|
{
|
||||||
playerDataManager.UseGold(hpPotionPrice1, (isSuccess) =>
|
playerDataManager.UseGold(price, (isSuccess) =>
|
||||||
{
|
{
|
||||||
if (isSuccess)
|
if (isSuccess)
|
||||||
{
|
{
|
||||||
playerDataManager.userItem.hpPotion += 1;
|
if (potionType == "hp")
|
||||||
Debug.Log($"HP 포션 구매 성공! 남은 골드: {playerDataManager.goldAmount}, HP 포션 수량: {playerDataManager.userItem.hpPotion}");
|
{
|
||||||
|
playerDataManager.userItem.hpPotion += quantity;
|
||||||
|
}
|
||||||
|
else if (potionType == "mp")
|
||||||
|
{
|
||||||
|
playerDataManager.userItem.mpPotion += quantity;
|
||||||
|
}
|
||||||
|
|
||||||
UIManager.Singleton.UpdateCashData();
|
UIManager.Singleton.UpdateCashData();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족하여 HP 포션 구매 실패!");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족합니다!");
|
// HP 포션 구매 버튼 클릭 시 호출
|
||||||
}
|
public void OnClickBuyHpPotion1Button()
|
||||||
|
{
|
||||||
|
BuyPotion(hpPotionPrice1, "hp", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClickBuyHpPotion5Button()
|
public void OnClickBuyHpPotion5Button()
|
||||||
{
|
{
|
||||||
if (playerDataManager.goldAmount >= hpPotionPrice5)
|
BuyPotion(hpPotionPrice5, "hp", 5);
|
||||||
{
|
|
||||||
playerDataManager.UseGold(hpPotionPrice5, (isSuccess) =>
|
|
||||||
{
|
|
||||||
if (isSuccess)
|
|
||||||
{
|
|
||||||
playerDataManager.userItem.hpPotion += 5;
|
|
||||||
Debug.Log($"HP 포션 구매 성공! 남은 골드: {playerDataManager.goldAmount}, HP 포션 수량: {playerDataManager.userItem.hpPotion}");
|
|
||||||
UIManager.Singleton.UpdateCashData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족하여 HP 포션 구매 실패!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족합니다!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClickBuyHpPotion20Button()
|
public void OnClickBuyHpPotion20Button()
|
||||||
{
|
{
|
||||||
if (playerDataManager.goldAmount >= hpPotionPrice20)
|
BuyPotion(hpPotionPrice20, "hp", 20);
|
||||||
{
|
|
||||||
playerDataManager.UseGold(hpPotionPrice20, (isSuccess) =>
|
|
||||||
{
|
|
||||||
if (isSuccess)
|
|
||||||
{
|
|
||||||
playerDataManager.userItem.hpPotion += 20;
|
|
||||||
Debug.Log($"HP 포션 구매 성공! 남은 골드: {playerDataManager.goldAmount}, HP 포션 수량: {playerDataManager.userItem.hpPotion}");
|
|
||||||
UIManager.Singleton.UpdateCashData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족하여 HP 포션 구매 실패!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족합니다!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MP 포션 구매 버튼 클릭 시 호출
|
// MP 포션 구매 버튼 클릭 시 호출
|
||||||
public void OnClickBuyMpPotion1Button()
|
public void OnClickBuyMpPotion1Button()
|
||||||
{
|
{
|
||||||
if (playerDataManager.goldAmount >= mpPotionPrice1)
|
BuyPotion(mpPotionPrice1, "mp", 1);
|
||||||
{
|
|
||||||
playerDataManager.UseGold(mpPotionPrice1, (isSuccess) =>
|
|
||||||
{
|
|
||||||
if (isSuccess)
|
|
||||||
{
|
|
||||||
playerDataManager.userItem.mpPotion += 1;
|
|
||||||
Debug.Log($"MP 포션 구매 성공! 남은 골드: {playerDataManager.goldAmount}, MP 포션 수량: {playerDataManager.userItem.mpPotion}");
|
|
||||||
UIManager.Singleton.UpdateCashData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족하여 MP 포션 구매 실패!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족합니다!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MP 포션 구매 버튼 클릭 시 호출
|
|
||||||
public void OnClickBuyMpPotion5Button()
|
public void OnClickBuyMpPotion5Button()
|
||||||
{
|
{
|
||||||
if (playerDataManager.goldAmount >= mpPotionPrice5)
|
BuyPotion(mpPotionPrice5, "mp", 5);
|
||||||
{
|
|
||||||
playerDataManager.UseGold(mpPotionPrice5, (isSuccess) =>
|
|
||||||
{
|
|
||||||
if (isSuccess)
|
|
||||||
{
|
|
||||||
playerDataManager.userItem.mpPotion += 5;
|
|
||||||
Debug.Log($"MP 포션 구매 성공! 남은 골드: {playerDataManager.goldAmount}, MP 포션 수량: {playerDataManager.userItem.mpPotion}");
|
|
||||||
UIManager.Singleton.UpdateCashData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족하여 MP 포션 구매 실패!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족합니다!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MP 포션 구매 버튼 클릭 시 호출
|
|
||||||
public void OnClickBuyMpPotion20Button()
|
public void OnClickBuyMpPotion20Button()
|
||||||
{
|
{
|
||||||
if (playerDataManager.goldAmount >= mpPotionPrice20)
|
BuyPotion(mpPotionPrice20, "mp", 20);
|
||||||
{
|
|
||||||
playerDataManager.UseGold(mpPotionPrice20, (isSuccess) =>
|
|
||||||
{
|
|
||||||
if (isSuccess)
|
|
||||||
{
|
|
||||||
playerDataManager.userItem.mpPotion += 20;
|
|
||||||
Debug.Log($"MP 포션 구매 성공! 남은 골드: {playerDataManager.goldAmount}, MP 포션 수량: {playerDataManager.userItem.mpPotion}");
|
|
||||||
UIManager.Singleton.UpdateCashData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족하여 MP 포션 구매 실패!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("골드가 부족합니다!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user