199 lines
6.4 KiB
C#
199 lines
6.4 KiB
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
|
|||
|
public class WeedingPanelCtr : MonoBehaviour {
|
|||
|
public static WeedingPanelCtr Instance;
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
}
|
|||
|
|
|||
|
#region
|
|||
|
public List<Image> roleHeadIconList;
|
|||
|
public List<Text> roleNameList;
|
|||
|
|
|||
|
public GameObject weedingItemPrefab;
|
|||
|
public Transform weedingItemParent;
|
|||
|
|
|||
|
public RingItem selfRingItem;
|
|||
|
public RingItem selfPreviewRingItem;
|
|||
|
|
|||
|
public RingItem otherRingItem;
|
|||
|
public RingItem otherPreviewRingItem;
|
|||
|
|
|||
|
private int curSelectedWeedingId = (int)WeedingType.Level_High; //当前选择的婚礼规模(默认为豪华)
|
|||
|
#endregion
|
|||
|
|
|||
|
public enum WeedingType
|
|||
|
{
|
|||
|
Level_High = 1,
|
|||
|
Level_Middle = 2,
|
|||
|
Level_Low = 3,
|
|||
|
}
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
curSelectedWeedingId = (int)WeedingType.Level_High;
|
|||
|
CreateWeedingItem();
|
|||
|
SetRoleHeadIconList();
|
|||
|
SetRoleNameList();
|
|||
|
ReqOtherRingInfo();
|
|||
|
InitSelfRingInfo();
|
|||
|
}
|
|||
|
|
|||
|
public void ReqOtherRingInfo()
|
|||
|
{
|
|||
|
if(GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).IsValid())
|
|||
|
{
|
|||
|
ReqGetOtherMarryRingInfo req = new ReqGetOtherMarryRingInfo();
|
|||
|
req.guid = (long)GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).Guid;
|
|||
|
req.SendMsg();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void InitSelfRingInfo()
|
|||
|
{
|
|||
|
selfRingItem.InitRingItem();
|
|||
|
selfPreviewRingItem.InitRingItem((int)MarryRingCtr.RingType.Marry, GameManager.gameManager.PlayerDataPool.MyRingInfoData.GetRingInfo().ringLevel);
|
|||
|
}
|
|||
|
|
|||
|
public void InitOtherRingInfo(RespGetOtherMarryRingInfo packet)
|
|||
|
{
|
|||
|
otherRingItem.InitRingItem(packet.ringType, packet.ringlevel);
|
|||
|
otherPreviewRingItem.InitRingItem((int)MarryRingCtr.RingType.Marry, packet.ringlevel);
|
|||
|
}
|
|||
|
|
|||
|
public void SetRoleHeadIconList()
|
|||
|
{
|
|||
|
for(int index = 0; index < roleHeadIconList.Count; index++)
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(0).IsValid())
|
|||
|
{
|
|||
|
roleHeadIconList[index].gameObject.SetActive(true);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(roleHeadIconList[index], Utils.GetProfessionSpriteName(GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(index).Profession));
|
|||
|
}else
|
|||
|
{
|
|||
|
roleHeadIconList[index].gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SetRoleNameList()
|
|||
|
{
|
|||
|
for (int index = 0; index < roleHeadIconList.Count; index++)
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(0).IsValid())
|
|||
|
{
|
|||
|
roleNameList[index].gameObject.SetActive(true);
|
|||
|
roleNameList[index].text = GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(index).MemberName;
|
|||
|
}else
|
|||
|
{
|
|||
|
roleNameList[index].gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private List<WeedingItem> itemPrefabList = new List<WeedingItem>();
|
|||
|
public void CreateWeedingItem()
|
|||
|
{
|
|||
|
var weedingConfig = TableManager.GetWeedingConfig().Values;
|
|||
|
ClearAllItemPrefab();
|
|||
|
foreach (var config in weedingConfig)
|
|||
|
{
|
|||
|
if(config.MarryType == 0) //结婚
|
|||
|
{
|
|||
|
GameObject item = GameObject.Instantiate(weedingItemPrefab);
|
|||
|
|
|||
|
item.transform.SetParent(weedingItemParent);
|
|||
|
item.transform.localPosition = Vector3.zero;
|
|||
|
item.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|||
|
item.transform.localScale = Vector3.one;
|
|||
|
|
|||
|
item.GetComponent<WeedingItem>().InitWeedingItem(config.Id);
|
|||
|
itemPrefabList.Add(item.GetComponent<WeedingItem>());
|
|||
|
}
|
|||
|
}
|
|||
|
if (itemPrefabList.Count > 0)
|
|||
|
OnWeedingItemClick(itemPrefabList[0].weedingId);
|
|||
|
}
|
|||
|
|
|||
|
public void ClearAllItemPrefab()
|
|||
|
{
|
|||
|
for(int index = 0; index < itemPrefabList.Count; index++)
|
|||
|
{
|
|||
|
GameObject.Destroy(itemPrefabList[index].gameObject);
|
|||
|
}
|
|||
|
itemPrefabList.Clear();
|
|||
|
}
|
|||
|
|
|||
|
//需要服务器同步当前双方戒指的等级
|
|||
|
public void InitRingItem(int manRingLevel, int felmaleRingLevel)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void OnWeedingItemClick(int weedingId)
|
|||
|
{
|
|||
|
curSelectedWeedingId = weedingId;
|
|||
|
for (int index = 0; index < itemPrefabList.Count; index++)
|
|||
|
{
|
|||
|
itemPrefabList[index].ShowMarkIcon(weedingId == itemPrefabList[index].weedingId);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnReqMarrybtnClick()
|
|||
|
{
|
|||
|
//判断当前的消耗
|
|||
|
Tab_WeedingConfig config = TableManager.GetWeedingConfigByID(curSelectedWeedingId, 0);
|
|||
|
if(config == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(config.ConsumeType == (int)CONSUM_TYPE.MONEY)
|
|||
|
{
|
|||
|
if(JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)config.ConsumeSubType, config.ConsumeValue))
|
|||
|
{
|
|||
|
|
|||
|
string consumeDesc = "";
|
|||
|
string weedingTyleDesc = "";
|
|||
|
for(int index = 0; index < itemPrefabList.Count; index++)
|
|||
|
{
|
|||
|
if(itemPrefabList[index].weedingId == curSelectedWeedingId)
|
|||
|
{
|
|||
|
consumeDesc = itemPrefabList[index].consumeDescAndValue.text;
|
|||
|
weedingTyleDesc = itemPrefabList[index].weedingName.text;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).IsValid())
|
|||
|
{
|
|||
|
//请求结婚
|
|||
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{46355}", consumeDesc, roleNameList[1].text, weedingTyleDesc), "", delegate ()
|
|||
|
{
|
|||
|
ReqMarry req = new ReqMarry();
|
|||
|
req.weddingType = curSelectedWeedingId;
|
|||
|
req.beMarriedGuid = -1;
|
|||
|
req.SendMsg();
|
|||
|
|
|||
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|||
|
OnCloseBtnClick();
|
|||
|
}, delegate ()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnCloseBtnClick()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.WeedingPanel);
|
|||
|
}
|
|||
|
}
|