using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using System;
|
using TableConfig;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class TalentTreeBehaviour : MonoBehaviour
|
{
|
[SerializeField] TalentTree m_TalentTree;
|
[SerializeField] TalentSkillBehaviour[] m_TalentSkills;
|
[SerializeField] ScrollRect m_Scroller;
|
TalentModel model
|
{
|
get { return ModelCenter.Instance.GetModel<TalentModel>(); }
|
}
|
|
public int series { get; private set; }
|
public int talentType { get; private set; }
|
|
public virtual void Display(int series, int type)
|
{
|
this.series = series;
|
talentType = type;
|
DisplaySkills();
|
m_Scroller.verticalNormalizedPosition = 1;
|
}
|
|
void DisplaySkills()
|
{
|
var job = PlayerDatas.Instance.baseData.Job;
|
List<int> talentSkills;
|
model.TryGetTalents(job, series, talentType, out talentSkills);
|
for (int i = 0; i < m_TalentSkills.Length; i++)
|
{
|
m_TalentSkills[i].Dispose();
|
if (talentSkills != null && i < talentSkills.Count)
|
{
|
m_TalentSkills[i].gameObject.SetActive(true);
|
m_TalentSkills[i].Display(talentSkills[i]);
|
}
|
else
|
{
|
m_TalentSkills[i].gameObject.SetActive(false);
|
}
|
}
|
|
model.selectSkill = talentSkills != null ? talentSkills[0] : 0;
|
}
|
|
public virtual void Dispose()
|
{
|
|
}
|
|
public bool BelongToTalentTree(int job, int series, int type)
|
{
|
return m_TalentTree.BelongToTalentTree(job, series, type);
|
}
|
}
|
|
[Serializable]
|
public struct TalentTree
|
{
|
public int[] jobs;
|
public int[] series;
|
public int[] types;
|
|
public bool BelongToTalentTree(int job, int series, int type)
|
{
|
for (int i = 0; i < jobs.Length; i++)
|
{
|
if (jobs[i] != job)
|
{
|
continue;
|
}
|
for (int k = 0; k < this.series.Length; k++)
|
{
|
if (this.series[k] != series)
|
{
|
continue;
|
}
|
for (int q = 0; q < types.Length; q++)
|
{
|
if (types[q] == type)
|
{
|
return true;
|
}
|
}
|
}
|
}
|
return false;
|
}
|
}
|
}
|