545 lines
19 KiB
C#
545 lines
19 KiB
C#
using UnityEngine;
|
||
using System.Collections;
|
||
using UnityEngine.EventSystems;
|
||
using System;
|
||
using UnityEngine.UI;
|
||
using GCGame.Table;
|
||
using Games.Mission;
|
||
using Games.GlobeDefine;
|
||
using Module.Log;
|
||
|
||
public class ActivityItem : UIItemSelect
|
||
{
|
||
public int m_ItemInfoId;
|
||
public Image m_ActivityIcon; // 活动标记
|
||
public Text m_ActivityName; // 活动描述
|
||
public Text m_HasJoinedTimes; // 活动参加的次数
|
||
public Text m_ActivityGotValue; // 活动对应的活力值
|
||
public Image m_MarkTypeIcon; // 活动是否被推荐或者是组队、战斗类的活动
|
||
public Button m_JoinButton; // 活动参加按钮
|
||
public Text buttonDesc; // 已经接取任务的时候显示已接
|
||
public Image m_LimitInfoImage; // 活动限制image
|
||
public Text m_LimitInfoText; // 活动限制信息
|
||
public GameObject m_ActivityValueItem; // (是否显示活力要用到)
|
||
|
||
public Sprite recommendImage; // 推荐标记
|
||
public Sprite limitTimeImage; // 限时标记
|
||
|
||
|
||
public GameObject _CompleteIcon; // 完成标记
|
||
public GameObject _FinishIcon; // 接取标记
|
||
public GameObject _SelectEffect;
|
||
|
||
public GameObject _expIcon;
|
||
public GameObject _RedIcon;
|
||
|
||
public GameObject _NormalParamPanel;
|
||
public GameObject _SpecialParamPanel;
|
||
public Text _SpecialParamText;
|
||
|
||
public int m_curShowSceneID = -1;
|
||
public int _ServerType = -1;
|
||
public enum ActivityPromoteType
|
||
{
|
||
INVALID_PROMOTE = -1,
|
||
IS_PROMOTE = 1, //推荐
|
||
NOT_PROMOTE = 2, //不推荐
|
||
}
|
||
|
||
|
||
public override void Show(Hashtable hash)
|
||
{
|
||
base.Show();
|
||
|
||
var itemInfo = (int)hash["InitObj"];
|
||
// baseTab在InitItem中重复赋值!!!
|
||
baseTab = TableManager.GetActivityBaseByID(itemInfo, 0);
|
||
_ServerType = baseTab.ActivityServerType;
|
||
RefreshHeadExpIcon();
|
||
InitItem(itemInfo);
|
||
}
|
||
|
||
private Tab_ActivityBase baseTab = null;
|
||
|
||
public void SetIconAndName()
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(m_ActivityIcon, baseTab.ActivityIcon);
|
||
m_ActivityName.text = baseTab.ActivityName;
|
||
}
|
||
|
||
public bool IsCompleteLimitTimes()
|
||
{
|
||
//计算活力值
|
||
Tab_ActivityActValLimit actvalLimit = TableManager.GetActivityActValLimitByID(baseTab.ActivityServerType, 0);
|
||
if (actvalLimit == null)
|
||
{
|
||
return false;
|
||
}
|
||
int m_SingleActVal = actvalLimit.ActValPer; // 单次活动的活力值
|
||
int m_AcitivityLimitTimes = baseTab.ActityLimitTimes; // 活动限制的次数
|
||
int param = 0;
|
||
|
||
if (baseTab.ActivityServerType != -1)
|
||
{
|
||
param = ActivityDataManager.Instance.GetActivityCompleteTimes(baseTab.ActivityServerType);
|
||
param = (param > 0 ? param : 0);
|
||
}
|
||
|
||
if (m_AcitivityLimitTimes == -1)
|
||
return true;
|
||
|
||
if (param >= m_AcitivityLimitTimes)
|
||
return true;
|
||
|
||
return false;
|
||
}
|
||
|
||
public void SetActValueAndCountAndLimitInfo()
|
||
{
|
||
//计算活力值
|
||
Tab_ActivityActValLimit actvalLimit = TableManager.GetActivityActValLimitByID(baseTab.ActivityServerType, 0);
|
||
if (actvalLimit == null)
|
||
{
|
||
return;
|
||
}
|
||
int m_SingleActVal = actvalLimit.ActValPer; // 单次活动的活力值
|
||
int m_AcitivityLimitTimes = baseTab.ActityLimitTimes; // 活动限制的次数
|
||
int param = 0;
|
||
|
||
// 多余判断,是-1就不可能获得表格数据 !!!
|
||
if (baseTab.ActivityServerType != -1)
|
||
{
|
||
param = ActivityDataManager.Instance.GetActivityCompleteTimes(baseTab.ActivityServerType);
|
||
param = (param > 0 ? param : 0);
|
||
}
|
||
|
||
//如果不限制次数
|
||
if (m_AcitivityLimitTimes == -1)
|
||
{
|
||
//不限制活动次数
|
||
m_HasJoinedTimes.text = StrDictionary.GetClientDictionaryString("#{43036}");// "不限制";
|
||
}
|
||
else
|
||
{
|
||
m_HasJoinedTimes.text = param.ToString() + "/" + m_AcitivityLimitTimes.ToString();
|
||
}
|
||
|
||
if (m_SingleActVal > 0)
|
||
{
|
||
m_ActivityValueItem.gameObject.SetActive(true);
|
||
int m_DayLimitVal = actvalLimit.DayCountLimit;
|
||
int m_TotalVal = m_SingleActVal * param;
|
||
if (m_TotalVal > (m_SingleActVal * m_DayLimitVal))
|
||
{
|
||
m_ActivityGotValue.text = (m_SingleActVal * m_DayLimitVal).ToString() + "/" + actvalLimit.ActValPer * actvalLimit.DayCountLimit;
|
||
}
|
||
else
|
||
{
|
||
m_ActivityGotValue.text = m_TotalVal.ToString() + "/" + actvalLimit.ActValPer * actvalLimit.DayCountLimit;
|
||
}
|
||
|
||
// 这个 m_LimitTimes 作用何在 !!!
|
||
int m_LimitTimes = -1;
|
||
|
||
Tab_ActivityActValLimit limit = TableManager.GetActivityActValLimitByID(baseTab.ActivityServerType, 0);
|
||
if (limit != null)
|
||
{
|
||
m_LimitTimes = limit.DayCountLimit;
|
||
}
|
||
|
||
}else
|
||
{
|
||
m_ActivityValueItem.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
public void ShowMarkIcon()
|
||
{
|
||
// 可将 m_MarkTypeIcon.gameObject.SetActive(false); 写在开头缩减代码
|
||
if (!ActivityController.Instance().IsFinish(m_ItemInfoId))
|
||
{
|
||
//判断活动是否是推荐活动 显示推荐标记
|
||
int m_PromoteType = baseTab.Promote;
|
||
if (m_PromoteType == (int)ActivityPromoteType.IS_PROMOTE)
|
||
{
|
||
m_MarkTypeIcon.gameObject.SetActive(true);
|
||
m_MarkTypeIcon.overrideSprite = recommendImage;
|
||
}
|
||
else if ((baseTab.ActivityType & 1) != 0) //限时活动
|
||
{
|
||
m_MarkTypeIcon.gameObject.SetActive(true);
|
||
m_MarkTypeIcon.overrideSprite = limitTimeImage;
|
||
}
|
||
else
|
||
{
|
||
m_MarkTypeIcon.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_MarkTypeIcon.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
|
||
//刷新当前是否要限时迎头经验高倍的标记
|
||
|
||
public void RefreshHeadExpIcon()
|
||
{
|
||
if (GameManager.gameManager.PlayerDataPool.ActivityHeadExpDic.ContainsKey(_ServerType)
|
||
&& GameManager.gameManager.PlayerDataPool.ActivityHeadExpDic[_ServerType] > 0)
|
||
{
|
||
RefreshHeadExpIcon(true);
|
||
}
|
||
else
|
||
{
|
||
RefreshHeadExpIcon(false);
|
||
}
|
||
}
|
||
|
||
public void RefreshHeadExpIcon(bool isShow)
|
||
{
|
||
_expIcon.SetActive(isShow);
|
||
}
|
||
|
||
public void InitItem(int hash)
|
||
{
|
||
m_ItemInfoId = hash;
|
||
if (m_ItemInfoId != -1)
|
||
{
|
||
baseTab = TableManager.GetActivityBaseByID(m_ItemInfoId, 0);
|
||
if (baseTab == null)
|
||
{
|
||
return;
|
||
}
|
||
SpecialParam();
|
||
//设置活动标志
|
||
SetIconAndName();
|
||
|
||
//设置活动的已经完成的以及限制次数
|
||
SetActValueAndCountAndLimitInfo();
|
||
|
||
//活动已经完成的就不再显示推荐标记
|
||
ShowMarkIcon();
|
||
|
||
//根据状态设置描述
|
||
SetItemStateDesc();
|
||
}
|
||
}
|
||
|
||
void SpecialParam()
|
||
{
|
||
_NormalParamPanel.SetActive(baseTab.ActivityServerType != (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_EXERCISEROOM);
|
||
_SpecialParamPanel.SetActive(baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_EXERCISEROOM);
|
||
if(baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_EXERCISEROOM)
|
||
{
|
||
ReqSpecialParam();
|
||
}
|
||
}
|
||
|
||
public void RefershExerciseRoomRemainTime(int remainTime)
|
||
{
|
||
_SpecialParamText.text = remainTime + "";
|
||
}
|
||
|
||
void ReqSpecialParam()
|
||
{
|
||
//练功房
|
||
ReqExerciseRoomInfo req = new ReqExerciseRoomInfo();
|
||
req.flag = 1;
|
||
req.SendMsg();
|
||
}
|
||
|
||
bool IsSetNeedOpenServerTime(int id)
|
||
{
|
||
var activityBase = TableManager.GetActivityBaseByID(id, 0);
|
||
if (activityBase == null)
|
||
return false;
|
||
|
||
if (activityBase.NeedOpenServerDay + 1 > GlobalData.OpenServerDays)
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(false);
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
m_LimitInfoImage.gameObject.SetActive(true);
|
||
m_LimitInfoText.text = StrDictionary.GetClientDictionaryString("#{2186}", activityBase.NeedOpenServerDay - GlobalData.OpenServerDays + 1);
|
||
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
public void SetItemStateDesc()
|
||
{
|
||
if (IsSetNeedOpenServerTime(m_ItemInfoId))
|
||
return;
|
||
if (ActivityController.GetActivityTimeState(m_ItemInfoId) == (int)ActivityController.ActivityTimeType.IsGoing
|
||
|| ActivityController.GetActivityTimeState(m_ItemInfoId) == (int)ActivityController.ActivityTimeType.WillOpenButShow)
|
||
{
|
||
if (!ActivityController.IsLevelEnough(m_ItemInfoId))
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(false);
|
||
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
|
||
m_LimitInfoImage.gameObject.SetActive(true);
|
||
m_LimitInfoText.text = StrDictionary.GetClientDictionaryString("#{43033}", baseTab.Level.ToString());
|
||
}
|
||
else if((!ActivityController.IsCompleted(m_ItemInfoId)))
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(false);
|
||
|
||
//判断是否有当前任务在身上
|
||
if (IsHaveThisTypeMission(m_ItemInfoId))
|
||
{
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
|
||
m_LimitInfoImage.gameObject.SetActive(true);
|
||
m_LimitInfoText.text = StrDictionary.GetClientDictionaryString("#{1619}");
|
||
}
|
||
else
|
||
{
|
||
m_JoinButton.gameObject.SetActive(true);
|
||
buttonDesc.text = StrDictionary.GetClientDictionaryString("#{46214}", baseTab.Level.ToString());
|
||
|
||
m_LimitInfoImage.gameObject.SetActive(false);
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
// 完成后是否隐藏 参加 按钮
|
||
// 1 不隐藏
|
||
if(baseTab.HideOnCompleted == 1)
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(false);
|
||
|
||
m_JoinButton.gameObject.SetActive(true);
|
||
m_LimitInfoImage.gameObject.SetActive(false);
|
||
buttonDesc.text = StrDictionary.GetClientDictionaryString("#{46214}", baseTab.Level.ToString());
|
||
}
|
||
else
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(true);
|
||
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
m_LimitInfoImage.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
else if(ActivityController.GetActivityTimeState(m_ItemInfoId) == (int)ActivityController.ActivityTimeType.WillOpen)
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(false);
|
||
|
||
if (!ActivityController.IsLevelEnough(m_ItemInfoId))
|
||
{
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
m_LimitInfoImage.gameObject.SetActive(true);
|
||
m_LimitInfoText.text = StrDictionary.GetClientDictionaryString("#{43033}", baseTab.Level.ToString());
|
||
}
|
||
else if ((!ActivityController.IsCompleted(m_ItemInfoId)))
|
||
{
|
||
// 显示最近的开启时间
|
||
int nearestTime = ActivityController.Instance().GetNearestOpenTime(m_ItemInfoId);
|
||
int hour = nearestTime / 100;
|
||
int minute = nearestTime - hour * 100;
|
||
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
m_LimitInfoImage.gameObject.SetActive(true);
|
||
m_LimitInfoText.text = StrDictionary.GetClientDictionaryString("#{2124}", hour, minute.ToString().Equals("0") ? "00" : minute.ToString());
|
||
}
|
||
else
|
||
{
|
||
if (baseTab.HideOnCompleted == 0) //隐藏
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(true);
|
||
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
m_LimitInfoImage.gameObject.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
_FinishIcon.SetActive(false);
|
||
_CompleteIcon.SetActive(false);
|
||
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
|
||
// 显示最近的开启时间
|
||
int nearestTime = ActivityController.Instance().GetNearestOpenTime(m_ItemInfoId);
|
||
int hour = nearestTime / 100;
|
||
int minute = nearestTime - hour * 100;
|
||
|
||
m_LimitInfoImage.gameObject.SetActive(true);
|
||
m_LimitInfoText.text = StrDictionary.GetClientDictionaryString("#{2124}", hour, minute.ToString().Equals("0") ? "00" : minute.ToString());
|
||
}
|
||
}
|
||
}
|
||
else if(ActivityController.GetActivityTimeState(m_ItemInfoId) == (int)ActivityController.ActivityTimeType.Finish)
|
||
{
|
||
_FinishIcon.SetActive(true);
|
||
_CompleteIcon.SetActive(false);
|
||
m_JoinButton.gameObject.SetActive(false);
|
||
m_LimitInfoImage.gameObject.SetActive(false);
|
||
}
|
||
|
||
if(m_JoinButton.gameObject.activeInHierarchy)
|
||
{
|
||
if(ActivityController.GetActivityTimeState(m_ItemInfoId) != (int)ActivityController.ActivityTimeType.IsGoing)
|
||
{
|
||
_RedIcon.SetActive(false);
|
||
return;
|
||
}
|
||
|
||
if (IsCompleteLimitTimes())
|
||
{
|
||
_RedIcon.SetActive(false);
|
||
return;
|
||
}
|
||
|
||
if (!IsGuildActivityShowRedIcon())
|
||
{
|
||
_RedIcon.SetActive(false);
|
||
return;
|
||
}
|
||
|
||
_RedIcon.SetActive(true);
|
||
}
|
||
}
|
||
|
||
public bool IsGuildActivityShowRedIcon()
|
||
{
|
||
if(baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDFREIGHT
|
||
|| baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_FEAST
|
||
|| baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_ESCORT
|
||
|| baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_DRAGONWAR
|
||
|| baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUILD_UNION_MATCH
|
||
|| baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GUIDBOSS
|
||
|| baseTab.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
||
{
|
||
if(!GameManager.gameManager.PlayerDataPool.IsHaveGuild())
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public static bool IsHaveThisTypeMission(int m_ItemInfoId)
|
||
{
|
||
Tab_ActivityBase activityBase = TableManager.GetActivityBaseByID(m_ItemInfoId, 0);
|
||
if(activityBase != null)
|
||
{
|
||
foreach(var mission in GameManager.gameManager.MissionManager.MissionList.m_aMission)
|
||
{
|
||
Tab_MissionBase ownMission = TableManager.GetMissionBaseByID(mission.Key, 0);
|
||
if(ownMission.MissionType == activityBase.MissionBaseType)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public override void OnItemClick()
|
||
{
|
||
base.OnItemClick();
|
||
showActivityInfoTip();
|
||
}
|
||
|
||
public void showActivityInfoTip()
|
||
{
|
||
UIManager.ShowUI(UIInfo.ActivityInfoTip, delegate (bool bSucess, object param)
|
||
{
|
||
if (bSucess)
|
||
{
|
||
ActivityInfoTipController.Instance.InitMyItemTip(m_ItemInfoId);
|
||
}
|
||
});
|
||
}
|
||
|
||
public enum Parameter_type //点击按钮的去向类型
|
||
{
|
||
INVALID = -1,
|
||
CHUANSONG = 1,
|
||
FINDWAY = 2,
|
||
OPENUI = 3,
|
||
HUIBANG = 4,
|
||
LOACL_CALLBACK = 5,
|
||
MISSIONINSEC = 6,
|
||
OPENPERIOUS = 7,
|
||
ENTEREXERCISEROOM = 8,
|
||
ENTERCOPY = 9,
|
||
}
|
||
|
||
public void MyItemClick()
|
||
{
|
||
if (m_ItemInfoId == 37)
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{79509}"), null, delegate ()
|
||
{
|
||
ReqEnterForbiddenTop req = new ReqEnterForbiddenTop();
|
||
req.Flag = 1;
|
||
req.SendMsg();
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
},
|
||
null);
|
||
return;
|
||
}
|
||
ActivityController.ClickActive(m_ItemInfoId);
|
||
|
||
}
|
||
|
||
void EnterNonePKValueSceneOK()
|
||
{
|
||
Tab_SceneClass tabSceneClass = TableManager.GetSceneClassByID(m_curShowSceneID, 0);
|
||
if (null == tabSceneClass)
|
||
{
|
||
return;
|
||
}
|
||
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{1644}", tabSceneClass.Name), "", DoTeleport);
|
||
}
|
||
|
||
void DoTeleport()
|
||
{
|
||
if (GameManager.gameManager.ActiveScene.IsCopyScene())
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42632}"));
|
||
return;
|
||
}
|
||
|
||
Tab_SceneClass tabSceneClass = TableManager.GetSceneClassByID(m_curShowSceneID, 0);
|
||
if (null == tabSceneClass)
|
||
{
|
||
return;
|
||
}
|
||
SceneData.RequestChangeScene((int)CG_REQ_CHANGE_SCENE.CHANGETYPE.WORLDMAP, 0, m_curShowSceneID, -1, (int)tabSceneClass.SafeX, (int)tabSceneClass.SafeZ);
|
||
UIManager.CloseUI(UIInfo.Activity);
|
||
}
|
||
|
||
public void ShowSelectEffect(bool isShow)
|
||
{
|
||
if (_SelectEffect != null)
|
||
_SelectEffect.SetActive(isShow);
|
||
}
|
||
|
||
private void OnDisable()
|
||
{
|
||
HideEffect();
|
||
}
|
||
|
||
public void HideEffect()
|
||
{
|
||
if (_SelectEffect != null)
|
||
_SelectEffect.SetActive(false);
|
||
}
|
||
}
|