159 lines
5.6 KiB
C#
159 lines
5.6 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using System;
|
|
|
|
public class LiveItemCollectLogic : UIControllerBase<LiveItemCollectLogic>
|
|
{
|
|
void OnEnable()
|
|
{
|
|
SetInstance(this);
|
|
InitShowItem();
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
SetInstance(null);
|
|
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
UIManager.CloseUI(UIInfo.LiveItemCollectNum);
|
|
}
|
|
|
|
public void InitShowItem()
|
|
{
|
|
if (LiveSkillLogic.Instance().SelectedLiveItem.SceneID > 0)
|
|
{
|
|
InitCollect();
|
|
}
|
|
else
|
|
{
|
|
InitMake();
|
|
}
|
|
}
|
|
|
|
public void BtnOk()
|
|
{
|
|
if (LiveSkillLogic.Instance().SelectedLiveItem.SceneID <= 0)
|
|
{
|
|
int materialCnt = 0;
|
|
if (LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(1) > 0)
|
|
{
|
|
materialCnt = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(1)) / LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(1);
|
|
}
|
|
if (materialCnt == 0)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{4760}"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
int num = 0;
|
|
if (_CollectPanel.activeSelf)
|
|
{
|
|
num = _NumInput.Value;
|
|
}
|
|
else
|
|
{
|
|
num = _MakeNumInput.Value;
|
|
}
|
|
GameManager.gameManager.LiveSkill.StartLiveCollect(LiveSkillLogic.Instance().SelectedLiveItem, LiveSkillLogic.Instance().SelectedLivingSkill, num);
|
|
|
|
CloseWindow();
|
|
if (_CollectPanel.activeSelf)
|
|
{
|
|
UIManager.CloseUI(UIInfo.SkillInfo);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#region collect
|
|
|
|
public GameObject _CollectPanel;
|
|
public GameObject _MakePanel;
|
|
public Text _CostValue;
|
|
public Text _OwnValue;
|
|
//public Image _ItemIcon;
|
|
public LiveSkillExItem _SkillItem;
|
|
public UINumBoardInput _NumInput;
|
|
public Text _BtnText;
|
|
public Text _GroupNum;
|
|
|
|
private void InitCollect()
|
|
{
|
|
_CollectPanel.SetActive(true);
|
|
_MakePanel.SetActive(false);
|
|
_SkillItem.UpdateLiveItem(LiveSkillLogic.Instance().SelectedLiveItem.Id);
|
|
_BtnText.text = LiveSkillLogic.Instance().SelectedLivingSkill.SkillName.Replace(StrDictionary.GetClientDictionaryString("#{4476}"), "");
|
|
InitCost();
|
|
_GroupNum.text = "";
|
|
}
|
|
|
|
private void InitCost()
|
|
{
|
|
int ownValue = GameManager.gameManager.PlayerDataPool.GetIntPropty(LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeTypebyIndex(0), LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(0));
|
|
int singleValue = LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(0);
|
|
int maxCnt = ownValue / singleValue;
|
|
_NumInput.Init(1, 1, ownValue / singleValue);
|
|
_CostValue.text = (LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(0) * 1).ToString();
|
|
_OwnValue.text = ownValue.ToString();
|
|
}
|
|
|
|
public void CollectNumModify()
|
|
{
|
|
int value = LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(0) * _NumInput.Value;
|
|
_CostValue.text = value.ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region make
|
|
|
|
public LiveSkillExItem _MakeItem;
|
|
public UINumBoardInput _MakeNumInput;
|
|
public LiveSkillMaterialItem _LiveItemMaterial;
|
|
|
|
private void InitMake()
|
|
{
|
|
_CollectPanel.SetActive(false);
|
|
_MakePanel.SetActive(true);
|
|
_MakeItem.UpdateLiveItem(LiveSkillLogic.Instance().SelectedLiveItem.Id);
|
|
_BtnText.text = LiveSkillLogic.Instance().SelectedLivingSkill.SkillName.Replace(StrDictionary.GetClientDictionaryString("#{4476}"), "");
|
|
InitMakeCost();
|
|
_GroupNum.text = StrDictionary.GetClientDictionaryString("#{4759}", LiveSkillLogic.Instance().SelectedLiveItem.GetProductItemIDNumbyIndex(0));
|
|
}
|
|
|
|
private void InitMakeCost()
|
|
{
|
|
int ownValue = GameManager.gameManager.PlayerDataPool.GetIntPropty(LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeTypebyIndex(0), LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(0));
|
|
int singleValue = LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(0);
|
|
int valueCnt = ownValue / singleValue;
|
|
int materialCnt = valueCnt;
|
|
if(LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(1) > 0)
|
|
{
|
|
materialCnt = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(1)) / LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(1);
|
|
}
|
|
|
|
int maxCnt = Math.Min(materialCnt, valueCnt);
|
|
_MakeNumInput.Init(maxCnt, 0, Math.Min(materialCnt, valueCnt));
|
|
_CostValue.text = (LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(0) * maxCnt).ToString();
|
|
_OwnValue.text = ownValue.ToString();
|
|
_LiveItemMaterial.InitMaterial(LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(1), LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(1));
|
|
}
|
|
|
|
public void MakeNumModify()
|
|
{
|
|
int value = LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(0) * _MakeNumInput.Value;
|
|
_CostValue.text = value.ToString();
|
|
_LiveItemMaterial.InitMaterial(LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeSubTypebyIndex(1), LiveSkillLogic.Instance().SelectedLiveItem.GetConsumeNumbyIndex(1) * _MakeNumInput.Value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|