158 lines
4.5 KiB
C#
158 lines
4.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Games.LogicObj;
|
|
using GCGame.Table;
|
|
using Games.GlobeDefine;
|
|
|
|
public class ActivityStartTip : UIControllerBase<ActivityStartTip>
|
|
{
|
|
private static List<ActivityDataManager.ActivityData> m_Activitys = new List<ActivityDataManager.ActivityData>();
|
|
public static void OPenTip(object args)
|
|
{
|
|
Tab_SceneClass scene = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene, 0);
|
|
if ((scene.Type == 2 || scene.Type == 3) && GameManager.gameManager.RunningScene != (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_GUILD)
|
|
{
|
|
return;
|
|
}
|
|
if (m_Activitys.Count <= 0)
|
|
return;
|
|
|
|
UIManager.ShowUI(UIInfo.ActiveStartTip);
|
|
}
|
|
|
|
public static bool AddTip(object param)
|
|
{
|
|
ActivityDataManager.ActivityData activityData = param as ActivityDataManager.ActivityData;
|
|
if (activityData == null || activityData.activityTab == null)
|
|
return false;
|
|
if (activityData.activityState == ActivityDataManager.ActivityState.Playing)
|
|
{
|
|
m_Activitys.Add(activityData);
|
|
}
|
|
else
|
|
{
|
|
m_Activitys.Remove(activityData);
|
|
return false;
|
|
}
|
|
|
|
Tab_SceneClass scene = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene, 0);
|
|
if (scene.Type == 0 || scene.Type == 1 || GameManager.gameManager.RunningScene == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_GUILD)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public GameObject Achar;
|
|
public Image ActivityName;
|
|
public Image ActivityImage;
|
|
|
|
private ActivityDataManager.ActivityData m_CurrentShow = null;
|
|
|
|
void Awake()
|
|
{
|
|
SetInstance(this);
|
|
Achar.SetActive(false);
|
|
}
|
|
|
|
void OnDestory()
|
|
{
|
|
SetInstance(null);
|
|
}
|
|
|
|
|
|
float nextTip = 0;
|
|
private void Update()
|
|
{
|
|
if(m_CurrentShow == null && ((nextTip >= 0 && nextTip - Time.realtimeSinceStartup <= 0) || m_Activitys.Count <= 0))
|
|
{
|
|
UpdateTip();
|
|
nextTip = -1;
|
|
}
|
|
}
|
|
|
|
private bool IsCanShow(ActivityDataManager.ActivityData activityData)
|
|
{
|
|
if (activityData.activityTab.Level > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
|
|
return false;
|
|
if (activityData.activityTab.StartTipNeedGuild == 1 && GameManager.gameManager.PlayerDataPool.IsHaveGuild() == false)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
public void UpdateTip()
|
|
{
|
|
if (m_Activitys.Count <= 0 )
|
|
{
|
|
Close();
|
|
return;
|
|
}
|
|
|
|
for(int i=0;i< m_Activitys.Count;i++)
|
|
{
|
|
if(IsCanShow(m_Activitys[i]))
|
|
{
|
|
m_CurrentShow = m_Activitys[i];
|
|
}
|
|
}
|
|
if(m_CurrentShow==null)
|
|
{
|
|
Close();
|
|
return;
|
|
}
|
|
m_Activitys.Remove(m_CurrentShow);
|
|
Achar.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(ActivityImage, m_CurrentShow.activityTab.StartTipImage);
|
|
LoadAssetBundle.Instance.SetImageSprite(ActivityName, m_CurrentShow.activityTab.StartTipImage + "Name");
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
nextTip = 0;
|
|
m_CurrentShow = null;
|
|
Achar.SetActive(false);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
nextTip = 0;
|
|
m_CurrentShow = null;
|
|
Achar.SetActive(false);
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
if (m_CurrentShow == null || m_CurrentShow.activityTab == null)
|
|
return;
|
|
nextTip = Time.realtimeSinceStartup + 2;
|
|
m_CurrentShow = null;
|
|
Achar.SetActive(false);
|
|
}
|
|
|
|
public void EnterOK()
|
|
{
|
|
if (m_CurrentShow.activityTab.Id == 37)
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{79509}"), null, delegate ()
|
|
{
|
|
ReqEnterForbiddenTop req = new ReqEnterForbiddenTop();
|
|
req.Flag = 1;
|
|
req.SendMsg();
|
|
Achar.SetActive(false);
|
|
},
|
|
null);
|
|
|
|
return;
|
|
}
|
|
if (m_CurrentShow == null || m_CurrentShow.activityTab == null)
|
|
return;
|
|
nextTip = Time.realtimeSinceStartup + 2;
|
|
ActivityController.ClickActive(m_CurrentShow.activityTab.Id);
|
|
m_CurrentShow = null;
|
|
Achar.SetActive(false);
|
|
|
|
}
|
|
} |