1417 lines
53 KiB
C#
1417 lines
53 KiB
C#
using UnityEngine;
|
||
using System.Collections;
|
||
using GCGame;
|
||
using System.Collections.Generic;
|
||
using Games.GlobeDefine;
|
||
using Games.UserCommonData;
|
||
using GCGame.Table;
|
||
using System;
|
||
using UnityEngine.UI;
|
||
using Games.Mission;
|
||
using Module.Log;
|
||
|
||
public class ActivityController : UIControllerBase<ActivityController>
|
||
{
|
||
#region static
|
||
|
||
public static void ShowUI()
|
||
{
|
||
UIManager.ShowUI(UIInfo.Activity);
|
||
}
|
||
|
||
#endregion
|
||
|
||
void Awake()
|
||
{
|
||
InitValRewContainer();
|
||
}
|
||
|
||
void InitValRewContainer()
|
||
{
|
||
StartCoroutine(CreateValRew());
|
||
}
|
||
|
||
void ReqValRewStateAndDailyVal()
|
||
{
|
||
ReqDailyActValInfo req = new ReqDailyActValInfo();
|
||
req.flag = 1;
|
||
req.SendMsg();
|
||
}
|
||
|
||
public void OnValPacket(RetDailyActValInfo packet)
|
||
{
|
||
for(int index = 0; index < _ValRewItemList.Count && index < packet.rewardList.Count; index++)
|
||
{
|
||
_ValRewItemList[index].RefreshItemState(packet.rewardList[index]);
|
||
}
|
||
|
||
InitMyActivitiesness();
|
||
}
|
||
|
||
public GameObject _ValRewItemPrefab;
|
||
public Transform _ValRewItemParent;
|
||
private List<ActivityalRewItem> _ValRewItemList = new List<ActivityalRewItem>();
|
||
IEnumerator CreateValRew()
|
||
{
|
||
List<int> valRewIdList = new List<int>();
|
||
var ValRewDic = TableManager.GetActivityValRew();
|
||
foreach (var tab in ValRewDic)
|
||
{
|
||
if (!valRewIdList.Contains(tab.Key))
|
||
valRewIdList.Add(tab.Key);
|
||
}
|
||
|
||
var needCreateCount = valRewIdList.Count - _ValRewItemList.Count;
|
||
for(int index = 0; index < needCreateCount; index++)
|
||
{
|
||
GameObject item = Instantiate(_ValRewItemPrefab) as GameObject;
|
||
|
||
item.transform.SetParent(_ValRewItemParent);
|
||
|
||
item.transform.localScale = Vector3.one;
|
||
item.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
||
item.transform.localPosition = Vector3.zero;
|
||
|
||
_ValRewItemList.Add(item.GetComponent<ActivityalRewItem>());
|
||
}
|
||
|
||
var Slidewidth = m_Slider.gameObject.GetComponent<RectTransform>().sizeDelta.x;
|
||
for (int index = 0; index < _ValRewItemList.Count; index++)
|
||
_ValRewItemList[index].InitItem(valRewIdList[index], Slidewidth);
|
||
|
||
//在创建完的时候再同步一次协议,防止OnEnable的时候这边还没有创建完
|
||
ReqValRewStateAndDailyVal();
|
||
|
||
yield break;
|
||
}
|
||
|
||
private static int _MaxActivityVal = -1;
|
||
public static int GetCurLevelMaxVal()
|
||
{
|
||
if (_MaxActivityVal != -1)
|
||
return _MaxActivityVal;
|
||
|
||
var level = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
||
var valTab = TableManager.GetActValLimitByID(level, 0);
|
||
if (valTab != null)
|
||
_MaxActivityVal = valTab.ActValLimit;
|
||
return _MaxActivityVal;
|
||
}
|
||
|
||
void OnEnable()
|
||
{
|
||
preLoadAllActivities();
|
||
//ReqSyncServerTime();
|
||
SetInstance(this);
|
||
InitMyActivitiesness();
|
||
OnToggleOn(0);
|
||
ReqActivityHeadExp();
|
||
ReqValRewStateAndDailyVal();
|
||
}
|
||
|
||
public static void Show(Acticity_Type actType)
|
||
{
|
||
UIManager.ShowUI(UIInfo.Activity,
|
||
(bool isSuccess, object param) =>
|
||
{
|
||
if(isSuccess)
|
||
{
|
||
ActivityController.Instance().OnToggleOn((int)actType);
|
||
}
|
||
});
|
||
}
|
||
|
||
public void ReqActivityHeadExp()
|
||
{
|
||
CG_REQ_ACTIVITY_HEAD_EXP_LIST req = (CG_REQ_ACTIVITY_HEAD_EXP_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ACTIVITY_HEAD_EXP_LIST);
|
||
req.Nilparam = 1;
|
||
req.SendPacket();
|
||
}
|
||
|
||
public void ReqSyncServerTime()
|
||
{
|
||
var cgBeat = (CG_CONNECTED_HEARTBEAT)PacketDistributed.CreatePacket(MessageID.PACKET_CG_CONNECTED_HEARTBEAT);
|
||
cgBeat.SetIsresponse(1);
|
||
cgBeat.SendPacket();
|
||
}
|
||
|
||
void OnDisable()
|
||
{
|
||
SetInstance(null);
|
||
_isNeedPosActItemId = -1;
|
||
}
|
||
|
||
public void CloseWindow()
|
||
{
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
}
|
||
|
||
|
||
public enum Acticity_Type
|
||
{
|
||
ACTIVITY_INVALID = -1,
|
||
ACTIVITY_DAILY = 0, //全部任务
|
||
ACTIVITY_LIMITTIME= 1, //限时
|
||
ACTIVITY_EXP = 2, //经验
|
||
ACTIVITY_EQUIP = 4, //装备
|
||
ACTIVITY_TRIBUTE = 8, //帮贡
|
||
}
|
||
|
||
public List<GameObject> _MenuMarkobjList;
|
||
public int m_TotalActicitiesTypeCount = 4; //活动所拥有的类型 日常为全部活动
|
||
|
||
//分类过的活动 此int为活动类型
|
||
private List<int> m_SortAllActivities = new List<int>();
|
||
|
||
//分类后的活动 存储的是任务ID
|
||
public Dictionary<Acticity_Type, List<int>> AllTypeActivityDic = new Dictionary<Acticity_Type, List<int>>();
|
||
private List<int> DailyMissionList = new List<int>(); // 日常活动
|
||
private List<int> ExpMissionList = new List<int>(); // 经验任务
|
||
private List<int> LimitTimeMissionList = new List<int>(); // 限时活动
|
||
private List<int> EquipMissionList = new List<int>(); // 装备任务
|
||
private List<int> TributeMissionList = new List<int>(); // 帮贡任务
|
||
|
||
//最后一次选择的活动类型下标
|
||
public int m_SelectedIndex = -1;
|
||
|
||
public UIContainerSelect _ItemsContainer;
|
||
|
||
//周历
|
||
public GameObject m_ActivitiesInTimePage;
|
||
public List<GameObject> _MenuItemRedIconList;
|
||
|
||
public void ClearAllList()
|
||
{
|
||
//if (MissionDic.Count > 0)
|
||
//{
|
||
// MissionDic.Clear();
|
||
//}
|
||
|
||
if (DailyMissionList.Count > 0)
|
||
{
|
||
DailyMissionList.Clear();
|
||
}
|
||
if (LimitTimeMissionList.Count > 0)
|
||
{
|
||
LimitTimeMissionList.Clear();
|
||
}
|
||
if (ExpMissionList.Count > 0)
|
||
{
|
||
ExpMissionList.Clear();
|
||
}
|
||
|
||
if (EquipMissionList.Count > 0)
|
||
{
|
||
EquipMissionList.Clear();
|
||
}
|
||
if (TributeMissionList.Count > 0)
|
||
{
|
||
TributeMissionList.Clear();
|
||
}
|
||
|
||
if (m_SortAllActivities.Count > 0)
|
||
{
|
||
m_SortAllActivities.Clear();
|
||
}
|
||
}
|
||
|
||
//活力值
|
||
public Text m_ActivitiesNessText;
|
||
public Slider m_Slider;
|
||
private int _MaxDailyVal = -1;
|
||
public void InitMyActivitiesness()
|
||
{
|
||
int m_ActValue = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.DailyActivityVal; //获取服务器同步的角色活力值
|
||
if(_MaxDailyVal == -1)
|
||
{
|
||
foreach (var tab in TableManager.GetActivityValRew())
|
||
if (_MaxDailyVal < tab.Key)
|
||
_MaxDailyVal = tab.Key;
|
||
}
|
||
|
||
m_ActivitiesNessText.text = StrDictionary.GetClientDictionaryString("#{3139}", m_ActValue, _MaxDailyVal); //m_ActValue + "/" + m_LimitVal;
|
||
|
||
//设置Progress的进度
|
||
m_Slider.value = (float)m_ActValue / (float)_MaxDailyVal;
|
||
}
|
||
|
||
|
||
IEnumerator SortActicitiesByType() //筛选今天可以参加的活动
|
||
{
|
||
yield return new WaitForEndOfFrame();
|
||
//分类之前先进行清除
|
||
ClearAllList();
|
||
foreach (var m_Activity in TableManager.GetActivityBase().Values)
|
||
{
|
||
if (m_Activity.IsShow != 1)
|
||
continue;
|
||
|
||
int m_ActivityType = m_Activity.ActivityType;
|
||
if (IsTodayOpen(m_Activity.Id))
|
||
{
|
||
var activityBase = TableManager.GetActivityBaseByID(m_Activity.Id, 0);
|
||
if(activityBase != null && activityBase.ActivityType != 1)
|
||
DailyMissionList.Add(m_Activity.Id); //日常活动存储全部的活动(在周期内的活动)
|
||
}
|
||
//位运算 判断属于哪种类型
|
||
for(int index = 0; index < m_TotalActicitiesTypeCount; index++)
|
||
{
|
||
int m_Type = (int)Math.Pow(2, index);
|
||
if((m_ActivityType & m_Type) != 0)
|
||
{
|
||
if (IsTodayOpen(m_Activity.Id)) //在开启周期内
|
||
{
|
||
if (m_Type == (int)Acticity_Type.ACTIVITY_EXP)
|
||
{
|
||
ExpMissionList.Add(m_Activity.Id);
|
||
}
|
||
if (m_Type == (int)Acticity_Type.ACTIVITY_LIMITTIME)
|
||
{
|
||
LimitTimeMissionList.Add(m_Activity.Id);
|
||
}
|
||
if (m_Type == (int)Acticity_Type.ACTIVITY_EQUIP)
|
||
{
|
||
EquipMissionList.Add(m_Activity.Id);
|
||
}
|
||
if (m_Type == (int)Acticity_Type.ACTIVITY_TRIBUTE)
|
||
{
|
||
TributeMissionList.Add(m_Activity.Id);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
DailyMissionList = SetMyActivityState(DailyMissionList);
|
||
ExpMissionList = SetMyActivityState(ExpMissionList);
|
||
LimitTimeMissionList = SetMyActivityState(LimitTimeMissionList);
|
||
EquipMissionList = SetMyActivityState(EquipMissionList);
|
||
TributeMissionList = SetMyActivityState(TributeMissionList);
|
||
|
||
////初始化全部的活动按钮
|
||
//yield return StartCoroutine(InitMyActivityItemByType(Acticity_Type.ACTIVITY_DAILY));
|
||
OnToggleOn(0);
|
||
yield break;
|
||
}
|
||
|
||
public bool IsUnLimitActivity(int actId)
|
||
{
|
||
var activityBase = TableManager.GetActivityBaseByID(actId, 0);
|
||
if (activityBase == null)
|
||
return false;
|
||
|
||
if (activityBase.ActityLimitTimes == -1)
|
||
return true;
|
||
|
||
return false;
|
||
}
|
||
|
||
public void RefreshMenuItemRedIconState()
|
||
{
|
||
bool limitShow = false;
|
||
for(int index = 0; index < LimitTimeMissionList.Count; index++)
|
||
{
|
||
if(IsOnOpenAndCanJoin(LimitTimeMissionList[index]) && !IsUnLimitActivity(LimitTimeMissionList[index]))
|
||
{
|
||
var activityBase = TableManager.GetActivityBaseByID(LimitTimeMissionList[index], 0);
|
||
if (activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDFREIGHT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_FEAST
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_ESCORT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_DRAGONWAR
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUIDBOSS
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild())
|
||
{
|
||
limitShow = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
limitShow = true;
|
||
}
|
||
if(limitShow)
|
||
break;
|
||
}
|
||
}
|
||
_MenuItemRedIconList[1].SetActive(limitShow);
|
||
|
||
bool equipShow = false;
|
||
for (int index = 0; index < ExpMissionList.Count; index++)
|
||
{
|
||
if (IsOnOpenAndCanJoin(ExpMissionList[index]) && !IsUnLimitActivity(LimitTimeMissionList[index]))
|
||
{
|
||
var activityBase = TableManager.GetActivityBaseByID(ExpMissionList[index], 0);
|
||
if (activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDFREIGHT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_FEAST
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_ESCORT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_DRAGONWAR
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUIDBOSS
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild())
|
||
{
|
||
equipShow = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
equipShow = true;
|
||
}
|
||
if(equipShow)
|
||
break;
|
||
}
|
||
}
|
||
_MenuItemRedIconList[2].SetActive(equipShow);
|
||
|
||
bool expShow = false;
|
||
for (int index = 0; index < EquipMissionList.Count; index++)
|
||
{
|
||
if (IsOnOpenAndCanJoin(EquipMissionList[index]) && !IsUnLimitActivity(LimitTimeMissionList[index]))
|
||
{
|
||
var activityBase = TableManager.GetActivityBaseByID(EquipMissionList[index], 0);
|
||
if (activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDFREIGHT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_FEAST
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_ESCORT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_DRAGONWAR
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUIDBOSS
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild())
|
||
{
|
||
expShow = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
expShow = true;
|
||
}
|
||
if(expShow)
|
||
break;
|
||
}
|
||
}
|
||
_MenuItemRedIconList[3].SetActive(expShow);
|
||
|
||
bool tributeShow = false;
|
||
for (int index = 0; index < TributeMissionList.Count; index++)
|
||
{
|
||
if (IsOnOpenAndCanJoin(TributeMissionList[index]) && !IsUnLimitActivity(LimitTimeMissionList[index]))
|
||
{
|
||
var activityBase = TableManager.GetActivityBaseByID(TributeMissionList[index], 0);
|
||
if (activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDFREIGHT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_FEAST
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_ESCORT
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_DRAGONWAR
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUIDBOSS
|
||
|| activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild())
|
||
{
|
||
tributeShow = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
tributeShow = true;
|
||
}
|
||
if(tributeShow)
|
||
break;
|
||
}
|
||
}
|
||
_MenuItemRedIconList[4].SetActive(tributeShow);
|
||
|
||
_MenuItemRedIconList[0].SetActive(limitShow || expShow || equipShow || tributeShow);
|
||
}
|
||
|
||
//今天是否开启该任务
|
||
public static bool IsTodayOpen(int m_ItemInfoId)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(m_ItemInfoId, 0);
|
||
if (activityBase == null)
|
||
return false;
|
||
|
||
int m_ServerTime = GlobalData.ServerAnsiTime;
|
||
DateTime dt = GCGame.Utils.GetServerDateTime();
|
||
|
||
int m_OnTime = (int)dt.DayOfWeek;
|
||
|
||
string[] m_TabOnTime = activityBase.Recurrent.Split('|');
|
||
for(int index = 0; index < m_TabOnTime.Length; index++)
|
||
{
|
||
if(m_OnTime == int.Parse(m_TabOnTime[index]))
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 通过类型获取活动的数量
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
/// <returns></returns>
|
||
public int GetActivitiesCountByType(int type)
|
||
{
|
||
//获取之前先排序吧
|
||
//SortActicitiesByType();
|
||
|
||
int m_Count = 0;
|
||
int m_Type = (int)Math.Pow(2, type - 1);
|
||
switch(m_Type)
|
||
{
|
||
case (int)Acticity_Type.ACTIVITY_DAILY:
|
||
if(DailyMissionList == null)
|
||
{
|
||
m_Count = -1;
|
||
break;
|
||
}
|
||
m_Count = DailyMissionList.Count;
|
||
break;
|
||
|
||
case (int)Acticity_Type.ACTIVITY_EXP:
|
||
if (ExpMissionList == null)
|
||
{
|
||
m_Count = -1;
|
||
break;
|
||
}
|
||
m_Count = ExpMissionList.Count;
|
||
break;
|
||
|
||
case (int)Acticity_Type.ACTIVITY_LIMITTIME:
|
||
if (LimitTimeMissionList == null)
|
||
{
|
||
m_Count = -1;
|
||
break;
|
||
}
|
||
m_Count = LimitTimeMissionList.Count;
|
||
break;
|
||
|
||
case (int)Acticity_Type.ACTIVITY_EQUIP:
|
||
if (EquipMissionList == null)
|
||
{
|
||
m_Count = -1;
|
||
break;
|
||
}
|
||
m_Count = EquipMissionList.Count;
|
||
break;
|
||
|
||
case (int)Acticity_Type.ACTIVITY_TRIBUTE:
|
||
if (TributeMissionList == null)
|
||
{
|
||
m_Count = -1;
|
||
break;
|
||
}
|
||
m_Count = TributeMissionList.Count;
|
||
break;
|
||
default:
|
||
m_Count = 0;
|
||
break;
|
||
}
|
||
return m_Count;
|
||
}
|
||
|
||
public void preLoadAllActivities()
|
||
{
|
||
//分类活动类型
|
||
StartCoroutine(SortActicitiesByType());
|
||
}
|
||
|
||
/// <summary>
|
||
/// 通过活动的类型来初始化对应活动界面
|
||
/// </summary>
|
||
/// <param name="m_ActivityType"></param>
|
||
IEnumerator InitMyActivityItemByType(Acticity_Type m_ActivityType)
|
||
{
|
||
yield return new WaitForEndOfFrame();
|
||
switch(m_ActivityType)
|
||
{
|
||
case Acticity_Type.ACTIVITY_DAILY:
|
||
_ItemsContainer.InitSelectContent(DailyMissionList, null);
|
||
break;
|
||
case Acticity_Type.ACTIVITY_EXP:
|
||
_ItemsContainer.InitSelectContent(ExpMissionList, null);
|
||
break;
|
||
case Acticity_Type.ACTIVITY_EQUIP:
|
||
_ItemsContainer.InitSelectContent(EquipMissionList, null);
|
||
break;
|
||
case Acticity_Type.ACTIVITY_LIMITTIME:
|
||
_ItemsContainer.InitSelectContent(LimitTimeMissionList, null);
|
||
break;
|
||
case Acticity_Type.ACTIVITY_TRIBUTE:
|
||
_ItemsContainer.InitSelectContent(TributeMissionList, null);
|
||
break;
|
||
default:
|
||
_ItemsContainer.InitSelectContent(null, null);
|
||
break;
|
||
}
|
||
ShowItemByActId(_isNeedPosActItemId);
|
||
|
||
yield break;
|
||
}
|
||
|
||
public Acticity_Type GetActivitiesTypeByIndex(int index)
|
||
{
|
||
if(index == 0)
|
||
{
|
||
return Acticity_Type.ACTIVITY_DAILY;
|
||
}
|
||
int m_Type = (int)Math.Pow(2, index - 1);
|
||
switch(m_Type)
|
||
{
|
||
case (int)Acticity_Type.ACTIVITY_EXP:
|
||
return Acticity_Type.ACTIVITY_EXP;
|
||
case (int)Acticity_Type.ACTIVITY_EQUIP:
|
||
return Acticity_Type.ACTIVITY_EQUIP;
|
||
case (int)Acticity_Type.ACTIVITY_LIMITTIME:
|
||
return Acticity_Type.ACTIVITY_LIMITTIME;
|
||
case (int)Acticity_Type.ACTIVITY_TRIBUTE:
|
||
return Acticity_Type.ACTIVITY_TRIBUTE;
|
||
default:
|
||
return Acticity_Type.ACTIVITY_INVALID;
|
||
}
|
||
}
|
||
|
||
//tag
|
||
public void OnToggleOn(int index)
|
||
{
|
||
for(int _Index = 0; _Index < _MenuMarkobjList.Count; _Index++)
|
||
{
|
||
_MenuMarkobjList[_Index].SetActive(index == _Index);
|
||
}
|
||
if (m_SelectedIndex != index)
|
||
_isNeedPosActItemId = -1;
|
||
m_SelectedIndex = index;
|
||
SortActivityList(m_SelectedIndex);
|
||
StartCoroutine(InitMyActivityItemByType(GetActivitiesTypeByIndex(index)));
|
||
RefreshMenuItemRedIconState();
|
||
}
|
||
|
||
public void RefreshActvityItemState()
|
||
{
|
||
SortActivityList(m_SelectedIndex);
|
||
StartCoroutine(InitMyActivityItemByType(GetActivitiesTypeByIndex(m_SelectedIndex)));
|
||
RefreshMenuItemRedIconState();
|
||
}
|
||
|
||
public void SortActivityList(int index)
|
||
{
|
||
switch((int)GetActivitiesTypeByIndex(index))
|
||
{
|
||
case (int)Acticity_Type.ACTIVITY_DAILY:
|
||
SetMyActivityState(DailyMissionList);
|
||
break;
|
||
case (int)Acticity_Type.ACTIVITY_EXP:
|
||
SetMyActivityState(ExpMissionList);
|
||
break;
|
||
case (int)Acticity_Type.ACTIVITY_EQUIP:
|
||
SetMyActivityState(EquipMissionList);
|
||
break;
|
||
case (int)Acticity_Type.ACTIVITY_LIMITTIME:
|
||
SetMyActivityState(LimitTimeMissionList);
|
||
break;
|
||
case (int)Acticity_Type.ACTIVITY_TRIBUTE:
|
||
SetMyActivityState(TributeMissionList);
|
||
break;
|
||
}
|
||
}
|
||
|
||
//打开周历
|
||
public void myWeekButtonClick()
|
||
{
|
||
m_ActivitiesInTimePage.SetActive(true);
|
||
}
|
||
|
||
#region 获取时间状态
|
||
public enum ActivityTimeType
|
||
{
|
||
WillOpen = 0, //将要开启 还未结束
|
||
IsGoing = 1, //正在进行
|
||
Finish = 2, //已结束
|
||
WillOpenButShow = 3, //配置需求显示,实际未到时间
|
||
}
|
||
public static int GetActivityTimeState(int m_AcId)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(m_AcId, 0);
|
||
if (activityBase == null)
|
||
return -1;
|
||
|
||
int activityOpenTime = 0;
|
||
int activityEndTime = 0;
|
||
|
||
DateTime dt = Utils.GetServerDateTime();
|
||
//获取服务器的小时 分钟
|
||
int hour = dt.Hour;
|
||
int minute = dt.Minute;
|
||
int currentServerTimeToTabTime = hour * 100 + minute; //例如:2200 2100
|
||
|
||
int maxEndTime = 0; //记录最大时间(超过最大时间则是已结束)
|
||
|
||
//获得最后一次结束时间
|
||
for (int index = 0; index < activityBase.getTimeCount(); index++)
|
||
{
|
||
if (!activityBase.GetTimebyIndex(index).Equals("-1"))
|
||
{
|
||
activityOpenTime = int.Parse(activityBase.GetTimebyIndex(index).Split('|')[0]);
|
||
activityEndTime = int.Parse(activityBase.GetTimebyIndex(index).Split('|')[1]);
|
||
|
||
if (activityEndTime > maxEndTime)
|
||
{
|
||
maxEndTime = activityEndTime;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
if (ActivityDataManager.Instance.IsActivityState(activityBase.ActivityServerType, ActivityDataManager.ActivityState.Playing))
|
||
return (int)ActivityTimeType.IsGoing;
|
||
|
||
if (currentServerTimeToTabTime >= maxEndTime)
|
||
{
|
||
return (int)ActivityTimeType.Finish; //活动已结束
|
||
}else
|
||
{
|
||
if(currentServerTimeToTabTime >= activityOpenTime && activityBase.IsOpenWhenWaiting == 1)
|
||
{
|
||
if((activityBase.ActivityType & 1) == 1) //限时活动
|
||
return (int)ActivityTimeType.WillOpenButShow;
|
||
else
|
||
return (int)ActivityTimeType.IsGoing;
|
||
}
|
||
else
|
||
{
|
||
return (int)ActivityTimeType.WillOpen; //活动未开启
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
public static bool IsLevelEnough(int activityId)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(activityId, 0);
|
||
if (activityBase == null)
|
||
{
|
||
return false;
|
||
}
|
||
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level >= activityBase.Level)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public static bool IsOnOpenTime(int activityId)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(activityId, 0);
|
||
if (activityBase == null)
|
||
return false;
|
||
|
||
if (GetActivityTimeState(activityId) == 1)
|
||
return true;
|
||
else
|
||
return false;
|
||
}
|
||
|
||
public static bool IsCompleted(int activityId)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(activityId, 0);
|
||
if (activityBase == null)
|
||
return false;
|
||
|
||
if (activityBase.ActityLimitTimes == -1)
|
||
return false;
|
||
|
||
if (activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_EXERCISEROOM)
|
||
return ActivityDataManager.Instance.GetActivityCompleteTimes(activityBase.ActivityServerType) <= 0;
|
||
|
||
var complete = ActivityDataManager.Instance.GetActivityCompleteTimes(activityBase.ActivityServerType);
|
||
return complete >= 0 && complete >= activityBase.ActityLimitTimes;
|
||
|
||
}
|
||
|
||
public static void ClickActive(int activityID)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(activityID, 0);
|
||
if (activityBase == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
|
||
string parameter = activityBase.Parameter;
|
||
int m_ParamType = activityBase.ParameterType;
|
||
var _serverType = activityBase.ActivityServerType;
|
||
|
||
//副本中屏蔽点击
|
||
Tab_SceneClass sceneClass = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene, 0);
|
||
if (sceneClass != null && m_ParamType != (int)ActivityItem.Parameter_type.OPENUI)
|
||
{
|
||
if (sceneClass.Type == 2 && GameManager.gameManager.RunningScene != (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUILD) //副本
|
||
{
|
||
//副本中屏蔽点击
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46208}"));
|
||
return;
|
||
}
|
||
}
|
||
|
||
|
||
//点击的时候再做一次时间判断
|
||
if (ActivityController.Instance())
|
||
{
|
||
if (ActivityController.Instance().IsLimitMission(activityBase))
|
||
{
|
||
if (ActivityController.Instance().IsFinish(activityID)
|
||
/*|| (GlobalData.ActivityStateDic.ContainsKey(activityBase.ActivityServerType)) && GlobalData.ActivityStateDic[activityBase.ActivityServerType] == 0*/) //活动已经结束
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_TREASURE_GLOD)
|
||
{
|
||
CG_TREASURE_GOLD_OPTION send = (CG_TREASURE_GOLD_OPTION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_TREASURE_GOLD_OPTION);
|
||
send.SetOptiontype(5);
|
||
send.SendPacket();
|
||
return;
|
||
}
|
||
|
||
switch (m_ParamType)
|
||
{
|
||
case (int)ActivityItem.Parameter_type.CHUANSONG:
|
||
//传送
|
||
if (activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH)
|
||
{
|
||
if (GameManager.gameManager.RunningScene != GlobeVar.GUILDMATCH_MAINFUBENID && ActivityDataManager.Instance.IsActivityState((int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH, ActivityDataManager.ActivityState.Playing))
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{29036}"), null, delegate ()
|
||
{
|
||
GCGame.Utils.EnterCopy((int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUILDWARMAIN);
|
||
},
|
||
null);
|
||
}
|
||
else
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{25137}"));
|
||
}
|
||
return;
|
||
}
|
||
|
||
Tab_SceneClass sceneInfo = TableManager.GetSceneClassByID(int.Parse(parameter), 0);
|
||
if (sceneInfo != null)
|
||
{
|
||
var m_curShowSceneID = sceneInfo.SceneID;
|
||
if (m_curShowSceneID >= 0 && Singleton<ObjManager>.GetInstance().MainPlayer != null && m_curShowSceneID != GameManager.gameManager.RunningScene)
|
||
{
|
||
if (GCGame.Utils.IsCanPK(int.Parse(parameter)) && !GCGame.Utils.IsIncPKValue(m_curShowSceneID))
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{2672}"), "", () => { EnterNonePKValueSceneOK(m_curShowSceneID); });
|
||
}
|
||
else
|
||
{
|
||
EnterNonePKValueSceneOK(m_curShowSceneID);
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
break;
|
||
case (int)ActivityItem.Parameter_type.FINDWAY:
|
||
Tab_AutoSearch autoSearch = TableManager.GetAutoSearchByID(int.Parse(parameter), 0);
|
||
if (autoSearch == null)
|
||
{
|
||
return;
|
||
}
|
||
//接受任务后自动寻路
|
||
Vector3 targetPos = new Vector3();
|
||
targetPos.x = autoSearch.X;
|
||
targetPos.z = autoSearch.Z;
|
||
int nTargetScene = autoSearch.DstSceneID;
|
||
AutoSearchPoint point = new AutoSearchPoint(nTargetScene, targetPos.x, targetPos.z);
|
||
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
||
{
|
||
GameManager.gameManager.AutoSearch.BuildPath(point);
|
||
Tab_RoleBaseAttr RoleBase = TableManager.GetRoleBaseAttrByID(autoSearch.DataId, 0);
|
||
// 确定NPC存在,并且寻路信息已经构建
|
||
if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path)
|
||
{
|
||
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name;
|
||
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius;
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
}
|
||
}
|
||
break;
|
||
case (int)ActivityItem.Parameter_type.OPENUI:
|
||
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUIDBOSS)
|
||
{
|
||
if (!GameManager.gameManager.PlayerDataPool.IsHaveGuild())
|
||
{
|
||
// 加入帮派提醒
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6707}"));
|
||
return;
|
||
}
|
||
}
|
||
|
||
if(_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_FACTIONCHALLENGE)
|
||
{
|
||
UIManager.ShowUI(UIInfo.SportsPanel, delegate(bool bSucess, object param) {
|
||
if(bSucess)
|
||
{
|
||
SportsPanel.Instance.OnMenuItemClick((int)SportsPanel.SportsType.FactionChallenge);
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
else if(_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_FIGHTYARD)
|
||
{
|
||
UIManager.ShowUI(UIInfo.SportsPanel, delegate (bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
SportsPanel.Instance.OnMenuItemClick((int)SportsPanel.SportsType.Yanwu);
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
else if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH)
|
||
{
|
||
UIManager.ShowUI(UIInfo.SportsPanel, delegate (bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
SportsPanel.Instance.OnMenuItemClick((int)SportsPanel.SportsType.Guild);
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
else if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_TREASURE_GLOD)
|
||
{
|
||
UIManager.ShowUI(UIInfo.SportsPanel, delegate (bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
SportsPanel.Instance.OnMenuItemClick((int)SportsPanel.SportsType.Digong);
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
else if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_PVP)
|
||
{
|
||
UIManager.ShowUI(UIInfo.SportsPanel, delegate (bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
SportsPanel.Instance.OnMenuItemClick((int)SportsPanel.SportsType.Pvp);
|
||
}
|
||
});
|
||
return;
|
||
}
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
UIManager.ShowUI(UIPathData.m_DicUIName[parameter], delegate (bool bSucess, object param) {
|
||
if (bSucess)
|
||
{
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_IMPERIALEXAM)
|
||
{
|
||
ImpreialExamPanelCtr.Instance.SetMyQuestionType((int)ActivityDataManager.Activity_Type.ACTIVITY_IMPERIALEXAM);
|
||
return;
|
||
}
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_HUISHI)
|
||
{
|
||
ImpreialExamPanelCtr.Instance.AskQuestionInfo((int)ImpreialExamPanelCtr.Question_Type.QUESTION_HUISHI);
|
||
return;
|
||
}
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_MISER)
|
||
{
|
||
Hashtable table = new Hashtable();
|
||
table["ActiveType"] = (int)ActivityDataManager.Activity_Type.ACTIVITY_MISER;
|
||
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.OpenActivePresiousWnd, table);
|
||
}
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_PACKVETCH)
|
||
{
|
||
Hashtable table = new Hashtable();
|
||
table["ActiveType"] = (int)ActivityDataManager.Activity_Type.ACTIVITY_PACKVETCH;
|
||
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.OpenActivePresiousWnd, table);
|
||
}
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITYH_LUCKSTAR)
|
||
{
|
||
Hashtable table = new Hashtable();
|
||
table["ActiveType"] = (int)ActivityDataManager.Activity_Type.ACTIVITYH_LUCKSTAR;
|
||
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.OpenActivePresiousWnd, table);
|
||
}
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_CROSSSERVERBOSS)
|
||
{
|
||
if (BossUI.Instance() != null)
|
||
BossUI.Instance().ShowPage(3);
|
||
}
|
||
if (_serverType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_BOSS)
|
||
{
|
||
if (BossUI.Instance() != null)
|
||
BossUI.Instance().ShowPage(1);
|
||
}
|
||
}
|
||
});
|
||
break;
|
||
case (int)ActivityItem.Parameter_type.HUIBANG: //传送回帮派
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild() == false)
|
||
{
|
||
// 加入帮派提醒
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6707}"));
|
||
return;
|
||
}
|
||
|
||
if (activityBase.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
||
{
|
||
//帮派等级小于4返回
|
||
var guidTab = TableManager.GetGuildOtherByID(0, 0);
|
||
if (guidTab == null)
|
||
{
|
||
LogModule.ErrorLog("guidTab is null");
|
||
return;
|
||
}
|
||
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel < guidTab.RobberNeedGuildLevel)
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6709}"));
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (activityBase.Parameter.Equals("-1"))
|
||
{
|
||
var guid = GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid;
|
||
var mainPlayer = ObjManager.Instance.MainPlayer;
|
||
if (mainPlayer != null)
|
||
mainPlayer.BackGuildMap(guid);
|
||
else
|
||
{
|
||
// 保持之前玩家未创建也可以发送协议的逻辑
|
||
var send =
|
||
(CG_REQ_ENTER_GUILDMAP)PacketDistributed.CreatePacket(MessageID
|
||
.PACKET_CG_REQ_ENTER_GUILDMAP);
|
||
send.SetGuildGuid(guid);
|
||
send.SendPacket();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
string[] paramaters = activityBase.Parameter.Split('|');
|
||
int roleId = int.Parse(paramaters[0]);
|
||
float posX = float.Parse(paramaters[1]);
|
||
float posZ = float.Parse(paramaters[2]);
|
||
|
||
GameManager.gameManager.AutoSearch.BackGuild(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid, int.Parse(paramaters[0]), float.Parse(paramaters[1]), float.Parse(paramaters[2]));
|
||
}
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
}
|
||
break;
|
||
case (int)ActivityItem.Parameter_type.LOACL_CALLBACK: //本地回调函数
|
||
{
|
||
//需要确保方法是静态公有的,其他地方也会用到,不要和UI绑一起
|
||
var method = typeof(ActivityController).GetMethod(parameter, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
|
||
if(method != null)
|
||
method.Invoke(null, new object[0]);
|
||
//if (GameManager.gameManager)
|
||
//{
|
||
// GameManager.gameManager.Invoke(parameter, 0);
|
||
//}
|
||
}
|
||
break;
|
||
|
||
case (int)ActivityItem.Parameter_type.MISSIONINSEC:
|
||
int autosearchId = Games.GlobeDefine.GlobeVar.GetMasterAutosearchId(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession);
|
||
Tab_AutoSearch searchTab = TableManager.GetAutoSearchByID(autosearchId, 0);
|
||
if (searchTab == null)
|
||
{
|
||
return;
|
||
}
|
||
//接受任务后自动寻路
|
||
Vector3 pos = new Vector3();
|
||
pos.x = searchTab.X;
|
||
pos.z = searchTab.Z;
|
||
int sceneId = searchTab.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(searchTab.DataId, 0);
|
||
if (null != RoleBase && null != GameManager.gameManager.AutoSearch.Path)
|
||
{
|
||
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = RoleBase.Name;
|
||
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = RoleBase.DialogRadius;
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
}
|
||
}
|
||
break;
|
||
case (int)ActivityItem.Parameter_type.OPENPERIOUS:
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.IsHaveGuild() == false)
|
||
{
|
||
// 加入帮派提醒
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6707}"));
|
||
return;
|
||
}
|
||
|
||
UIManager.ShowUI(UIInfo.ActivePresious, OpenActivePresiousWnd, activityBase.ActivityServerType);
|
||
}
|
||
break;
|
||
case (int)ActivityItem.Parameter_type.ENTEREXERCISEROOM:
|
||
ReqEnterExerciseRoom req = new ReqEnterExerciseRoom();
|
||
req.flag = 1;
|
||
req.SendMsg();
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
break;
|
||
case (int)ActivityItem.Parameter_type.ENTERCOPY:
|
||
int fubenID = -1;
|
||
if(int.TryParse(parameter,out fubenID) && fubenID != GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID)
|
||
{
|
||
Tab_Fuben fubenInfo = TableManager.GetFubenByID(fubenID);
|
||
if (fubenInfo != null)
|
||
{
|
||
if (Singleton<ObjManager>.GetInstance().MainPlayer != null)
|
||
{
|
||
GCGame.Utils.EnterCopy(int.Parse(parameter));
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
public static void OpenActivePresiousWnd(bool successed, object param)
|
||
{
|
||
if (successed == true)
|
||
{
|
||
Hashtable table = new Hashtable();
|
||
table["ActiveType"] = (int)param;
|
||
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.OpenActivePresiousWnd, table);
|
||
}
|
||
}
|
||
|
||
static void EnterNonePKValueSceneOK(int sceneID)
|
||
{
|
||
Tab_SceneClass tabSceneClass = TableManager.GetSceneClassByID(sceneID, 0);
|
||
if (null == tabSceneClass)
|
||
{
|
||
return;
|
||
}
|
||
DoTeleport(sceneID);
|
||
//MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{1644}", tabSceneClass.Name), "", () => { DoTeleport(sceneID); });
|
||
}
|
||
|
||
static void DoTeleport(int sceneID)
|
||
{
|
||
if (GameManager.gameManager.ActiveScene.IsCopyScene())
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42632}"));
|
||
return;
|
||
}
|
||
|
||
Tab_SceneClass tabSceneClass = TableManager.GetSceneClassByID(sceneID, 0);
|
||
if (null == tabSceneClass)
|
||
{
|
||
return;
|
||
}
|
||
SceneData.RequestChangeScene((int)CG_REQ_CHANGE_SCENE.CHANGETYPE.WORLDMAP, 0, sceneID, -1, (int)tabSceneClass.SafeX, (int)tabSceneClass.SafeZ);
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
}
|
||
|
||
public bool IsWillOpen(int activityId)
|
||
{
|
||
if (GetActivityTimeState(activityId) == (int)ActivityTimeType.WillOpen
|
||
|| GetActivityTimeState(activityId) == (int)ActivityTimeType.WillOpenButShow)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsFinish(int activityId)
|
||
{
|
||
if (GetActivityTimeState(activityId) == (int)ActivityTimeType.Finish)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsOnOpenAndCanJoin(int activityId) //在时间内 等级满足 未完成
|
||
{
|
||
if (IsOnOpenTime(activityId) && IsLevelEnough(activityId) && !IsCompleted(activityId))
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsWillOpenAndCanJoin(int activityId)
|
||
{
|
||
if(IsWillOpen(activityId) && IsLevelEnough(activityId) && !IsCompleted(activityId))
|
||
{
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
public bool IsStatisfyAndCompleted(int activityId)
|
||
{
|
||
if(IsLevelEnough(activityId) && IsCompleted(activityId))
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//分类活动并进行排序
|
||
public List<int> SetMyActivityState(List<int> m_List)
|
||
{
|
||
List<int> CanJoinList = new List<int>(); //在时间内 等级满足 未完成
|
||
List<int> WillJoinList = new List<int>(); //马上开启 等级满足 未完成
|
||
List<int> CompledteList = new List<int>(); //等级满足 已完成(0, 1状态)
|
||
List<int> LevelNotEnoughList = new List<int>(); //等级不满足
|
||
List<int> FinishedList = new List<int>(); //已结束
|
||
for (int index = 0; index < m_List.Count; index++)
|
||
{
|
||
if(IsOnOpenAndCanJoin(m_List[index]))
|
||
{
|
||
CanJoinList.Add(m_List[index]);
|
||
}else if(IsWillOpenAndCanJoin(m_List[index]))
|
||
{
|
||
WillJoinList.Add(m_List[index]);
|
||
}else if(IsStatisfyAndCompleted(m_List[index]))
|
||
{
|
||
CompledteList.Add(m_List[index]);
|
||
}else if(!IsLevelEnough(m_List[index]))
|
||
{
|
||
LevelNotEnoughList.Add(m_List[index]);
|
||
}else
|
||
{
|
||
FinishedList.Add(m_List[index]);
|
||
}
|
||
}
|
||
|
||
CanJoinList.Sort(SortCanJoinList);
|
||
WillJoinList.Sort(SortWillOpenList);
|
||
CompledteList.Sort(SortCompletedList);
|
||
LevelNotEnoughList.Sort(SortLevelNottEnough);
|
||
FinishedList.Sort(SortFinisedList);
|
||
m_List.Clear();
|
||
m_List.AddRange(CanJoinList);
|
||
m_List.AddRange(WillJoinList);
|
||
m_List.AddRange(CompledteList);
|
||
m_List.AddRange(LevelNotEnoughList);
|
||
m_List.AddRange(FinishedList);
|
||
return m_List;
|
||
}
|
||
|
||
public int SortCanJoinList(int actIdA, int actIdB)
|
||
{
|
||
var tabA = TableManager.GetActivityBaseByID(actIdA, 0);
|
||
var tabB = TableManager.GetActivityBaseByID(actIdB, 0);
|
||
if(tabA == null || tabB == null)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
if (tabA.Promote > tabB.Promote)
|
||
{
|
||
return -1;
|
||
}
|
||
else if (tabA.Promote < tabB.Promote)
|
||
{
|
||
return 1;
|
||
}
|
||
else //推荐等级等级相同的时候,判断是否是限时任务
|
||
{
|
||
//限时排在前
|
||
if (IsLimitMission(tabA) && !IsLimitMission(tabB))
|
||
{
|
||
return -1;
|
||
}
|
||
else if (IsLimitMission(tabB) && !IsLimitMission(tabA))
|
||
{
|
||
return 1;
|
||
}
|
||
else
|
||
{
|
||
//ID小的排在前
|
||
return tabA.Id < tabB.Id ? -1 : 1; //不存在ID相同的情况
|
||
}
|
||
}
|
||
}
|
||
|
||
public int SortWillOpenList(int actIdA, int actIdB)
|
||
{
|
||
return GetNearestOpenTime(actIdA) < GetNearestOpenTime(actIdB) ? -1 : 1;
|
||
}
|
||
|
||
public int SortCompletedList(int actIdA, int actIdB)
|
||
{
|
||
var tabA = TableManager.GetActivityBaseByID(actIdA, 0);
|
||
var tabB = TableManager.GetActivityBaseByID(actIdB, 0);
|
||
if (tabA == null || tabB == null)
|
||
{
|
||
return 0;
|
||
}
|
||
if(tabA.HideOnCompleted > tabB.HideOnCompleted)
|
||
{
|
||
return -1;
|
||
}else if(tabB.HideOnCompleted > tabA.HideOnCompleted)
|
||
{
|
||
return 1;
|
||
}else
|
||
{
|
||
return tabA.Id < tabB.Id ? -1 : 1;
|
||
}
|
||
}
|
||
|
||
public int SortLevelNottEnough(int actIdA, int actIdB)
|
||
{
|
||
var tabA = TableManager.GetActivityBaseByID(actIdA, 0);
|
||
var tabB = TableManager.GetActivityBaseByID(actIdB, 0);
|
||
if (tabA == null || tabB == null)
|
||
{
|
||
return 0;
|
||
}
|
||
if(tabA.Level == tabB.Level)
|
||
{
|
||
//ID小在前
|
||
return tabA.Id < tabB.Id ? -1 : 1;
|
||
}
|
||
return tabA.Level < tabB.Level ? -1 : 1;
|
||
}
|
||
|
||
public int SortFinisedList(int actIdA, int actIdB)
|
||
{
|
||
var tabA = TableManager.GetActivityBaseByID(actIdA, 0);
|
||
var tabB = TableManager.GetActivityBaseByID(actIdB, 0);
|
||
if (tabA == null || tabB == null)
|
||
{
|
||
return 0;
|
||
}
|
||
return tabA.Id < tabB.Id ? -1 : 1;
|
||
}
|
||
|
||
public int GetNearestOpenTime(int actId)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(actId, 0);
|
||
if (activityBase == null)
|
||
return -1;
|
||
|
||
int m_ServerTime = GlobalData.ServerAnsiTime;
|
||
DateTime dt = GCGame.Utils.GetServerDateTime();
|
||
|
||
int nearestOpenTime = 0;
|
||
//获取服务器的小时 分钟
|
||
int hour = dt.Hour;
|
||
int minute = dt.Minute;
|
||
int currentServerTimeToTabTime = hour * 100 + minute; //例如:2200 2100
|
||
nearestOpenTime = int.Parse(activityBase.GetTimebyIndex(0).Split('|')[0]);
|
||
for (int index = 0; index < activityBase.getTimeCount(); index++)
|
||
{
|
||
if (!activityBase.GetTimebyIndex(index).Equals("-1"))
|
||
{
|
||
if (currentServerTimeToTabTime < int.Parse(activityBase.GetTimebyIndex(index).Split('|')[0])
|
||
&& currentServerTimeToTabTime < int.Parse(activityBase.GetTimebyIndex(index).Split('|')[1]))
|
||
{
|
||
nearestOpenTime = int.Parse(activityBase.GetTimebyIndex(index).Split('|')[0]);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return nearestOpenTime;
|
||
}
|
||
|
||
public bool IsLimitMission(Tab_ActivityBase tab)
|
||
{
|
||
return (tab.ActivityType & 1) != 0 ? true : false;
|
||
}
|
||
|
||
public void OnUseActivityBtnClick()
|
||
{
|
||
UIManager.ShowUI(UIInfo.Boss, delegate(bool bSucess, object param)
|
||
{
|
||
if(bSucess)
|
||
{
|
||
BossUI.Instance().ShowPage(0);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 进入皇陵探宝活动
|
||
public static void GoTombRaider()
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(5703, -1,
|
||
() =>
|
||
{
|
||
TombRaiderTipPanelCtr.HasShow = false;
|
||
GCGame.Utils.EnterCopy(6059);
|
||
});
|
||
}
|
||
|
||
// 进入跨服夺旗活动
|
||
public static void GoCaptureFlag()
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(5703, -1,
|
||
() =>
|
||
{
|
||
TombRaiderTipPanelCtr.HasShow = false;
|
||
GCGame.Utils.EnterCopy(6059);
|
||
});
|
||
}
|
||
|
||
//夜战地宫
|
||
public static void TreasureGold()
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{39500}"), null, delegate ()
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.Money.GetMoney_Coin() >= 10000)
|
||
{
|
||
CG_TREASURE_GOLD_OPTION send = (CG_TREASURE_GOLD_OPTION)PacketDistributed.CreatePacket(MessageID.PACKET_CG_TREASURE_GOLD_OPTION);
|
||
send.SetOptiontype(0);
|
||
send.SendPacket();
|
||
}
|
||
else
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{39512}"), null, delegate ()
|
||
{
|
||
JudgeMoneyLogic.ShowSwitchMoneyPanel(MONEYTYPE.MONEYTYPE_COIN, true);
|
||
}, null);
|
||
}
|
||
|
||
}, null);
|
||
}
|
||
|
||
//不稳定排序导致定位的时候排序还未结束,排序结束之后会互换位置
|
||
private int _isNeedPosActItemId = -1;
|
||
public void ShowItemByActId(int _ActId)
|
||
{
|
||
_isNeedPosActItemId = _ActId;
|
||
_ItemsContainer.ForeachActiveItem<ActivityItem>((actItem) => {
|
||
if(actItem.m_ItemInfoId == _ActId)
|
||
{
|
||
//显示当前的位置
|
||
_ItemsContainer.ShowContainerPos(actItem);
|
||
actItem.ShowSelectEffect(true);
|
||
}else
|
||
{
|
||
actItem.ShowSelectEffect(false);
|
||
}
|
||
});
|
||
}
|
||
|
||
public void OnHelpSpriteBtn()
|
||
{
|
||
UIManager.ShowUI(UIInfo.ChatHelperRoot);
|
||
}
|
||
}
|