Files
JJBB/Assets/Project/Script/GUI/PlayerInfo/OtherPlayerAdvancePanelCtr.cs
2024-08-23 15:49:34 +08:00

242 lines
7.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using GCGame.Table;
using System.Collections.Generic;
using Games.GlobeDefine;
public class OtherPlayerAdvancePanelCtr : MonoBehaviour {
#region
public Text stageText; // 阶级描述
public Text modelNameText; // 模型名称
public UICameraTexture modelCameraTexture; // 3D模型
public GameObject InfoPanel; // 信息面板
public GameObject noDataPane; // 无数据提示面板
// 当前页面所属类型
// public AdvanceMenuItemPanelCtr.AdvancePanelType panelType;
// 进阶所属类型
public int curAdvanceBaseLevel; // 当前进阶等级
public int curAdcanceBaseGrade; // 当前等阶
public AdvanceAttrPanel attrPanel; // 属性面板
public AdvanceSkillPanel skillPanel; // 技能面板
public AdvanceEquipPanel equipPanel; // 装备面板
//public AdvanceAnimation animatonPanel; // 动画帧动画脚本
public GameObject ShowModelPanel; // 模型面板
//public GameObject ShowAnimationPanel; // 动画帧面板
#endregion
private Dictionary<AdvanceBase.AdvanceType, AdvanceInfo> advanceInfoDic;
private Dictionary<AdvanceBase.AdvanceType, AdvanceInfo> AdvanceInfoDic
{
get;set;
}
public AdvanceBase.AdvanceType advanceType = AdvanceBase.AdvanceType.Invalid;
private bool hasInit = false; // 标记是否已经有数据/初始化
public bool HasInit
{
get { return hasInit; }
}
#region Single
private static OtherPlayerAdvancePanelCtr _instance;
public static OtherPlayerAdvancePanelCtr Instance
{
get
{
if(_instance != null)
{
return _instance;
}
return null;
}
}
private void Awake()
{
if(_instance == null)
{
_instance = this;
}
}
private void OnDestroy()
{
_instance = null;
}
#endregion
private void OnDisable()
{
hasInit = false;
}
public void Init(Dictionary<AdvanceBase.AdvanceType, AdvanceInfo> dic)
{
hasInit = true;
AdvanceInfoDic = dic;
if(advanceType != AdvanceBase.AdvanceType.Invalid)
{
ShowPanel(advanceType);
}
}
/// <summary>
/// 显示页面
/// </summary>
public void ShowPanel(AdvanceBase.AdvanceType showType)
{
ShowOrNone(true);
if (advanceType == AdvanceBase.AdvanceType.Invalid)
{
ShowOrNone(false);
return;
}
AdvanceInfo info;
if (!AdvanceInfoDic.TryGetValue(advanceType, out info))
{
ShowOrNone(false);
return;
}
// 如果baseID为负数代表没有则不显示
if(info.baseId < 0 || info.level == 0)
{
ShowOrNone(false);
//LogModule.ErrorLog("BaseID is wrong , baseID = " + info.baseId);
return;
}
attrPanel.InitAttrInfo(info, GameDefine_Globe.ShowType.Other); // 显示属性
skillPanel.InitSkillPanel(info, GameDefine_Globe.ShowType.Other); // 显示技能
switch (info.type)
{
// 对于坐骑进阶需要需要额外显示坐骑的装备槽
case (int)AdvanceBase.AdvanceType.Ride:
equipPanel.gameObject.SetActive(true);
if (equipPanel != null)
{
equipPanel.InitEquipItem(GameDefine_Globe.ShowType.Other);
}
break;
default:
equipPanel.gameObject.SetActive(false);
break;
}
ShowModelPanel.SetActive(true);
InitShowModel();
}
// 显示model
public void InitShowModel()
{
switch (advanceType)
{
case AdvanceBase.AdvanceType.Ride:
{
// 获取进阶表数据
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(AdvanceInfoDic[advanceType].baseId, 0);
if (advanceBase == null)
{
ShowOrNone(false);
return;
}
// 获取坐骑属性数据
Tab_MountBase mountBase = TableManager.GetMountBaseByID(advanceBase.ModelId, 0);
if (mountBase == null)
{
ShowOrNone(false);
return;
}
// 坐骑模型资源数据
Tab_CharMount charMount = TableManager.GetCharMountByID(mountBase.ModelID, 0);
if (charMount == null)
{
ShowOrNone(false);
return;
}
modelCameraTexture.InitMountModelPath(charMount, delegate () {
modelCameraTexture.gameObject.SetActive(true);
});
modelNameText.text = mountBase.Name;
stageText.text = GCGame.Utils.GetGradeString(advanceBase.Grade);
curAdvanceBaseLevel = advanceBase.Level;
curAdcanceBaseGrade = advanceBase.Grade;
}
break;
case AdvanceBase.AdvanceType.Wing:
{
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(AdvanceInfoDic[advanceType].baseId, 0);
if (advanceBase == null)
{
ShowOrNone(false);
return;
}
modelCameraTexture.InitWingModelPath(advanceBase, null, delegate ()
{
modelCameraTexture.gameObject.SetActive(true);
});
modelNameText.text = advanceBase.Name;
stageText.text = GCGame.Utils.GetGradeString(advanceBase.Grade);
curAdvanceBaseLevel = advanceBase.Level;
curAdcanceBaseGrade = advanceBase.Grade;
}
break;
default:
{
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(AdvanceInfoDic[advanceType].baseId, 0);
if (advanceBase == null)
{
modelCameraTexture.gameObject.SetActive(false);
ShowOrNone(false);
}
Tab_CharModel charModel = TableManager.GetCharModelByID(advanceBase.ShowModelId, 0);
if (charModel != null)
{
modelCameraTexture.InitModelPath(charModel.ResPath, charModel, LoadAssetBundle.BUNDLE_PATH_MODEL, true, delegate () {
modelCameraTexture._CameraPrefab.GetComponent<Camera>().orthographicSize = 1.3f;
modelCameraTexture.gameObject.SetActive(true);
});
}
modelNameText.text = advanceBase.Name;
stageText.text = GCGame.Utils.GetGradeString(advanceBase.Grade);
curAdvanceBaseLevel = advanceBase.Level;
curAdcanceBaseGrade = advanceBase.Grade;
}
break;
}
}
/// <summary>
/// 控制是否显示信息
/// 如:当没有相关进阶信息,关闭信息面板,打开提示面板
/// </summary>
/// <param name="isShow">是否显示信息面板</param>
private void ShowOrNone(bool isShow)
{
InfoPanel.SetActive(isShow);
noDataPane.SetActive(!isShow);
}
}