//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, May 17, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public enum RidingAndPetActivation
|
{
|
MountActivation = 0,//坐骑激活
|
MountSkillActivates = 1,//坐骑技能激活
|
PetActivation = 2,//灵宠激活
|
PetSkillActivates = 3,//灵宠技能激活
|
|
}
|
|
public class RidingAndPetActivationWin : Window
|
{
|
[SerializeField] Image m_NameImage;//类型名
|
[SerializeField] RawImage m_RawImagePet;//灵宠模型展示
|
[SerializeField] RawImage m_RawImageMount;//坐骑模型
|
[SerializeField] Text m_MilitaryPowerText;//战斗力
|
[SerializeField] Button m_BGMObjButton;//关闭按钮
|
|
[SerializeField] GameObject m_CharacterPaletteObj;//激活面板
|
[SerializeField] Transform m_SkillGroup;//技能组
|
[SerializeField] Transform m_CharacterPalette;//属性组
|
|
[SerializeField] GameObject m_PanelSkill;//技能解锁面板
|
[SerializeField] Text m_SkillText;//技能名
|
[SerializeField] PropertiesDirectory m_PropertiesDirectory;
|
[SerializeField] SkillButtonPet m_SkillBtn1;//技能按钮
|
[SerializeField] Text m_DescribeText;//技能描述
|
|
[SerializeField] GameObject m_Text;
|
|
#region Built-in
|
MountModel m_MountModel;
|
MountModel mountModel { get { return m_MountModel ?? (m_MountModel = ModelCenter.Instance.GetModel<MountModel>()); } }
|
RidingAndPetActivationModel ridingAndPetActivationModel { get { return ModelCenter.Instance.GetModel<RidingAndPetActivationModel>(); } }
|
List<HorseSkillClass> MountSkills = new List<HorseSkillClass>();
|
Dictionary<int, int> FightDic = new Dictionary<int, int>();
|
public static event Action FairyJadeDEvent;
|
private float LatencyTime = 0;//等待时间
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_BGMObjButton.AddListener(OnClickCloseButton);
|
}
|
|
protected override void OnPreOpen()
|
{
|
m_Text.gameObject.SetActive(false);
|
LatencyTime = 0f;
|
m_BGMObjButton.interactable = false;
|
RidingAndPetActivationSet(ridingAndPetActivationModel.RidingAndPetActivation1, ridingAndPetActivationModel.ActivateID1, ridingAndPetActivationModel.SkillID1, ridingAndPetActivationModel.Lv);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
|
}
|
|
protected override void OnPreClose()
|
{
|
switch (ridingAndPetActivationModel.RidingAndPetActivation1)
|
{
|
case RidingAndPetActivation.MountSkillActivates:
|
case RidingAndPetActivation.PetSkillActivates:
|
WindowCenter.Instance.Open<FlySkillIconWin>();
|
break;
|
default:
|
if (FairyJadeDEvent != null)
|
{
|
FairyJadeDEvent();
|
}
|
break;
|
}
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
protected override void LateUpdate()
|
{
|
LatencyTime += Time.deltaTime;
|
if (LatencyTime > 2f)
|
{
|
if (!m_BGMObjButton.interactable)
|
{
|
m_BGMObjButton.interactable = true;
|
}
|
if (!m_Text.activeInHierarchy)
|
{
|
m_Text.SetActive(true);
|
}
|
}
|
}
|
|
private void OnClickCloseButton()
|
{
|
Close();
|
}
|
public void RidingAndPetActivationSet(RidingAndPetActivation ridingAndPetActivation, int ActivateID, int SkillID = 0, int lv = 1)
|
{
|
switch (ridingAndPetActivation)
|
{
|
case RidingAndPetActivation.MountActivation:
|
SetMountActivation(ActivateID);
|
break;
|
case RidingAndPetActivation.MountSkillActivates:
|
SetMountSkillActivates(ActivateID, SkillID, lv);
|
break;
|
case RidingAndPetActivation.PetActivation:
|
SetPetActivation(ActivateID);
|
break;
|
case RidingAndPetActivation.PetSkillActivates:
|
SetPetSkillActivates(ActivateID, SkillID, lv);
|
break;
|
default:
|
break;
|
}
|
}
|
|
IEnumerator FrameDelay()
|
{
|
yield return null;
|
if (UI3DModelExhibition.Instance.NpcModelPet)
|
{
|
var animator = UI3DModelExhibition.Instance.NpcModelPet.GetComponent<Animator>();
|
animator.Play(GAStaticDefine.State_Dance);
|
}
|
}
|
|
private void SetMountActivation(int ActivateID)//坐骑激活
|
{
|
m_CharacterPaletteObj.SetActive(true);
|
m_PanelSkill.SetActive(false);
|
m_NameImage.SetSprite("UI_JH_11");
|
m_RawImagePet.gameObject.SetActive(false);
|
m_RawImageMount.gameObject.SetActive(true);
|
HorseConfig Horseconfig = HorseConfig.Get(ActivateID);
|
int InitFightPower = 0;
|
InitFightPower += Horseconfig.InitFightPower;
|
UI3DModelExhibition.Instance.ShowHourse(Horseconfig.Model, m_RawImageMount);
|
MountSkills.Clear();
|
foreach (var key in mountModel.GetMountSkillAndItem.Keys)
|
{
|
if (mountModel.GetMountSkillAndItem[key].HorseID == ActivateID)
|
{
|
MountSkills.Add(mountModel.GetMountSkillAndItem[key]);
|
}
|
}
|
for (int i = 0; i < m_SkillGroup.childCount; i++)
|
{
|
if (i < MountSkills.Count)
|
{
|
m_SkillGroup.GetChild(i).gameObject.SetActive(true);
|
SkillButtonPet mountSkill = m_SkillGroup.GetChild(i).gameObject.GetComponent<SkillButtonPet>();
|
mountSkill.SetModel(MountSkills[i].SkillID, MountSkills[i].HorseLV, true, ActivateID, SkillType.MountSkill);
|
}
|
else
|
{
|
m_SkillGroup.GetChild(i).gameObject.SetActive(false);
|
}
|
}
|
HorseUpConfig tagMode = HorseUpConfig.GetHorseIDAndLV(ActivateID, 1);
|
int[] strListType = tagMode.AttrType;
|
int[] strListValue = tagMode.AttrValue;
|
FightDic.Clear();
|
for (int i = 0; i < m_CharacterPalette.childCount; i++)
|
{
|
if (i < strListValue.Length)
|
{
|
m_CharacterPalette.GetChild(i).gameObject.SetActive(true);
|
PropertiesDirectory propertiesDirector = m_CharacterPalette.GetChild(i).GetComponent<PropertiesDirectory>();
|
switch (strListType[i])
|
{
|
case 6:
|
FightDic.Add(6, strListValue[i]);
|
propertiesDirector.AssignValueType1(Language.Get("Hit_Z"), strListValue[i].ToString());
|
break;
|
case 7:
|
FightDic.Add(7, strListValue[i]);
|
propertiesDirector.AssignValueType1(Language.Get("AttackPower_Z"), strListValue[i].ToString());
|
break;
|
case 23:
|
propertiesDirector.AssignValueType1(Language.Get("MovingSpeed_Z"), strListValue[i].ToString());
|
break;
|
}
|
}
|
else
|
{
|
if (m_CharacterPalette.GetChild(i).gameObject.name == "SkillGroupObj")
|
{
|
continue;
|
}
|
else
|
{
|
m_CharacterPalette.GetChild(i).gameObject.SetActive(false);
|
}
|
|
}
|
}
|
m_MilitaryPowerText.text = (UIHelper.GetFightPower(FightDic) + InitFightPower).ToString();
|
}
|
|
private void SetMountSkillActivates(int ActivateID, int SkillID, int lv)//坐骑技能激活
|
{
|
m_CharacterPaletteObj.SetActive(false);
|
m_PanelSkill.SetActive(true);
|
m_NameImage.SetSprite("UI_JH_6");
|
m_RawImagePet.gameObject.SetActive(false);
|
m_RawImageMount.gameObject.SetActive(true);
|
HorseConfig Horseconfig = HorseConfig.Get(ActivateID);
|
int InitFightPower = 0;
|
InitFightPower += Horseconfig.InitFightPower;
|
UI3DModelExhibition.Instance.ShowHourse(Horseconfig.Model, m_RawImageMount);
|
MountSkills.Clear();
|
foreach (var key in mountModel.GetMountSkillAndItem.Keys)
|
{
|
if (mountModel.GetMountSkillAndItem[key].HorseID == ActivateID)
|
{
|
MountSkills.Add(mountModel.GetMountSkillAndItem[key]);
|
}
|
}
|
m_SkillBtn1.SetModel(SkillID, lv, true, ActivateID, SkillType.MountSkill);
|
m_PropertiesDirectory.AssignValueType2(Language.Get("Class_Z"), (lv - 1).ToString(), lv.ToString());
|
SkillConfig skillconfig = SkillConfig.Get(SkillID);
|
|
m_SkillText.text = skillconfig.SkillName;
|
m_DescribeText.text = skillconfig.Description;
|
int fightNumber = 0;
|
Dictionary<int, float> Dic = ridingAndPetActivationModel.GetOneMountPropertyQuality(ActivateID);
|
FightDic.Clear();
|
FightDic.Add(6, (int)Dic[6]);
|
FightDic.Add(7, (int)Dic[7]);
|
for (int k = 0; k < MountSkills.Count; k++)
|
{
|
if (lv >= MountSkills[k].HorseLV)
|
{
|
SkillConfig skillcon = SkillConfig.Get(MountSkills[k].SkillID);
|
fightNumber += skillcon.FightPower;
|
}
|
}
|
m_MilitaryPowerText.text = (UIHelper.GetFightPower(FightDic) + fightNumber + InitFightPower).ToString();
|
}
|
|
private void SetPetActivation(int ActivateID)//灵宠激活
|
{
|
m_CharacterPaletteObj.SetActive(true);
|
m_PanelSkill.SetActive(false);
|
m_NameImage.SetSprite("UI_JH_11");
|
m_RawImagePet.gameObject.SetActive(true);
|
m_RawImageMount.gameObject.SetActive(false);
|
var npcConfig = NPCConfig.Get(ActivateID);
|
UI3DModelExhibition.Instance.ShowNPC(ActivateID, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, m_RawImagePet);
|
PetInfoConfig petInfoConfig = PetInfoConfig.Get(ActivateID);
|
int InitFightPower = int.Parse(petInfoConfig.InitFightPower);
|
int[] strListSkills = petInfoConfig.SkillID;
|
int[] strListSkillLv = petInfoConfig.SkillUnLock;
|
for (int i = 0; i < m_SkillGroup.childCount; i++)
|
{
|
if (i < strListSkills.Length)
|
{
|
m_SkillGroup.GetChild(i).gameObject.SetActive(true);
|
SkillButtonPet mountSkill = m_SkillGroup.GetChild(i).gameObject.GetComponent<SkillButtonPet>();
|
mountSkill.SetModel(strListSkills[i], strListSkillLv[i], true, ActivateID, SkillType.PetSkill);
|
}
|
else
|
{
|
m_SkillGroup.GetChild(i).gameObject.SetActive(false);
|
}
|
|
}
|
for (int j = 0; j < m_CharacterPalette.childCount; j++)
|
{
|
if (m_CharacterPalette.GetChild(j).gameObject.name == "SkillGroupObj")
|
{
|
continue;
|
}
|
else
|
{
|
m_CharacterPalette.GetChild(j).gameObject.SetActive(false);
|
}
|
}
|
PetClassCostConfig _tagPetClass = PetClassCostConfig.GetPetIdAndRank(ActivateID, 1);
|
FightDic.Clear();
|
FightDic.Add(77, _tagPetClass.AtkAdd);
|
FightDic.Add(78, _tagPetClass.AtkAdd);
|
m_CharacterPalette.GetChild(0).gameObject.SetActive(true);
|
PropertiesDirectory propertiesDirector1 = m_CharacterPalette.GetChild(0).GetComponent<PropertiesDirectory>();
|
propertiesDirector1.AssignValueType1(Language.Get("AttackPower_Z"), _tagPetClass.AtkAdd.ToString());
|
m_MilitaryPowerText.text = (UIHelper.GetFightPower(FightDic) + InitFightPower).ToString();
|
}
|
|
private void SetPetSkillActivates(int ActivateID, int SkillID, int lv)//灵宠技能激活
|
{
|
m_CharacterPaletteObj.SetActive(false);
|
m_PanelSkill.SetActive(true);
|
m_NameImage.SetSprite("UI_JH_6");
|
m_RawImagePet.gameObject.SetActive(true);
|
m_RawImageMount.gameObject.SetActive(false);
|
|
var npcConfig = NPCConfig.Get(ActivateID);
|
UI3DModelExhibition.Instance.ShowNPC(ActivateID, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, m_RawImagePet);
|
// StartCoroutine("FrameDelay");
|
PetInfoConfig petInfoConfig = PetInfoConfig.Get(ActivateID);
|
int InitFightPower = int.Parse(petInfoConfig.InitFightPower);
|
int[] strListSkills = petInfoConfig.SkillID;
|
int[] strListSkillLv = petInfoConfig.SkillUnLock;
|
m_SkillBtn1.SetModel(SkillID, lv, true, ActivateID, SkillType.PetSkill);
|
m_PropertiesDirectory.AssignValueType2(Language.Get("Class_Z"), (lv - 1).ToString(), lv.ToString());
|
SkillConfig skillcon = SkillConfig.Get(SkillID);
|
m_SkillText.text = skillcon.SkillName;
|
m_DescribeText.text = skillcon.Description;
|
PetClassCostConfig _tagPetClass1 = PetClassCostConfig.GetPetIdAndRank(ActivateID, lv);
|
int fightNumber = 0;
|
for (int j = 0; j < strListSkillLv.Length; j++)
|
{
|
if (lv >= strListSkillLv[j])
|
{
|
SkillConfig skillconfig = SkillConfig.Get(strListSkills[j]);
|
fightNumber += skillconfig.FightPower;
|
}
|
}
|
FightDic.Clear();
|
int OnePetAddLife = (int)ridingAndPetActivationModel.GetOnePetAddLife(ActivateID);
|
FightDic.Add(77, _tagPetClass1.AtkAdd);
|
FightDic.Add(78, _tagPetClass1.AtkAdd);
|
FightDic.Add(6, OnePetAddLife);
|
m_MilitaryPowerText.text = (UIHelper.GetFightPower(FightDic) + fightNumber + InitFightPower).ToString();
|
}
|
|
|
}
|
#endregion
|
|
}
|
|
|
|