237 lines
7.4 KiB
C#
237 lines
7.4 KiB
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
using System;
|
|||
|
using Games.GlobeDefine;
|
|||
|
|
|||
|
public class MarryPanelCtr : MonoBehaviour {
|
|||
|
|
|||
|
public static MarryPanelCtr Instance;
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
Instance = null;
|
|||
|
}
|
|||
|
|
|||
|
public enum CoupType
|
|||
|
{
|
|||
|
Husband = 1,
|
|||
|
Wife = 2,
|
|||
|
}
|
|||
|
|
|||
|
public GameObject marriedPanel;
|
|||
|
public GameObject noMarriedPanel;
|
|||
|
public List<UICameraTexture> modelCameraList;
|
|||
|
public List<Text> roleNameTextList;
|
|||
|
public Text marriedTime;
|
|||
|
public Text marryRuleText;
|
|||
|
public Text _MarryCoup;
|
|||
|
public Text _OperationBtnDesc;
|
|||
|
public Image roleHeadIcon;
|
|||
|
public void OnEnable()
|
|||
|
{
|
|||
|
ShowMarriedOrNoMarriedPanel();
|
|||
|
InitBtnDesc();
|
|||
|
}
|
|||
|
|
|||
|
void InitBtnDesc()
|
|||
|
{
|
|||
|
var str = StrDictionary.GetClientDictionaryString("#{86226}");
|
|||
|
if (_OperationBtnDesc.text.Equals(str))
|
|||
|
_OperationBtnDesc.text = str;
|
|||
|
}
|
|||
|
|
|||
|
public void ShowMarriedOrNoMarriedPanel()
|
|||
|
{
|
|||
|
if(IsMarried())
|
|||
|
{
|
|||
|
marriedPanel.SetActive(true);
|
|||
|
noMarriedPanel.SetActive(false);
|
|||
|
|
|||
|
//请求当前结婚的时间 显示对应的模型(需要知道对象的职业 或者服务器存的就是两个任务结婚时的CharModelId)
|
|||
|
ReqMarriedInfo();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
marriedPanel.SetActive(false);
|
|||
|
noMarriedPanel.SetActive(true);
|
|||
|
InitHeadIcon();
|
|||
|
InitMarryRuleTip();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//请求协议接口
|
|||
|
public void ReqMarriedInfo()
|
|||
|
{
|
|||
|
ReqMarryDetailData req = new ReqMarryDetailData();
|
|||
|
req.flag = 1;
|
|||
|
req.SendMsg();
|
|||
|
}
|
|||
|
|
|||
|
//协议返回(如果是显示的结婚礼服那么服务器最好保存的是CharModelId)
|
|||
|
private List<int> professionList;
|
|||
|
private List<string> nameList;
|
|||
|
public void OnReceivePacket(RetMarryDetailData packet)
|
|||
|
{
|
|||
|
_MarryCoup.text = StrDictionary.GetClientDictionaryString("#{47205}", packet.marryTotal);
|
|||
|
professionList = new List<int>();
|
|||
|
nameList = new List<string>();
|
|||
|
if (GameManager.gameManager.PlayerDataPool.IsMarried)
|
|||
|
{
|
|||
|
GameManager.gameManager.PlayerDataPool.MyRingInfoData.SetLoverName(packet.name);
|
|||
|
}
|
|||
|
if (packet.huabandWifeFlag == (int)CoupType.Husband)
|
|||
|
{
|
|||
|
professionList.Add(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession);
|
|||
|
nameList.Add(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName);
|
|||
|
professionList.Add(packet.loverCareer);
|
|||
|
nameList.Add(packet.name);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
professionList.Add(packet.loverCareer);
|
|||
|
nameList.Add(packet.name);
|
|||
|
professionList.Add(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession);
|
|||
|
nameList.Add(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName);
|
|||
|
}
|
|||
|
|
|||
|
//显示模型 时间
|
|||
|
SetMarryTime(packet.marryTm);
|
|||
|
InitCharModelAndName(packet.marryType);
|
|||
|
}
|
|||
|
|
|||
|
public void InitCharModelAndName(int weedingType)
|
|||
|
{
|
|||
|
Tab_WeedingConfig config = TableManager.GetWeedingConfigByID(weedingType, 0);
|
|||
|
if(config == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Tab_FashionItem fashionItemTab = TableManager.GetFashionItemByID(config.GainFashionId, 0);
|
|||
|
if(fashionItemTab == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Tab_ItemVisual itemVisual = TableManager.GetItemVisualByID(fashionItemTab.ItemVisualId, 0);
|
|||
|
if(itemVisual == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
int charModelId = -1;
|
|||
|
for(int index = 0; index < professionList.Count; index++)
|
|||
|
{
|
|||
|
switch (professionList[index])
|
|||
|
{
|
|||
|
case (int)CharacterDefine.PROFESSION.XUANNV:
|
|||
|
charModelId = itemVisual.CharModelIDXiaoYao;
|
|||
|
break;
|
|||
|
case (int)CharacterDefine.PROFESSION.LIUSHAN:
|
|||
|
charModelId = itemVisual.CharModelIDTianShan;
|
|||
|
break;
|
|||
|
case (int)CharacterDefine.PROFESSION.SHUSHAN:
|
|||
|
charModelId = itemVisual.CharModelIDDaLi;
|
|||
|
break;
|
|||
|
case (int)CharacterDefine.PROFESSION.TIANJI:
|
|||
|
charModelId = itemVisual.CharModelIDShaoLin;
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
if(charModelId == -1)
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
modelCameraList[index].InitModel(professionList[index], charModelId);
|
|||
|
roleNameTextList[index].text = nameList[index];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SetMarryTime(long time)
|
|||
|
{
|
|||
|
System.DateTime startTime = new System.DateTime(1970, 1, 1).ToLocalTime();
|
|||
|
System.DateTime curTime = startTime.AddSeconds(time);
|
|||
|
marriedTime.text = StrDictionary.GetClientDictionaryString("#{25123}", curTime.Year, curTime.Month, curTime.Day);
|
|||
|
}
|
|||
|
|
|||
|
public bool IsMarried()
|
|||
|
{
|
|||
|
return GameManager.gameManager.PlayerDataPool.IsMarried;
|
|||
|
}
|
|||
|
|
|||
|
public void InitMarryRuleTip()
|
|||
|
{
|
|||
|
marryRuleText.text = StrDictionary.GetClientDictionaryString("#{47011}");
|
|||
|
}
|
|||
|
|
|||
|
public void InitHeadIcon()
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(roleHeadIcon, Utils.GetProfessionSpriteName(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession));
|
|||
|
}
|
|||
|
|
|||
|
private const int marryNpcAutosearchId = 9008;
|
|||
|
public void OnGotoMarryBtnClick()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.m_RunningScene == 658)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
//UIManager.ShowUI(UIInfo.WeddingOperationPanel);
|
|||
|
Tab_AutoSearch autoSearch = TableManager.GetAutoSearchByID(marryNpcAutosearchId, 0);
|
|||
|
if (autoSearch == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Vector3 pos = new Vector3();
|
|||
|
pos.x = autoSearch.X;
|
|||
|
pos.z = autoSearch.Z;
|
|||
|
int sceneId = autoSearch.DstSceneID;
|
|||
|
AutoSearchPoint targetPoint = new AutoSearchPoint(sceneId, pos.x, pos.z);
|
|||
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|||
|
{
|
|||
|
GameManager.gameManager.AutoSearch.BuildPath(targetPoint);
|
|||
|
Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(autoSearch.DataId, 0);
|
|||
|
if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path)
|
|||
|
{
|
|||
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name;
|
|||
|
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius;
|
|||
|
}
|
|||
|
}
|
|||
|
CloseCurPanel();
|
|||
|
}
|
|||
|
|
|||
|
public void CloseCurPanel()
|
|||
|
{
|
|||
|
MarryRoot.Instance.OnCloseBtnClick();
|
|||
|
}
|
|||
|
|
|||
|
public void PlayWeddingMovie()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.m_RunningScene == 658)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
const string movieName = "/Audio/3333.mp4";
|
|||
|
if (MarryMovieCtr.Instance)
|
|||
|
{
|
|||
|
MarryMovieCtr.Instance.PlayMovie(movieName);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
UIManager.ShowUI(UIInfo.MarryMovieCtr, (sucess, param) =>
|
|||
|
{
|
|||
|
MarryMovieCtr.Instance.PlayMovie(movieName);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|