Files
JJBB/Assets/Project/Script/Player/UserData/GlobalData.cs
2024-08-23 15:49:34 +08:00

466 lines
17 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using Games.GlobeDefine;
using Games.Item;
using GCGame;
using GCGame.Table;
public class GlobalData
{
public static int ServerAnsiTime = 0; // 服务器同步的时间
public static bool IsOpenConsumeRank = true; // 是否开启消费排行榜
public static bool IsOpenChristmas = false; // 是否开启圣诞节活动
public static bool IsOpenChongZhiRank = false;
public static int ChongZhiStartTime = 0;
public static int ChongZhiEndTime = 0;
public static int ChristmasStartTime = 0;
public static int ChristmasEndTime = 0;
public static bool IsLoginProcessEnd = false; //同步心跳包的时候记录当前状态为登录完毕
// public static bool IsAnimationFinish = false;
public static int CurAdvanceType = 0;
//相机移动的时候是否更新名字的位置
public static bool IsUpdateNmaeBoardWorldPosition = false;
//当前正在播放语音iD
public static int _PlayingSoundID = -1;
//NPC语音时间限制
public static int NextNpcSoundTime = -1;
//婚宴下次刷新时间
public static int BanquetNextRefreshTime = -1;
public static int ActivityValue; //角色的活力值
//进入当前场景的时间
public static float _EnterSceneStartTime = -1;
//请求进入的副本ID
public static int NeedShowCopyBaseUISceneId = -1;
public static int NeedShowCopyBaseSubPageIndex = 0;
public static int NeedShowSubPageIndex = 0;
//特权VIP可以领取的奖励数量
public static int PrivilegeVipCanGetRewCount;
//当前主线答题任务进行下标
//默认为-1用的时候先++, 用于关闭UI再次打开的时候计算当前应该显示的题目
public static int CurMissionQuestionIndex = -1;
// 开服天数
public static int OpenServerDays = 0; //默认为0用作判断
// <入口ID入口下的所有活动ID>
public static Dictionary<int, List<int>> CurMarketingActDic = new Dictionary<int, List<int>>();
// 创建角色天数
public static int CreateRoleDays = 0;
//会试殿试资格在关闭弹出的UI之后不再打开
public static bool HasOpenedImperialExamPanel = false;
//第一次进入场景同步配置
public static bool IsFirstTimeEnterScene = true;
// 监视是否第一次同步数据 - 现在同步数据要等到第一次同步等级才完整
// 暂时使用Hack的方法同步
public static bool HasSubmitLoginData;
//交互等待CD
public static float _InteractionLastMessageTime = 0.0f;
//存放快捷Item
public static Dictionary<ulong, int> m_ItemStackCounDic = new Dictionary<ulong, int>();
public static List<ulong> MyShortCutItemGuidList = new List<ulong>();
//存放背包物品数量
public static Dictionary<int, int> MtItemCountDic = new Dictionary<int, int>();
//选择时装(UICameraTexture中对武器时装进行特殊处理)
public static bool IsSelectedWeaponFashion = false;
//进场景的时候默认的武器Id
//public static int EnterSceneWeaponId = -1;
//是否舒刷新快捷使用的Item
public static bool _IsRefreshShortcutItem = false;
//popNotice缓存
public static List<string> PopNoticeList = new List<string>();
//获取开启的最大等级的特权VIP
//public static int GetMaxPrivilegeLevel()
//{
// var _level = -1;
// foreach(var vip in GameManager.gameManager.PlayerDataPool.PrivilegeTypeStateDic)
// {
// if(vip.Value)
// {
// if (vip.Key > _level)
// _level = vip.Key;
// }
// }
// return _level;
//}
public static Dictionary<int, int> FubenIdDic;
// 不去分入口或者子页面
public static bool IsMarketingActActive(int actID)
{
if (CurMarketingActDic.ContainsKey(actID))
return true;
foreach (var kv in CurMarketingActDic)
if (kv.Value.Contains(actID))
return true;
return false;
}
public static bool IsInSpecialScene()
{
var sceneClass = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
if (sceneClass == null) return true;
if (sceneClass.CanEnterSpecialActivity != 1)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{51001}"));
return true;
}
return false;
}
public static int GetCharModelId(int profession, int modelVisualId)
{
var itemVisual = TableManager.GetItemVisualByID(modelVisualId);
if (itemVisual != null)
switch (profession)
{
case (int) CharacterDefine.PROFESSION.TIANJI:
return itemVisual.CharModelIDShaoLin;
case (int) CharacterDefine.PROFESSION.LIUSHAN:
return itemVisual.CharModelIDTianShan;
case (int) CharacterDefine.PROFESSION.SHUSHAN:
return itemVisual.CharModelIDDaLi;
case (int) CharacterDefine.PROFESSION.XUANNV:
return itemVisual.CharModelIDXiaoYao;
}
return -1;
}
public static int GetCurSceenFubenId()
{
if (FubenIdDic == null)
{
FubenIdDic = new Dictionary<int, int>();
foreach (var tab in TableManager.GetFuben())
if (!FubenIdDic.ContainsKey(tab.Value.GetSceneIdbyIndex(0)))
FubenIdDic.Add(tab.Value.GetSceneIdbyIndex(0), tab.Key);
}
if (FubenIdDic.ContainsKey(GameManager.gameManager.RunningScene))
return FubenIdDic[GameManager.gameManager.RunningScene];
return -1;
}
public static Tab_PrivilegeFunction GetPrivilegeByPrivilegeId(int PrivilegeId)
{
foreach (var info in TableManager.GetPrivilegeFunction().Values)
if (info.PrivilegeId == PrivilegeId) //限购次数
return info;
return null;
}
public static int GetVipLimitBuyCount()
{
var limitCount = 0;
var vipLevel = GameManager.gameManager.PlayerDataPool.VipCost;
Tab_PrivilegeFunction privilegeFuncTab = null;
foreach (var info in TableManager.GetPrivilegeFunction().Values)
if (info.PrivilegeId == 8) //限购次数
{
privilegeFuncTab = info;
break;
}
if (privilegeFuncTab != null)
limitCount = int.Parse(privilegeFuncTab.GetVipbyIndex(GameManager.gameManager.PlayerDataPool.VipCost));
return limitCount;
}
//更换模型
//穿戴武器时装
public static string GetBingPointString(int effectId, int charModelType)
{
var effectTab = TableManager.GetEffectByID(effectId);
return effectTab == null ? string.Empty : GetBingPointString(effectTab, charModelType);
}
//获取特效的绑定点
public static string GetBingPointString(Tab_Effect effectTab, int charModelType)
{
var effectPoint = TableManager.GetEffectPointByID(charModelType);
if (effectPoint == null) return string.Empty;
if (effectTab.ParentName.Equals("CenterPoint"))
return effectPoint.CenterPoint;
if (effectTab.ParentName.Equals("HeadPoint"))
return effectPoint.HeadPoint;
if (effectTab.ParentName.Equals("LHandPoint"))
return effectPoint.LHandPoint;
if (effectTab.ParentName.Equals("RHandPoint"))
return effectPoint.RHandPoint;
if (effectTab.ParentName.Equals("LFootPoint"))
return effectPoint.LFootPoint;
if (effectTab.ParentName.Equals("Weapon_L"))
return effectPoint.WeaponL;
if (effectTab.ParentName.Equals("Weapon_R"))
return effectPoint.WeaponR;
return effectPoint.RFootPoint;
}
//获取FshionItemId
public static int GetFshionItemIdByDataId(int dataId)
{
var hasFind = false;
var fashionId = -1;
var fashionItemDic = TableManager.GetFashionItem().Values;
foreach (var item in fashionItemDic)
for (var index = 0; index < item.getCommonitemIdCount(); index++)
if (item.GetCommonitemIdbyIndex(index) == dataId)
{
fashionId = item.Id;
hasFind = true;
break;
}
if (!hasFind)
return -1;
return fashionId;
}
public static bool CanUseMedicItem(int itmeId)
{
var sceneClass = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene);
if (sceneClass == null) return false;
var commonItem = TableManager.GetCommonItemByID(itmeId);
if (commonItem == null) return false;
// 0-不可用药1-可以用药2-只允许用红药3-只允许用蓝药。不区分是否动态
if (sceneClass.CanUseMedic == 0)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{47022}"));
return false;
}
if (sceneClass.CanUseMedic == 2 && (commonItem.SubClassID == (int) MedicSubClass.MP_DY ||
commonItem.SubClassID != (int) MedicSubClass.MP))
{
// 只允许用红药(包括动态)
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{47022}"));
return false;
}
if (sceneClass.CanUseMedic == 3 && (commonItem.SubClassID == (int) MedicSubClass.HP_DY ||
commonItem.SubClassID != (int) MedicSubClass.HP))
{
// 只允许用蓝药(包括动态)
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{47022}"));
return false;
}
if (ItemCDInfoCtr.GetItemCDRemainTime(itmeId) > 0)
{
if (commonItem.SubClassID != (int) MedicSubClass.HP_DY && commonItem.SubClassID != (int) MedicSubClass.MP_DY
) GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1298}")); //自动使用的药品不能使用的时候不弹出提示
return false;
}
var curHP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.HP;
var maxHP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.MaxHP;
var curMP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.MP;
var maxMP = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.MaxMP;
if (commonItem != null)
{
if (commonItem.MinLevelRequire > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
{
if (commonItem.SubClassID != (int) MedicSubClass.HP_DY &&
commonItem.SubClassID != (int) MedicSubClass.MP_DY) //动态等级判断不弹提示
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{42707}"));
return false;
}
if (commonItem.ClassID == (int) ItemClass.MEDIC)
{
if (commonItem.SubClassID == (int) MedicSubClass.HP
|| commonItem.SubClassID == (int) MedicSubClass.HP_DY)
{
if (curHP < maxHP) return true;
if (commonItem.SubClassID != (int) MedicSubClass.HP_DY)
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6014}"));
return false;
}
if (commonItem.SubClassID == (int) MedicSubClass.MP
|| commonItem.SubClassID == (int) MedicSubClass.MP_DY)
{
if (curMP < maxMP) return true;
if (commonItem.SubClassID != (int) MedicSubClass.MP_DY)
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6015}"));
return false;
}
}
return false;
}
return false;
}
public static bool CanDragSkillBySkillIndex(int index)
{
var curSkillBaseId = Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo[index].SkillBaseTable.Id;
if (curSkillBaseId == 412 || curSkillBaseId == 413
|| curSkillBaseId == 322 || curSkillBaseId == 323
|| curSkillBaseId == 109 || curSkillBaseId == 110
|| curSkillBaseId == 222 || curSkillBaseId == 223)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1309}"));
return false;
}
return true;
}
// 是否开启聚宝盆
public static bool IsOpenPrecious()
{
if (null == GameManager.gameManager) return false;
if (!GameManager.gameManager.PlayerDataPool.IsHaveGuild()) return false;
var curTime = Utils.GetServerDateTime();
if (curTime.Hour >= 20 && curTime.Hour < 22) return true;
return false;
}
public static bool IsOpenWar()
{
if (null == GameManager.gameManager) return false;
if (!GameManager.gameManager.PlayerDataPool.IsHaveGuild()) return false;
var curTime = Utils.GetServerDateTime();
if (curTime.DayOfWeek == DayOfWeek.Wednesday || curTime.DayOfWeek == DayOfWeek.Thursday ||
curTime.DayOfWeek == DayOfWeek.Saturday || curTime.DayOfWeek == DayOfWeek.Sunday)
if (curTime.Hour == 21)
return true;
return false;
}
public static int ActivityNextStartTimeOnSecond(int activityType)
{
Tab_ActivityBase activityBase = null;
var activityBases = TableManager.GetActivityBase().Values;
foreach (var activity in activityBases)
if (activity.ActivityServerType == activityType)
{
activityBase = activity;
break;
}
if (activityBase == null)
return -1;
var curTime = Utils.GetServerDateTime();
var m_TabOnDay = activityBase.Recurrent.Split('|');
for (var index = 0; index < m_TabOnDay.Length; index++)
{
var nextDay = int.Parse(m_TabOnDay[index]);
if ((int) curTime.DayOfWeek == nextDay)
for (var j = 0; j < activityBase.getTimeCount(); j++)
{
if (activityBase.GetTimebyIndex(j) == "-1")
continue;
var m_TabOnHour = activityBase.GetTimebyIndex(j).Split('|');
if (m_TabOnHour.Length < 2)
continue;
var start = 0;
if (int.TryParse(m_TabOnHour[0], out start))
if (curTime.Hour * 100 + curTime.Minute < start)
{
var hour = start / 100;
var minute = start % 100;
var totlesecond = (hour - curTime.Hour) * 3600 + (minute - curTime.Minute) * 60 +
curTime.Second - 60;
return totlesecond;
}
}
if ((int) curTime.DayOfWeek < nextDay)
{
var m_TabOnHour = activityBase.GetTimebyIndex(0).Split('|');
if (m_TabOnHour.Length < 2)
continue;
var start = 0;
if (int.TryParse(m_TabOnHour[0], out start))
{
var day = nextDay - (int) curTime.DayOfWeek;
var hour = start / 100;
var minute = start % 100;
var totlesecond = (hour - curTime.Hour) * 3600 + (minute - curTime.Minute) * 60 + curTime.Second -
60 + day * 24 * 3600;
return totlesecond;
}
}
}
var m_TabOnHour1 = activityBase.GetTimebyIndex(0).Split('|');
if (m_TabOnHour1.Length < 2)
return -1;
var start1 = 0;
if (int.TryParse(m_TabOnHour1[0], out start1))
{
var day = 7 - (int) curTime.DayOfWeek;
var hour = start1 / 100;
var minute = start1 % 100;
var totlesecond = (hour - curTime.Hour) * 3600 + (minute - curTime.Minute) * 60 + curTime.Second - 60 +
day * 24 * 3600 * 60;
return totlesecond;
}
return -1;
}
public static bool IsChristmasOpen()
{
if (!IsOpenChristmas) return false;
var curTime = Utils.GetServerDateTime();
var startTime = new DateTime(1970, 1, 1, 0, 0, 0);
//开始时间
var BeginTime = new DateTime(startTime.Ticks + ChristmasStartTime * 10000000L, DateTimeKind.Utc);
//BeginTime = BeginTime.ToLocalTime();
BeginTime = BeginTime.AddHours(8); //调到北京时间
//结束时间
var EndTime = new DateTime(startTime.Ticks + ChristmasEndTime * 10000000L, DateTimeKind.Utc);
//EndTime = EndTime.ToLocalTime();
EndTime = EndTime.AddHours(8); //调到北京时间
return curTime >= BeginTime && curTime <= EndTime;
}
}