//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, February 27, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine.UI;
|
|
|
namespace Snxxz.UI
|
{
|
|
public class EquipSuitPropertyWidget : MonoBehaviour
|
{
|
[SerializeField] Text m_SuitName;
|
[SerializeField] StarToggle[] m_StarToggles;
|
[SerializeField] Text[] m_SuitEquipNames;
|
[SerializeField] UIEffect[] m_SuitEquipEffects;
|
|
[SerializeField] EquipSuitPropertyBar m_TwoSuit;
|
[SerializeField] EquipSuitPropertyBar m_FiveSuit;
|
[SerializeField] Text m_EightSuitTitle;
|
[SerializeField] Text m_EightSuitDescription;
|
[SerializeField] UIEffect[] m_SuitLevelEffects;
|
|
[SerializeField] EquipSuitActiveHand m_SuitActive2;
|
[SerializeField] EquipSuitActiveHand m_SuitActive5;
|
[SerializeField] EquipSuitActiveHand m_SuitActive8;
|
|
[SerializeField] RedpointBehaviour redpoint0;
|
[SerializeField] RedpointBehaviour redpoint3;
|
[SerializeField] RedpointBehaviour redpoint6;
|
[SerializeField] RedpointBehaviour redpoint9;
|
|
EquipModel model { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
int level;
|
|
public void Init(int level, int eightSuitLevel)
|
{
|
this.level = level;
|
|
redpoint0.redpointId = (200100 + this.level) * 100 + 0;
|
redpoint3.redpointId = (200100 + this.level) * 100 + 3;
|
redpoint6.redpointId = (200100 + this.level) * 100 + 6;
|
redpoint9.redpointId = (200100 + this.level) * 100 + 9;
|
|
m_SuitName.text = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.TwoSuit)[0].name;
|
var maxLevel = EquipStarModel.GetMaxStarLevel(level);
|
m_StarToggles[3].SetActive(maxLevel >= 9);
|
m_StarToggles[2].SetActive(maxLevel >= 6);
|
m_StarToggles[1].SetActive(maxLevel >= 3);
|
m_StarToggles[0].SetActive(true);
|
|
int selectIndex = model.GetSuitRepoindStar(level);
|
if (selectIndex != -1)
|
{
|
m_StarToggles[selectIndex].Select();
|
return;
|
}
|
|
if (eightSuitLevel >= 6 && maxLevel >= 9)
|
{
|
m_StarToggles[3].Select();
|
}
|
else if (eightSuitLevel >= 3 && maxLevel >= 6)
|
{
|
m_StarToggles[2].Select();
|
}
|
else if (eightSuitLevel >= 0 && maxLevel >= 3)
|
{
|
m_StarToggles[1].Select();
|
}
|
else
|
{
|
m_StarToggles[0].Select();
|
}
|
|
}
|
|
public void DisplaySuitPlaces(List<int> places)
|
{
|
for (int i = 1; i <= 8; i++)
|
{
|
var hasSuit = places.Contains(i);
|
m_SuitEquipNames[i - 1].color = UIHelper.GetUIColor(hasSuit ? TextColType.Green : TextColType.White, true);
|
m_SuitEquipNames[i - 1].text = UIHelper.GetEquipPlaceName(i);
|
}
|
}
|
|
public void DisplaySuitPlaceEffects(List<int> places)
|
{
|
foreach (var place in places)
|
{
|
m_SuitEquipEffects[place - 1].Play();
|
model.RecordSuitPlaceEffectPlay(new Int2(this.level, place));
|
}
|
}
|
|
public void DisplayProperty(EquipSuitProperty property)
|
{
|
|
m_TwoSuit.Display(property.twoSuit, true, property.twoSuit.actived && property.handActived2);
|
m_FiveSuit.Display(property.fiveSuit, true, property.fiveSuit.actived && property.handActived5);
|
m_EightSuitDescription.text = GetEightSuitDescription(property.eightSuitId);
|
var color = UIHelper.GetUIColor(property.eightActived && property.handActived8 ? TextColType.Green : TextColType.White, true);
|
m_EightSuitTitle.color = color;
|
m_EightSuitDescription.color = color;
|
|
m_SuitActive2.DisPlay(property.twoSuit.actived && !property.handActived2, property.level,
|
property.suitID, 2, property.star);
|
m_SuitActive5.DisPlay(property.fiveSuit.actived && !property.handActived5, property.level,
|
property.suitID, 5, property.star);
|
m_SuitActive8.DisPlay(property.eightActived && !property.handActived8, property.level,
|
property.suitID, 8, property.star);
|
}
|
|
public void DisplaySuitLevelEffects(EquipSuitActive suitActive)
|
{
|
if (suitActive.twoActived)
|
{
|
m_SuitLevelEffects[0].Play();
|
model.RecordSuitLevelEffectPlay(new Int3(suitActive.level, suitActive.star, 2));
|
}
|
|
if (suitActive.fiveActived)
|
{
|
m_SuitLevelEffects[1].Play();
|
model.RecordSuitLevelEffectPlay(new Int3(suitActive.level, suitActive.star, 5));
|
}
|
|
if (suitActive.eightActived)
|
{
|
m_SuitLevelEffects[2].Play();
|
model.RecordSuitLevelEffectPlay(new Int3(suitActive.level, suitActive.star, 8));
|
if (!model.IsSetAppearanceHinted(suitActive.level))
|
{
|
model.RecordSuitSetAppearanceHint(suitActive.level);
|
var equipSet = model.GetEquipSet(suitActive.level);
|
var config = RealmConfig.Get(equipSet.realm);
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),
|
Language.Get("WearRealmEquip", config.Name, config.Name),
|
(bool ok) => { if (ok) { model.SetAppearance(suitActive.level); } }
|
);
|
}
|
}
|
}
|
|
public void Dispose()
|
{
|
|
}
|
|
private string GetEightSuitDescription(int suitId)
|
{
|
var config = EquipSuitConfig.Get(suitId);
|
if (config.skillID > 0)
|
{
|
return config.description;
|
}
|
else
|
{
|
return PlayerPropertyConfig.GetFullDescription(config.attr[0]);
|
}
|
}
|
|
[System.Serializable]
|
public class StarToggle
|
{
|
public int star;
|
public Text title;
|
public Toggle toggle;
|
|
EquipModel model { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
public void SetActive(bool active)
|
{
|
toggle.isOn = false;
|
title.SetActive(active);
|
toggle.interactable = active;
|
if (active)
|
{
|
toggle.SetListener(OnValueChange);
|
}
|
else
|
{
|
toggle.RemoveAllListeners();
|
}
|
}
|
|
public void Select()
|
{
|
toggle.isOn = true;
|
}
|
|
private void OnValueChange(bool value)
|
{
|
if (value)
|
{
|
model.SelectSuitStarLevel(star);
|
}
|
}
|
|
}
|
|
}
|
|
}
|