237 lines
7.0 KiB
C#
237 lines
7.0 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using GCGame.Table;
|
||
using Games.Mission;
|
||
using Module.Log;
|
||
|
||
public class CrossServerCopyInfoCtr : MonoBehaviour {
|
||
|
||
public static CrossServerCopyInfoCtr Instance;
|
||
private void Awake()
|
||
{
|
||
Instance = this;
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
Instance = null;
|
||
}
|
||
|
||
public GameObject _ShowBtn;
|
||
public GameObject _HideBtn;
|
||
public UIContainerBase _RewContainer;
|
||
public Text _MissionInfoDesc;
|
||
public Text _MissionCountParam;
|
||
public Text _DailyReputation;
|
||
public Text _NpcName;
|
||
public GameObject _MissionPanel;
|
||
public GameObject _DailyMissionPanel;
|
||
public GameObject _CompleteMissionIcon;
|
||
public GameObject _RewPanel;
|
||
|
||
public GameObject _InfoPanel;
|
||
|
||
|
||
public int _MissionId = -1;
|
||
|
||
private void OnEnable()
|
||
{
|
||
OnShow();
|
||
if (ActivityDataManager.Instance.IsActivityState((int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_CROSSSERVERBOSS, ActivityDataManager.ActivityState.Playing))
|
||
{
|
||
gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
private SynCrossSerInfo _Packet;
|
||
public void OnPacket(SynCrossSerInfo packet)
|
||
{
|
||
_Packet = packet;
|
||
_MissionId = packet.killMissionid;
|
||
_DailyReputation.text = packet.todayscore + "/" + packet.totalscore;
|
||
if (_MissionId == -1)
|
||
{
|
||
_MissionPanel.SetActive(false);
|
||
InitRewAndNpcName();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
_MissionPanel.SetActive(true);
|
||
MissionOperation();
|
||
}
|
||
}
|
||
|
||
public void OnShop()
|
||
{
|
||
YuanBaoShopLogic.OpenShopForJiFenItem(10, -1);
|
||
//UIManager.ShowUI(UIInfo.YuanBaoShop, delegate(bool bSucess, object param) {
|
||
// if(bSucess)
|
||
// {
|
||
// YuanBaoShopLogic.OpenShopForJiFenItem(10, -1);
|
||
// }
|
||
//});
|
||
}
|
||
|
||
public void OnRule()
|
||
{
|
||
MessageHelpLogic.ShowHelpMessage(53);
|
||
}
|
||
|
||
public void OnExit()
|
||
{
|
||
//if (Singleton<ObjManager>.Instance.MainPlayer != null)
|
||
//{
|
||
// Singleton<ObjManager>.Instance.MainPlayer.AskLeaveCopy();
|
||
//}
|
||
|
||
var sceneInfo = TableManager.GetSceneClassByID(13, 0);
|
||
if (sceneInfo != null)
|
||
{
|
||
SceneData.RequestChangeScene((int)AutoSearchPoint.ChangeMap_Type.WORLDMAP, 0,13,
|
||
-1, (int)sceneInfo.SafeX, (int)sceneInfo.SafeZ);
|
||
}
|
||
}
|
||
|
||
public void OnShow()
|
||
{
|
||
_ShowBtn.SetActive(true);
|
||
_HideBtn.SetActive(false);
|
||
_InfoPanel.SetActive(true);
|
||
GCGame.Utils.HideMainTopRightUI();
|
||
}
|
||
|
||
public void OnHide()
|
||
{
|
||
_ShowBtn.SetActive(false);
|
||
_HideBtn.SetActive(true);
|
||
_InfoPanel.SetActive(false);
|
||
}
|
||
|
||
//不能每次同步声望的时候都刷新一次
|
||
private bool hasInitRew = false;
|
||
private const int _AcceptMissionNpcDataId = -1;
|
||
public void InitRewAndNpcName()
|
||
{
|
||
if (hasInitRew)
|
||
return;
|
||
|
||
//这边写死了一个接取护送任务的NPCID
|
||
Tab_RoleBaseAttr roleBaseAttr = null;
|
||
switch (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force)
|
||
{
|
||
case 6:
|
||
roleBaseAttr = TableManager.GetRoleBaseAttrByID(912, 0);
|
||
break;
|
||
case 7:
|
||
roleBaseAttr = TableManager.GetRoleBaseAttrByID(913, 0);
|
||
break;
|
||
case 27:
|
||
roleBaseAttr = TableManager.GetRoleBaseAttrByID(914, 0);
|
||
break;
|
||
}
|
||
if (roleBaseAttr != null)
|
||
{
|
||
_NpcName.text = roleBaseAttr.Name;
|
||
}
|
||
|
||
List<int> rewList = new List<int>();
|
||
for(int index = 0; index < _Packet.rewardItem.Count; index++)
|
||
{
|
||
rewList.Add(_Packet.rewardItem[index].awardSubType);
|
||
}
|
||
|
||
if (rewList.Count > 0)
|
||
{
|
||
_RewPanel.SetActive(true);
|
||
_RewContainer.InitContentItem(rewList);
|
||
}else
|
||
{
|
||
_RewPanel.SetActive(false);
|
||
}
|
||
|
||
hasInitRew = true;
|
||
RefreshMisisonCountParam();
|
||
}
|
||
|
||
public void RefreshMisisonCountParam()
|
||
{
|
||
Tab_ActivityBase tab = ActivityDataManager.Instance.GetActivityTabByID(29);
|
||
int complete = ActivityDataManager.Instance.GetActivityCompleteTimes((int)ActivityDataManager.Activity_Type.CROSS_SER_ESCORT);
|
||
if(tab!=null)
|
||
{
|
||
_MissionCountParam.text = string.Format("({0}/{1})", complete < 0 ? 0 : complete, tab.ActityLimitTimes);
|
||
}
|
||
|
||
|
||
//var activityBase = TableManager.GetActivityBaseByID(29, 0); //这边写死很蛋疼,跨服押镖有三个枚举,服务器说用30,但是表里面配的是31!
|
||
//if (GlobalData.ActivityCompletedCount.ContainsKey((int)ActivityDataManager.Activity_Type.CROSS_SER_ESCORT))
|
||
// _MissionCountParam.text = "(" + GlobalData.ActivityCompletedCount[(int)ActivityDataManager.Activity_Type.CROSS_SER_ESCORT] + "/" + activityBase.ActityLimitTimes + ")";
|
||
}
|
||
|
||
public void MissionOperation()
|
||
{
|
||
RefreshMisisonParam();
|
||
InitRewAndNpcName();
|
||
RefreshMissionState();
|
||
}
|
||
|
||
public void RefreshMisisonParam()
|
||
{
|
||
if (_MissionId == -1)
|
||
return;
|
||
|
||
var missionDIc = TableManager.GetMissionDictionaryByID(_MissionId, 0);
|
||
if (missionDIc == null)
|
||
return;
|
||
var param = GameManager.gameManager.MissionManager.GetMissionParam(_MissionId, 0);
|
||
_MissionInfoDesc.text = string.Format(missionDIc.GetFollowTextbyIndex(0), param); //只显示默认的第一个描述
|
||
}
|
||
|
||
public void OnNpcName()
|
||
{
|
||
var npcID = -1;
|
||
switch (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Force)
|
||
{
|
||
case 6:
|
||
npcID = 912;
|
||
break;
|
||
case 7:
|
||
npcID = 913;
|
||
break;
|
||
case 27:
|
||
npcID = 914;
|
||
break;
|
||
}
|
||
|
||
Tab_AutoSearch sceneNpc = TableManager.GetAutoSearchByID(npcID, 0);
|
||
if (sceneNpc == null)
|
||
return;
|
||
AutoSearchPoint point = new AutoSearchPoint(sceneNpc.DstSceneID, sceneNpc.X, sceneNpc.Z);
|
||
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
||
{
|
||
Tab_RoleBaseAttr role = TableManager.GetRoleBaseAttrByID(sceneNpc.DataId, 0);
|
||
GameManager.gameManager.AutoSearch.BuildPath(point);
|
||
if (role != null)
|
||
{
|
||
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = role.Name;
|
||
}
|
||
}
|
||
}
|
||
|
||
public void RefreshMissionState()
|
||
{
|
||
if (_CompleteMissionIcon != null)
|
||
_CompleteMissionIcon.SetActive(GameManager.gameManager.MissionManager.GetMissionState(_MissionId) == (int)MissionState.Mission_Completed);
|
||
}
|
||
|
||
public void OnMissionItem()
|
||
{
|
||
if (_MissionId == -1)
|
||
return;
|
||
GameManager.gameManager.MissionManager.MissionPathFinder(_MissionId);
|
||
}
|
||
}
|