137 lines
4.6 KiB
C#
137 lines
4.6 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using GCGame.Table;
|
|
using System.Collections.Generic;
|
|
|
|
public class DivorcePanelCtr : MonoBehaviour {
|
|
|
|
public static DivorcePanelCtr Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
CreateItemPrefab();
|
|
}
|
|
|
|
public GameObject itemPrafab;
|
|
public Transform itemPrefabParent;
|
|
|
|
private List<DivorceItem> itemPrefabList = new List<DivorceItem>();
|
|
public void CreateItemPrefab()
|
|
{
|
|
var allConfig = TableManager.GetWeedingConfig().Values;
|
|
ClearAllItemPrefab();
|
|
foreach (var config in allConfig)
|
|
{
|
|
if(config.MarryType == 1)
|
|
{
|
|
GameObject item = GameObject.Instantiate(itemPrafab);
|
|
|
|
item.transform.SetParent(itemPrefabParent);
|
|
item.transform.localPosition = Vector3.zero;
|
|
item.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|
item.transform.localScale = Vector3.one;
|
|
|
|
item.GetComponent<DivorceItem>().InitItem(config.Id);
|
|
itemPrefabList.Add(item.GetComponent<DivorceItem>());
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ClearAllItemPrefab()
|
|
{
|
|
for (int index = 0; index < itemPrefabList.Count; index++)
|
|
{
|
|
GameObject.Destroy(itemPrefabList[index].gameObject);
|
|
}
|
|
itemPrefabList.Clear();
|
|
}
|
|
|
|
private int curSelectDivorceItemId;
|
|
public void OnDivorceItemClick(int divorceItemId)
|
|
{
|
|
curSelectDivorceItemId = divorceItemId;
|
|
ReqDivoce req = new ReqDivoce();
|
|
switch (divorceItemId)
|
|
{
|
|
case 4:
|
|
//判断消耗
|
|
{
|
|
string consumeDesc = "";
|
|
Tab_WeedingConfig config = TableManager.GetWeedingConfigByID(divorceItemId, 0);
|
|
if(config != null)
|
|
{
|
|
consumeDesc = config.ConsumeValue + PlayerData.MONEY.GetMoneyStr((MONEYTYPE)config.ConsumeSubType);
|
|
if (JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)config.ConsumeSubType, config.ConsumeValue))
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{47003}", consumeDesc,
|
|
GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).MemberName),
|
|
"", delegate() {
|
|
req.guid = -1;
|
|
req.divoceType = divorceItemId;
|
|
req.SendMsg();
|
|
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}, delegate() {
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 5:
|
|
//不是队长
|
|
if (!GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
|
|
{
|
|
GUIData.AddNotifyData("#{7005}");
|
|
return;
|
|
}
|
|
|
|
//没带老婆
|
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() != 2)
|
|
{
|
|
GUIData.AddNotifyData("#{47000}");
|
|
return;
|
|
}
|
|
|
|
//老婆离队
|
|
if (!GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).FollowLeader())
|
|
{
|
|
GUIData.AddNotifyData("#{47001}");
|
|
return;
|
|
}
|
|
|
|
if(GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).IsValid())
|
|
{
|
|
req.guid = (long)GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).Guid;
|
|
req.divoceType = divorceItemId;
|
|
req.SendMsg();
|
|
}else
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{47000}"));
|
|
return;
|
|
}
|
|
break;
|
|
case 6:
|
|
req.guid = (long)GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMember(1).Guid;
|
|
req.divoceType = divorceItemId;
|
|
req.SendMsg();
|
|
break;
|
|
}
|
|
OnCloseBtnClick();
|
|
}
|
|
|
|
public void OnCloseBtnClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.DivorcePanel);
|
|
}
|
|
}
|