You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
421 lines
15 KiB
421 lines
15 KiB
using IVDataFormat;
|
|
using IVServerFormat;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MissionMgr : MonoBehaviour
|
|
{
|
|
#region Const
|
|
private static MissionMgr curMgr = null;
|
|
#endregion
|
|
|
|
#region UI
|
|
[SerializeField]
|
|
private Canvas canvasUi;
|
|
private TextMeshProUGUI txtCond;
|
|
private TextMeshProUGUI txtClearRate;
|
|
private GoodsItem goods;
|
|
Button btnBubble, btnBubbleClear;
|
|
TextMeshProUGUI txtBubble;
|
|
private RectTransform badge;
|
|
TextMeshProUGUI txtBadge;
|
|
private RectTransform inpanel,allClear;
|
|
TextMeshProUGUI txtComplete;
|
|
private TextMeshProUGUI txtTitle;
|
|
private TextMeshProUGUI txtDesc;
|
|
private Button btnMainPanel;
|
|
Button btnOpenPanel;
|
|
RectTransform rectMainPanel;
|
|
private RectTransform imgArrow;
|
|
private RectTransform imgArrowRev;
|
|
private Animator MainPanelEffect;
|
|
private ParticleSystem ptcClear;
|
|
|
|
Slider missionProgress;
|
|
#endregion
|
|
|
|
#region Values
|
|
private nAchivement achive;
|
|
private int itemId;
|
|
private bool isClear = false;
|
|
private bool ReLocalize = true;
|
|
private bool isInit = false;
|
|
#endregion
|
|
|
|
#region Const
|
|
private void Awake()
|
|
{
|
|
curMgr = this;
|
|
}
|
|
#endregion
|
|
|
|
#region init
|
|
public static void SLocalize()
|
|
{
|
|
if (curMgr != null)
|
|
curMgr.Localize();
|
|
}
|
|
|
|
public static void SReLocalize()
|
|
{
|
|
curMgr.ReLocalize = true;
|
|
curMgr.Localize();
|
|
}
|
|
|
|
private void Localize()
|
|
{
|
|
if (ReLocalize)
|
|
{
|
|
isInit = true;
|
|
btnMainPanel = canvasUi.transform.Find("MainPanel").GetComponent<Button>();
|
|
btnOpenPanel = canvasUi.transform.Find("btnOpen").GetComponent<Button>();
|
|
rectMainPanel = canvasUi.transform.Find("MainPanel").GetComponent<RectTransform>();
|
|
txtCond = btnMainPanel.transform.Find("txtCond").GetComponent<TextMeshProUGUI>();
|
|
txtClearRate = btnMainPanel.transform.Find("txtClearRate").GetComponent<TextMeshProUGUI>();
|
|
goods = canvasUi.transform.Find("GoodsItem").GetComponent<GoodsItem>();
|
|
btnBubble = btnMainPanel.transform.Find("imgBubble").GetComponent<Button>();
|
|
txtBubble = btnBubble.transform.Find("txtGo").GetComponent<TextMeshProUGUI>();
|
|
txtBubble.text = LocalizationText.GetText("mission_go");
|
|
btnBubbleClear = btnMainPanel.transform.Find("imgBubbleCom").GetComponent<Button>();
|
|
txtBadge = btnBubbleClear.transform.Find("txtReward").GetComponent<TextMeshProUGUI>();
|
|
txtBadge.text = LocalizationText.GetText("mission_clear");
|
|
imgArrow = btnMainPanel.transform.Find("imgArrow").GetComponent<RectTransform>();
|
|
imgArrowRev = btnMainPanel.transform.Find("imgArrowRev").GetComponent<RectTransform>();
|
|
allClear = btnMainPanel.transform.Find("AllClear").GetComponent<RectTransform>();
|
|
txtComplete = canvasUi.transform.Find("txtComp").GetComponent<TextMeshProUGUI>();
|
|
txtComplete.text = LocalizationText.GetText("all_comp");
|
|
txtTitle = allClear.transform.Find("txtTitle").GetComponent<TextMeshProUGUI>();
|
|
txtDesc = allClear.transform.Find("txtDesc").GetComponent<TextMeshProUGUI>();
|
|
txtTitle.text = LocalizationText.GetText("mission_allclear_title");
|
|
txtDesc.text = LocalizationText.GetText("mission_allclear_desc");
|
|
MainPanelEffect = btnMainPanel.transform.Find("MainPanelEffect").GetComponent<Animator>();
|
|
ptcClear = canvasUi.transform.Find("ptcMissionClear").GetComponent<ParticleSystem>();
|
|
|
|
missionProgress = btnMainPanel.transform.Find("sldPanel").GetComponent<Slider>();
|
|
SRefreshMission();
|
|
ReLocalize = false;
|
|
}
|
|
}
|
|
|
|
private void SetData()
|
|
{
|
|
itemId = DataHandler.GetTotalRecord().missionLv;
|
|
dMission mission = DataHandler.GetQuestMission(itemId);
|
|
if(mission != null)
|
|
{
|
|
achive = new nAchivement(mission);
|
|
txtCond.text = FormatString.TextCondition(mission.condType, mission.condValue);
|
|
txtClearRate.text = FormatString.TextConditionRate(achive);
|
|
missionProgress.value = (DataHandler.GetAchievementValue(achive) > achive.condValue ? achive.condValue : DataHandler.GetAchievementValue(achive)) / (float)achive.condValue;
|
|
|
|
if (curMgr.missionProgress.value != 0 && curMgr.missionProgress.value < 0.1)
|
|
{
|
|
curMgr.missionProgress.value = 0.1f;
|
|
}
|
|
|
|
if (mission.condType == eCondition.StageClear)
|
|
{
|
|
missionProgress.value = DataHandler.isClearAchievements(achive);
|
|
}
|
|
goods.SetGoods(mission.rewards[0].rewardType, mission.rewards[0].rewardId, mission.rewards[0].rewardCount);
|
|
}
|
|
else
|
|
{
|
|
txtCond.gameObject.SetActive(false);
|
|
txtClearRate.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public static void SRefreshMission()
|
|
{
|
|
if (curMgr.isInit)
|
|
{
|
|
if (DataHandler.GetTotalRecord().missionLv <= DataHandler.GetAllQuestMission().Length && BattleMgr.Instance.CurrentBattleType == BattleMgr.BattleType.Stage)
|
|
{
|
|
curMgr.SetData();
|
|
checkCurMission();
|
|
curMgr.allClear.gameObject.SetActive(false);
|
|
curMgr.txtComplete.gameObject.SetActive(false);
|
|
curMgr.btnMainPanel.interactable = true;
|
|
}
|
|
else if (BattleMgr.Instance.CurrentBattleType == BattleMgr.BattleType.Stage)
|
|
{
|
|
curMgr.itemId = 0;
|
|
curMgr.allCloseUi();
|
|
curMgr.FoldOpenCloseUi(!curMgr.btnOpenPanel.gameObject.activeSelf);
|
|
curMgr.allClear.gameObject.SetActive(true);
|
|
curMgr.MainPanelEffect.gameObject.SetActive(false);
|
|
curMgr.ptcClear.gameObject.SetActive(false);
|
|
curMgr.btnBubbleClear.gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
curMgr.ptcClear.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void SCloseMission()
|
|
{
|
|
curMgr.canvasUi.enabled = false;
|
|
curMgr.MainPanelEffect.gameObject.SetActive(false);
|
|
}
|
|
|
|
public static void SOpenMission()
|
|
{
|
|
curMgr.canvasUi.enabled = true;
|
|
checkCurMission();
|
|
}
|
|
|
|
public void allCloseUi()
|
|
{
|
|
//inpanel.gameObject.SetActive(false);
|
|
missionProgress.gameObject.SetActive(false);
|
|
txtClearRate.gameObject.SetActive(false);
|
|
txtCond.gameObject.SetActive(false);
|
|
goods.gameObject.SetActive(false);
|
|
btnBubbleClear.gameObject.SetActive(false);
|
|
ptcClear.gameObject.SetActive(false);
|
|
//badge.gameObject.SetActive(false);
|
|
imgArrow.gameObject.SetActive(false);
|
|
btnMainPanel.interactable = false;
|
|
curMgr.MainPanelEffect.gameObject.SetActive(false);
|
|
curMgr.txtComplete.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void FoldOpenCloseUi(bool isActive)
|
|
{
|
|
dMission mission = DataHandler.GetQuestMission(itemId);
|
|
|
|
if (!isActive)
|
|
{
|
|
rectMainPanel.anchoredPosition = new Vector3(-260f, 0f, 0f);
|
|
}
|
|
else
|
|
{
|
|
rectMainPanel.anchoredPosition = new Vector3(0f, 0f, 0f);
|
|
}
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
////inpanel.gameObject.SetActive(false);
|
|
//missionProgress.gameObject.SetActive(isActive);
|
|
//txtClearRate.gameObject.SetActive(isActive);
|
|
//txtCond.gameObject.SetActive(isActive);
|
|
////goods.gameObject.SetActive(false);
|
|
//badge.gameObject.SetActive(isActive);
|
|
|
|
if (isClear && DataHandler.GetTotalRecord().missionLv <= DataHandler.GetAllQuestMission().Length)
|
|
{
|
|
if (isActive)
|
|
{
|
|
btnBubble.gameObject.SetActive(false);
|
|
btnBubbleClear.gameObject.SetActive(true);
|
|
ptcClear.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
btnBubble.gameObject.SetActive(false);
|
|
btnBubbleClear.gameObject.SetActive(false);
|
|
ptcClear.gameObject.SetActive(true);
|
|
}
|
|
|
|
//badge.gameObject.SetActive(isActive);
|
|
}
|
|
else
|
|
{
|
|
if (isActive)
|
|
{
|
|
btnBubble.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
btnBubble.gameObject.SetActive(false);
|
|
btnBubbleClear.gameObject.SetActive(false);
|
|
ptcClear.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
txtComplete.gameObject.SetActive(!isActive);
|
|
if (isActive)
|
|
{
|
|
if (DataHandler.GetQuestMission(curMgr.itemId) != null)
|
|
{
|
|
if (DataHandler.GetQuestMission(curMgr.itemId).moveType == 0)
|
|
{
|
|
if (!isClear)
|
|
{
|
|
btnBubble.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
btnBubble.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
if (DataHandler.GetQuestMission(curMgr.itemId) != null)
|
|
txtComplete.gameObject.SetActive(false);
|
|
|
|
btnMainPanel.interactable = isActive;
|
|
btnOpenPanel.gameObject.SetActive(!isActive);
|
|
imgArrow.gameObject.SetActive(isActive);
|
|
imgArrowRev.gameObject.SetActive(!isActive);
|
|
|
|
////btnMainPanel.interactable = isActive;
|
|
////curMgr.MainPanelEffect.gameObject.SetActive(isActive);
|
|
}
|
|
#endregion
|
|
|
|
#region server
|
|
private void AClearMissionSucc(object result, object request)
|
|
{
|
|
cQuestMissionReturn data = result as cQuestMissionReturn;
|
|
if(data == null)
|
|
{
|
|
AClearMissionFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
DataHandler.AddRecord(eCondition.MissionClearLv);
|
|
int rewardCnt = data.playCurrency.diaFree - DataHandler.Goods.diaFree;
|
|
dMission mission = DataHandler.GetQuestMission(itemId);
|
|
nGoods[] goods = new nGoods[1] { new nGoods { propertyType = mission.rewards[0].rewardType, propertyId = mission.rewards[0].rewardId, propertyCount = mission.rewards[0].rewardCount } };
|
|
DataHandler.AddGoods(goods,data.playCurrency, true);
|
|
GameUIMgr.SOpenPopupGoods(goods);
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress,SoundName.GetGoods);
|
|
FoldOpenCloseUi(true);
|
|
SRefreshMission();
|
|
CoverCamera.Release();
|
|
}
|
|
private void AClearMissionFail(SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
public void btnMission()
|
|
{
|
|
if (itemId > DataHandler.GetAllQuestMission().Length || itemId == 0)
|
|
return;
|
|
|
|
if (isClear)
|
|
{
|
|
if (DataHandler.IsNeedDataSave)
|
|
SingleMgr.SaveDataMission();
|
|
// ������ ������ �ʿ䰡 ���� ���� �ٷ� ��� ��� ����.
|
|
else
|
|
ClearMission();
|
|
}
|
|
|
|
else
|
|
{
|
|
MoveContent();
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
}
|
|
|
|
}
|
|
|
|
public static void SClearMission()
|
|
{
|
|
curMgr.ClearMission();
|
|
}
|
|
|
|
private void ClearMission()
|
|
{
|
|
CoverCamera.Hold();
|
|
dMission mission = DataHandler.GetQuestMission(curMgr.itemId);
|
|
curMgr.achive = new nAchivement(mission);
|
|
|
|
if (DataHandler.isClearAchievements(curMgr.achive) > 0)
|
|
{
|
|
nIdCnt nid = new nIdCnt();
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.QuestMission), typeof(cQuestMissionReturn), AClearMissionSucc, AClearMissionFail, nid, false);
|
|
}
|
|
else
|
|
{
|
|
CoverCamera.Release();
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
public static void SSetMissionMonCnt()
|
|
{
|
|
curMgr.txtClearRate.text = FormatString.TextConditionRate(curMgr.achive);
|
|
curMgr.missionProgress.value = (float)(DataHandler.GetAchievementValue(curMgr.achive) > curMgr.achive.condValue ?
|
|
curMgr.achive.condValue : DataHandler.GetAchievementValue(curMgr.achive)) / (float)curMgr.achive.condValue;
|
|
|
|
if(curMgr.missionProgress.value!=0&& curMgr.missionProgress.value < 0.1)
|
|
{
|
|
curMgr.missionProgress.value = 0.1f;
|
|
}
|
|
}
|
|
|
|
private void MoveContent()
|
|
{
|
|
if (DataHandler.GetQuestMission(itemId) != null)
|
|
{
|
|
SingleMgr.MoveContent(DataHandler.GetQuestMission(itemId).moveType);
|
|
}
|
|
}
|
|
|
|
public static void checkCurMission()
|
|
{
|
|
dMission mission = DataHandler.GetQuestMission(curMgr.itemId);
|
|
if(mission != null)
|
|
{
|
|
curMgr.achive = new nAchivement(mission);
|
|
// Ŭ���� ������
|
|
if (DataHandler.isClearAchievements(curMgr.achive) > 0 && DataHandler.GetTotalRecord().missionLv <= DataHandler.GetAllQuestMission().Length)
|
|
{
|
|
curMgr.isClear = true;
|
|
// ������ ���¸�
|
|
if (!curMgr.btnOpenPanel.gameObject.activeSelf)
|
|
{
|
|
//curMgr.btnBubble.gameObject.SetActive(true);
|
|
curMgr.btnBubble.gameObject.SetActive(false);
|
|
curMgr.btnBubbleClear.gameObject.SetActive(true);
|
|
curMgr.ptcClear.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
curMgr.btnBubbleClear.gameObject.SetActive(false);
|
|
curMgr.ptcClear.gameObject.SetActive(true);
|
|
curMgr.btnBubble.gameObject.SetActive(false);
|
|
}
|
|
curMgr.MainPanelEffect.gameObject.SetActive(true);
|
|
}
|
|
// Ŭ���� ��������
|
|
else
|
|
{
|
|
curMgr.isClear = false;
|
|
if (!curMgr.btnOpenPanel.gameObject.activeSelf)
|
|
{
|
|
curMgr.btnBubble.gameObject.SetActive(true);
|
|
curMgr.btnBubbleClear.gameObject.SetActive(false);
|
|
curMgr.ptcClear.gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
curMgr.btnBubble.gameObject.SetActive(false);
|
|
curMgr.btnBubbleClear.gameObject.SetActive(false);
|
|
curMgr.ptcClear.gameObject.SetActive(false);
|
|
}
|
|
|
|
if (mission.moveType == 0)
|
|
{
|
|
curMgr.btnBubble.gameObject.SetActive(false);
|
|
|
|
}
|
|
//curMgr.btnBubble.gameObject.SetActive(false);
|
|
//curMgr.MainPanelEffect.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|