294 lines
9.5 KiB
C#
294 lines
9.5 KiB
C#
using UnityEngine;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine.UI;
|
||
using Games.Item;
|
||
using GCGame.Table;
|
||
|
||
public class MarryRingTips : MonoBehaviour
|
||
{
|
||
|
||
public static MarryRingTips Instance;
|
||
private void Awake()
|
||
{
|
||
Instance = this;
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
Instance = null;
|
||
}
|
||
|
||
#region
|
||
public Text ringName;
|
||
public Image ringIcon;
|
||
public Image _RingQuality;
|
||
public Text level;
|
||
public Text combat;
|
||
public List<Text> attrList;
|
||
|
||
public GameObject marryRingPanel;
|
||
public GameObject divorceRingPanel;
|
||
|
||
public Text divorceRingSkillName;
|
||
public Text divorceRingSkillDesc;
|
||
public Text divorceRingWelfareDesc;
|
||
|
||
public Text marryRingSkillName;
|
||
public Text marryRingSkillDesc;
|
||
public Text marryRingWelfareDesc;
|
||
public List<Text> ownerNameList;
|
||
|
||
private const int limitHeight = 260;
|
||
|
||
public GameObject levelUpPanel;
|
||
|
||
private readonly string skillDescStrId = "#{" + 47007 + "}";
|
||
#endregion
|
||
|
||
///虽然ringInfo里存有Info,但是这里还需要传的一个info是为了预览,结婚的时候预览结婚戒指的效果
|
||
private MarryRingCtr.RingInfo ringInfo;
|
||
private Tab_MarryRingBase marryRingBaseTab;
|
||
|
||
/// <summary>
|
||
/// 预览
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
/// <param name="level"></param>
|
||
private bool isPreView = false;
|
||
public void InitRingTips(int type, int level)
|
||
{
|
||
levelUpPanel.SetActive(false);
|
||
isPreView = true;
|
||
int ringBaseId = level + (type + 1) * 1000;
|
||
marryRingBaseTab = TableManager.GetMarryRingBaseByID(ringBaseId, 0);
|
||
if (marryRingBaseTab == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
SetLevelDesc(level);
|
||
ShorOrHidePanelByType((MarryRingCtr.RingType)type);
|
||
InitPanelByType((MarryRingCtr.RingType)type);
|
||
SetRingName(marryRingBaseTab.ItemId);
|
||
InitItemInfo(type, level);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查看本身戒指信息
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
public void InitRingTips(bool isShowLevelUpBtn = true)
|
||
{
|
||
levelUpPanel.SetActive(isShowLevelUpBtn);
|
||
isPreView = false;
|
||
ringInfo = GameManager.gameManager.PlayerDataPool.MyRingInfoData.GetRingInfo();
|
||
SetLevelDesc(GameManager.gameManager.PlayerDataPool.MyRingInfoData.GetRingInfo().ringLevel);
|
||
int ringBaseId = ringInfo.ringLevel + (ringInfo.ringType + 1) * 1000;
|
||
marryRingBaseTab = TableManager.GetMarryRingBaseByID(ringBaseId, 0);
|
||
if (marryRingBaseTab == null)
|
||
{
|
||
return;
|
||
}
|
||
ShorOrHidePanelByType((MarryRingCtr.RingType)ringInfo.ringType);
|
||
InitPanelByType((MarryRingCtr.RingType)ringInfo.ringType);
|
||
InitItemInfo(ringInfo.ringType, ringInfo.ringLevel);
|
||
SetRingName(marryRingBaseTab.ItemId);
|
||
}
|
||
|
||
public void SetRingName(int itemId)
|
||
{
|
||
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(itemId, 0);
|
||
if(commonItem == null)
|
||
{
|
||
return;
|
||
}
|
||
ringName.text = GCGame.Utils.GetQualityColorInTip(commonItem.Quality);
|
||
ringName.text += TableManager.GetCommonItemByID(itemId, 0).Name + "</color>";
|
||
}
|
||
|
||
public void SetLevelDesc(int _Level)
|
||
{
|
||
level.text = StrDictionary.GetClientDictionaryString("#{1166}", _Level);
|
||
}
|
||
|
||
private int itemId = -1;
|
||
public void InitItemInfo(int ringType, int ringLevel)
|
||
{
|
||
int ringBaseId = (ringType + 1) * 1000 + ringLevel;
|
||
Tab_MarryRingBase ringBaseTab = TableManager.GetMarryRingBaseByID(ringBaseId, 0);
|
||
if (ringBaseTab == null)
|
||
{
|
||
return;
|
||
}
|
||
itemId = ringBaseTab.ItemId;
|
||
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(itemId, 0);
|
||
if (commonItem != null)
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(ringIcon, commonItem.Icon);
|
||
LoadAssetBundle.Instance.SetImageSprite(_RingQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
||
if (commonItem.QualityEffect > 0)
|
||
{
|
||
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, ringIcon.transform);
|
||
}
|
||
else
|
||
{
|
||
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, ringIcon.transform);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void OnItemIconClick()
|
||
{
|
||
if(itemId == -1)
|
||
{
|
||
return;
|
||
}
|
||
|
||
ItemTooltipsLogic.ShowItemTooltip(itemId, ItemTooltipsLogic.ShowType.Info, ringIcon.transform.position);
|
||
}
|
||
|
||
public void InitPanelByType(MarryRingCtr.RingType type)
|
||
{
|
||
switch (type)
|
||
{
|
||
case MarryRingCtr.RingType.Single:
|
||
{
|
||
InitSingleRingTips();
|
||
}
|
||
break;
|
||
case MarryRingCtr.RingType.Marry:
|
||
{
|
||
InitMarryRingTips();
|
||
}
|
||
break;
|
||
case MarryRingCtr.RingType.Divorce:
|
||
{
|
||
InitDivoreceRingTips();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void InitSingleRingTips()
|
||
{
|
||
InitAttrPanel();
|
||
|
||
//CalculateBGRec();
|
||
}
|
||
|
||
public void InitMarryRingTips()
|
||
{
|
||
InitAttrPanel();
|
||
InitSkillAndWelfareDesc();
|
||
InitCoupNameDesc();
|
||
//CalculateBGRec();
|
||
}
|
||
|
||
public void InitDivoreceRingTips()
|
||
{
|
||
InitAttrPanel();
|
||
//InitSkillAndWelfareDesc();
|
||
//CalculateBGRec();
|
||
}
|
||
|
||
|
||
public void InitCoupNameDesc()
|
||
{
|
||
if (isPreView)
|
||
{
|
||
if(GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(0).IsValid()
|
||
&& GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).IsValid())
|
||
{
|
||
ownerNameList[0].text = StrDictionary.GetClientDictionaryString("#{47009}", GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(0).MemberName);
|
||
ownerNameList[1].text = StrDictionary.GetClientDictionaryString("#{47010}", GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).MemberName);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(GameManager.gameManager.PlayerDataPool.CoupFlag == (int)MarryPanelCtr.CoupType.Husband)
|
||
{
|
||
ownerNameList[0].text = StrDictionary.GetClientDictionaryString("#{47009}", GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName);
|
||
ownerNameList[1].text = StrDictionary.GetClientDictionaryString("#{47010}", GameManager.gameManager.PlayerDataPool.MyRingInfoData.loverName);
|
||
}
|
||
else
|
||
{
|
||
ownerNameList[0].text = StrDictionary.GetClientDictionaryString("#{47009}", GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName);
|
||
ownerNameList[1].text = StrDictionary.GetClientDictionaryString("#{47010}", GameManager.gameManager.PlayerDataPool.MyRingInfoData.loverName);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void InitSkillAndWelfareDesc()
|
||
{
|
||
//技能描述
|
||
int ringBaseId = (ringInfo.ringType + 1) * 1000 + ringInfo.ringLevel;
|
||
Tab_MarryRingSkillBase ringSkillBase = TableManager.GetMarryRingSkillBaseByID(marryRingBaseTab.SkillLevel, 0);
|
||
if(ringSkillBase== null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
marryRingSkillName.text = StrDictionary.GetClientDictionaryString("#{47006}", marryRingBaseTab.RingLevel);
|
||
marryRingSkillDesc.text = StrDictionary.GetClientDictionaryString(skillDescStrId,
|
||
ringSkillBase.GetAttrValuebyIndex(0),
|
||
ringSkillBase.GetAttrValuebyIndex(1),
|
||
ringSkillBase.GetAttrValuebyIndex(2));
|
||
|
||
marryRingWelfareDesc.text = StrDictionary.GetClientDictionaryString("#{47008}");
|
||
}
|
||
|
||
public void InitAttrPanel()
|
||
{
|
||
combat.text = marryRingBaseTab.CombatValue.ToString();
|
||
for (int index = 0; index < marryRingBaseTab.getAttrIdCount(); index++)
|
||
{
|
||
if (marryRingBaseTab.GetAttrIdbyIndex(index) != -1)
|
||
{
|
||
attrList[index].gameObject.SetActive(true);
|
||
InitAttrDesc(index, marryRingBaseTab.GetAttrIdbyIndex(index), marryRingBaseTab.GetAttrValuebyIndex(index));
|
||
}else
|
||
{
|
||
attrList[index].gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
//public void CalculateBGRec()
|
||
//{
|
||
// scrollViewLayout.minHeight = contentRec.rect.height > limitHeight ? limitHeight : contentRec.rect.height;
|
||
//}
|
||
|
||
public void InitAttrDesc(int index, int attrId, int attrValue)
|
||
{
|
||
string strAttrId = "#{" + (attrId + 10000) + "}";
|
||
attrList[index].text = StrDictionary.GetClientDictionaryString("#{46217}", StrDictionary.GetClientDictionaryString(strAttrId), attrValue);
|
||
}
|
||
|
||
public void ShorOrHidePanelByType(MarryRingCtr.RingType type)
|
||
{
|
||
marryRingPanel.SetActive(type == MarryRingCtr.RingType.Marry);
|
||
divorceRingPanel.SetActive(type == MarryRingCtr.RingType.Divorce);
|
||
}
|
||
|
||
public void OnRingIconClick()
|
||
{
|
||
ItemTooltipsLogic.ShowItemTooltip(itemId, ItemTooltipsLogic.ShowType.Info, ringIcon.gameObject.transform.position);
|
||
}
|
||
|
||
public void OnMaskClick()
|
||
{
|
||
UIManager.CloseUI(UIInfo.MarryRingTips);
|
||
}
|
||
|
||
public void OnLevelUpBtnClick()
|
||
{
|
||
UIManager.ShowUI(UIInfo.MarryRoot, delegate(bool bSucess, object param) {
|
||
if(bSucess)
|
||
{
|
||
MarryRoot.Instance.ShowPage(MarryRoot.MarryMenuItemType.Ring);
|
||
}
|
||
});
|
||
}
|
||
}
|