using UnityEngine;
|
using UnityEngine.UI;
|
using TableConfig;
|
using System.Collections.Generic;
|
using System.Collections;
|
using System;
|
using UnityEngine.Events;
|
using Snxxz.UI;
|
|
namespace Snxxz.UI
|
{
|
public class TreasureRefineTips : MonoBehaviour
|
{
|
[SerializeField]
|
private ScrollerController _danDrugCtrl;
|
|
[SerializeField]
|
private ScrollerController _treasureEffectCtrl;
|
|
[SerializeField]
|
private List<GameObject> _treasureAttrlist = new List<GameObject>();
|
|
[SerializeField]
|
private Image _refineMaterialIcon;
|
|
[SerializeField]
|
private Button _refineMaterialButton;
|
|
[SerializeField]
|
private Text _refineMaterialNumText;
|
|
[SerializeField]
|
private Button _chooseFireBtn;
|
|
[SerializeField]
|
private Text _furnaceLvText;
|
|
[SerializeField]
|
private Text _noEnoughLVText;
|
|
[SerializeField]
|
private Slider _successRateSlider;
|
|
[SerializeField]
|
private Text _successRateText;
|
|
[SerializeField]
|
private Text _allRefineLvText;
|
|
[SerializeField]
|
private Text _treasureNameText;
|
|
[SerializeField]
|
private Button _makeDanBtn;
|
|
[SerializeField]
|
private RawImage _treasureIcon;
|
|
[SerializeField]
|
private GameObject _refineMaterContent;
|
|
[SerializeField] FurnaceFireChooseWin ChooseWin;
|
|
private ToggleGroup _toggleGroup;
|
|
private int blastFurnaceLv = 1; //炼丹炉等级
|
private List<int> _collectedTreasurelist;
|
private Dictionary<int,TreasureSkillData> _treasureSkillDict;
|
private ItemConfig _chinItemModel;
|
private TreasureRefineConfig _treasureModel;
|
private int presentIndex = 0;
|
|
BlastFurnaceModel _furnaceModel;
|
BlastFurnaceModel FurnaceModel
|
{
|
get
|
{
|
return _furnaceModel ?? (_furnaceModel = ModelCenter.Instance.GetModel<BlastFurnaceModel>());
|
}
|
}
|
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
private void Awake()
|
{
|
_danDrugCtrl.OnRefreshCell += RefreshDandrugCell;
|
_treasureEffectCtrl.OnRefreshCell += RefreshTreasureEffectCell;
|
_toggleGroup = _danDrugCtrl.GetComponent<ToggleGroup>();
|
_chooseFireBtn.onClick.AddListener(OnClickChooseFire);
|
_makeDanBtn.onClick.AddListener(OnClickMakeDan);
|
|
playerPack.RefreshItemCountAct += RefreshItemCnt;
|
FurnaceModel.RefreshSuccessRateEvent += ChangeSuccessRate;
|
FurnaceModel.RefreshTreasureRefineEvent += CreateCell;
|
}
|
|
private void OnEnable()
|
{
|
_collectedTreasurelist =FurnaceModel.GetCollectedTreasureList();
|
if (_collectedTreasurelist.Count > 0)
|
presentIndex = _collectedTreasurelist[0];
|
|
_furnaceLvText.text = Language.Get("BlastFurnace101",FurnaceModel.StoveLV);
|
CreateCell();
|
}
|
private void RefreshItemCnt(PackType type, int index, int id)
|
{
|
CreateCell();
|
}
|
|
private void ChangeSuccessRate(float value)
|
{
|
int successRate = Mathf.RoundToInt((_treasureModel.SuccessRate + value) / 100);
|
if (successRate <= 100)
|
{
|
_successRateText.text = successRate + "%";
|
_successRateSlider.value = (_treasureModel.SuccessRate + value) / 10000;
|
}
|
else
|
{
|
_successRateText.text = 100 + "%";
|
_successRateSlider.value = 1;
|
}
|
|
}
|
|
private void CreateCell()
|
{
|
_danDrugCtrl.Refresh();
|
if(_collectedTreasurelist.Count > 0)
|
{
|
int i = 0;
|
int length = _collectedTreasurelist.Count;
|
for(i = 0; i < length; i++)
|
{
|
_danDrugCtrl.AddCell(ScrollerDataType.Header, _collectedTreasurelist[i]);
|
}
|
}
|
_danDrugCtrl.Restart();
|
}
|
|
private void RefreshDandrugCell(ScrollerDataType type, CellView cell)
|
{
|
//TreasureConfig treasureModel = Config.Instance.Get<TreasureConfig>(cell.index);
|
//Treasure treasure = null;
|
//FurnaceModel.sTreasureModel.TryGetTreasure(cell.index, out treasure);
|
//TreasureRefineConfig nextRefineModel = null;
|
|
//if (FurnaceModel.treasureRefineDict.ContainsKey((uint)cell.index))
|
//{
|
// nextRefineModel = TreasureRefineConfig.GetTreasureRefineModel(cell.index,FurnaceModel.treasureRefineDict[(uint)cell.index]+1);
|
// if(nextRefineModel == null)
|
// nextRefineModel = TreasureRefineConfig.GetTreasureRefineModel(cell.index,FurnaceModel.treasureRefineDict[(uint)cell.index]);
|
//}
|
//else
|
//{
|
// nextRefineModel = TreasureRefineConfig.GetTreasureRefineModel(cell.index,1);
|
//}
|
|
//if (treasureModel == null || treasure == null || nextRefineModel == null)
|
// return;
|
|
//DandrugCell dandrugCell = cell.GetComponent<DandrugCell>();
|
//if (dandrugCell == null)
|
// dandrugCell = cell.gameObject.AddComponent<DandrugCell>();
|
//dandrugCell.cellToggle.isOn = false;
|
//dandrugCell.cellToggle.group = _toggleGroup;
|
//dandrugCell.nameText.text = treasureModel.Name;
|
//dandrugCell.cellIcon.SetSprite(treasureModel.Icon);
|
//if(treasure.level > 0)
|
//{
|
// dandrugCell.treasureText.gameObject.SetActive(true);
|
// dandrugCell.treasureText.text = Language.Get("BlastFurnace105", treasure.level);
|
//}
|
//else
|
//{
|
// dandrugCell.treasureText.gameObject.SetActive(false);
|
//}
|
|
//if(FurnaceModel.StoveLV < nextRefineModel.BlastFurnaceLV)
|
//{
|
// dandrugCell.lockText.gameObject.SetActive(true);
|
// dandrugCell.lockText.text = Language.Get("BlastFurnace104", nextRefineModel.BlastFurnaceLV);
|
//}
|
//else
|
//{
|
// dandrugCell.lockText.gameObject.SetActive(false);
|
//}
|
|
//dandrugCell.cellToggle.onValueChanged.RemoveAllListeners();
|
//dandrugCell.cellToggle.onValueChanged.AddListener((bool isOn)=> { OnClickDandrugCell(isOn,cell, nextRefineModel,treasure); });
|
//if (presentIndex == cell.index)
|
//{
|
// dandrugCell.cellToggle.isOn = true;
|
//}
|
|
}
|
|
|
private void OnClickDandrugCell(bool isOn,CellView cell,TreasureRefineConfig nextRefineModel,Treasure treasure)
|
{
|
}
|
|
private void SetTreasureAttrStr(int[] attrIds, int[] attrValues,int[] nextAttrValues)
|
{
|
int i = 0;
|
for(i = 0; i < attrIds.Length; i++)
|
{
|
_treasureAttrlist[i].SetActive(true);
|
Text curAtrText = _treasureAttrlist[i].transform.Find("curAttrValueText").GetComponent<Text>();
|
Text nextText = _treasureAttrlist[i].transform.Find("nextAttrValueText").GetComponent<Text>();
|
GameObject arrow = _treasureAttrlist[i].transform.Find("arrowImage").gameObject;
|
if(attrValues != null)
|
{
|
curAtrText.text =FurnaceModel.GetTreasureAttrStr(attrIds[i], attrValues[i], true);
|
}
|
else
|
{
|
curAtrText.text =FurnaceModel.GetTreasureAttrStr(attrIds[i],0, true);
|
}
|
|
if (nextAttrValues != null)
|
{
|
arrow.SetActive(true);
|
nextText.gameObject.SetActive(true);
|
nextText.text =FurnaceModel.GetTreasureAttrStr(attrIds[i], nextAttrValues[i],false);
|
}
|
else
|
{
|
arrow.SetActive(false);
|
nextText.gameObject.SetActive(false);
|
}
|
}
|
|
}
|
|
private void RefreshAllTreasureLv()
|
{
|
string s = "";
|
if (FurnaceModel.GetAllTreasureRefineLv() < _treasureModel.AllTreasureLV)
|
{
|
s = UIHelper.GetTextColorByItemColor(TextColType.Red, FurnaceModel.GetAllTreasureRefineLv().ToString()) + "/" + _treasureModel.AllTreasureLV;
|
}
|
else
|
{
|
s = UIHelper.GetTextColorByItemColor(TextColType.Green, FurnaceModel.GetAllTreasureRefineLv().ToString()) + "/" + _treasureModel.AllTreasureLV;
|
}
|
|
_allRefineLvText.text = Language.Get("BlastFurnace112",s);
|
}
|
|
private void RefreshMaterial()
|
{
|
_chinItemModel = Config.Instance.Get<ItemConfig>(FurnaceModel.nextRefineMaterialID);
|
if (_chinItemModel == null)
|
return;
|
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack == null) return;
|
|
int haveMaterCount = singlePack.GetItemCountByID(FurnaceModel.nextRefineMaterialID);
|
if (haveMaterCount >=FurnaceModel.nextRefineMaterialNum)
|
{
|
_refineMaterialNumText.text = UIHelper.GetTextColorByItemColor(TextColType.White, haveMaterCount.ToString()) + "/" +FurnaceModel.nextRefineMaterialNum;
|
}
|
else
|
{
|
_refineMaterialNumText.text = UIHelper.GetTextColorByItemColor(TextColType.Red, haveMaterCount.ToString()) + "/" +FurnaceModel.nextRefineMaterialNum;
|
}
|
_refineMaterialIcon.SetSprite(_chinItemModel.IconKey);
|
}
|
|
private void CreateEffectCell(Dictionary<int,TreasureSkillData> treasureSkillDict)
|
{
|
_treasureEffectCtrl.Refresh();
|
if(treasureSkillDict.Count > 0)
|
{
|
foreach(var key in treasureSkillDict.Keys)
|
{
|
_treasureEffectCtrl.AddCell(ScrollerDataType.Header,key);
|
}
|
}
|
_treasureEffectCtrl.Restart();
|
}
|
|
private void RefreshTreasureEffectCell(ScrollerDataType type, CellView cell)
|
{
|
SkillConfig tagChinSkill = Config.Instance.Get<SkillConfig>(cell.index);
|
if (tagChinSkill == null)
|
return;
|
TreasureEffectCell effectCell = cell.GetComponent<TreasureEffectCell>();
|
if (effectCell == null)
|
effectCell = cell.gameObject.AddComponent<TreasureEffectCell>();
|
|
effectCell.skillIcon.SetSprite(tagChinSkill.IconName);
|
effectCell.nameText.text = tagChinSkill.SkillName;
|
effectCell.lvText.text = StringUtility.Contact(_treasureSkillDict[cell.index].treasureLv, Language.Get("L1047"));
|
|
effectCell.skillBtn.RemoveAllListeners();
|
effectCell.skillBtn.onClick.AddListener(() => { OnClickSkillBtn(cell.index); });
|
if (_treasureSkillDict[cell.index].islock)
|
{
|
effectCell.lockGo.SetActive(true);
|
}
|
else
|
{
|
effectCell.lockGo.SetActive(false);
|
|
}
|
}
|
|
private void OnClickMakeDan()
|
{
|
FurnaceModel.SendRefineTreasureQuest((uint)_treasureModel.TreasureID, (uint)FurnaceModel.fireId);
|
ChangeSuccessRate(0);
|
}
|
|
private void OnClickSkillBtn(int skillId)
|
{
|
TreasureConfig treasureModel = Config.Instance.Get<TreasureConfig>(_treasureModel.TreasureID);
|
SkillDetails.ShowSkillDetails(skillId, SkillDetails.SkillSourceType.BlastFurnace, 0, treasureModel.Name);
|
}
|
|
private void OnClickChooseFire()
|
{
|
ChooseWin.gameObject.SetActive(true);
|
}
|
}
|
}
|