435 lines
14 KiB
C#
435 lines
14 KiB
C#
using System.Collections.Generic;
|
|
using Games.GlobeDefine;
|
|
using GCGame.Table;
|
|
using UnityEngine;
|
|
using Games.LogicObj;
|
|
|
|
public class WorldBossData
|
|
{
|
|
private static WorldBossData _instance = null;
|
|
public static WorldBossData Instance
|
|
{
|
|
get
|
|
{
|
|
return _instance != null ? _instance : (_instance = new WorldBossData());
|
|
}
|
|
}
|
|
|
|
public void BossRedTip()
|
|
{
|
|
bool isShow = (m_VipFreeLeaveTimes > 0 || BossActivityIsEnough());
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.WorldBoss, m_WorldKillRewardTimes > 0 || m_WorldLastKillRewardTimes > 0);
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.HomeBoss, m_HomeKillRewardTimes > 0 || m_HomeLastKillRewardTimes > 0);
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.PrivateBoss, isShow);
|
|
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.Boss, (isShow || m_WorldKillRewardTimes > 0 || m_HomeKillRewardTimes > 0));
|
|
}
|
|
|
|
private bool BossActivityIsEnough()
|
|
{
|
|
Dictionary<int, Tab_PrivateBoss> bossInfos = TableManager.GetPrivateBoss();
|
|
foreach (var boss in bossInfos)
|
|
{
|
|
if (boss.Value.ActivityValue <= GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.CurStamina
|
|
&& boss.Value.Level <= GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
|
|
return true;
|
|
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int m_CurrentShowBossId = -1;
|
|
private int m_VipFreeUseTimes;
|
|
private int m_VipFreeLeaveTimes;
|
|
public int VipFreeLeaveTimes
|
|
{
|
|
get { return m_VipFreeLeaveTimes; }
|
|
}
|
|
|
|
public int VipCanUseLevel = 0; //可使用的VIP最高等级
|
|
public void VipFreeTimes()
|
|
{
|
|
VipCanUseLevel = 0;
|
|
foreach (var tab in TableManager.GetPrivilegeFunction())
|
|
{
|
|
if (tab.Value.PrivilegeId == 19)
|
|
{
|
|
var vipId = TableManager.GetVipIdoitInChargeByID(GameManager.gameManager.PlayerDataPool.ExperIvpLevel, 0);
|
|
if (vipId != null && GameManager.gameManager.PlayerDataPool.ExperIvpLevel != 0)
|
|
VipCanUseLevel = vipId.Param;
|
|
if (VipCanUseLevel < GameManager.gameManager.PlayerDataPool.VipCost)
|
|
VipCanUseLevel = GameManager.gameManager.PlayerDataPool.VipCost;
|
|
int vipUseTimes;
|
|
if (int.TryParse(tab.Value.GetVipbyIndex(VipCanUseLevel), out vipUseTimes))
|
|
m_VipFreeLeaveTimes = vipUseTimes - m_VipFreeUseTimes;
|
|
else
|
|
Debug.LogError("Vip data is not int32!");
|
|
break;
|
|
}
|
|
}
|
|
BossRedTip();
|
|
}
|
|
|
|
public void SetVipFree(int times)
|
|
{
|
|
m_VipFreeUseTimes = times;
|
|
VipFreeTimes();
|
|
}
|
|
|
|
private int m_WorldLastKillRewardTimes;
|
|
public int WorldLastKillRewardTimes
|
|
{
|
|
get { return m_WorldLastKillRewardTimes; }
|
|
}
|
|
|
|
private int m_HomeLastKillRewardTimes;
|
|
public int HomeLastKillRewardTimes
|
|
{
|
|
get { return m_HomeLastKillRewardTimes; }
|
|
}
|
|
|
|
private int m_WorldKillRewardTimes;
|
|
public int WorldKillRewardTimes
|
|
{
|
|
get { return m_WorldKillRewardTimes; }
|
|
}
|
|
|
|
private int m_HomeKillRewardTimes;
|
|
public int HomeKillRewardTimes
|
|
{
|
|
get { return m_HomeKillRewardTimes; }
|
|
}
|
|
|
|
public void SetLastKillReward(AckBossHomeUserInfo ackBossHomeUserInfo)
|
|
{
|
|
m_WorldLastKillRewardTimes = ackBossHomeUserInfo.worldbosslastkillawardtimesmax - ackBossHomeUserInfo.worldbosslastkillawardtimes;
|
|
m_HomeLastKillRewardTimes = ackBossHomeUserInfo.bosshomelastkillawardtimesmax - ackBossHomeUserInfo.bosshomelastkillawardtimes;
|
|
m_WorldKillRewardTimes = ackBossHomeUserInfo.worldbosskillawardtimesmax - ackBossHomeUserInfo.worldbosskillawardtimes;
|
|
m_HomeKillRewardTimes = ackBossHomeUserInfo.bosshomekillawardtimesmax - ackBossHomeUserInfo.bosshomekillawardtimes;
|
|
BossRedTip();
|
|
}
|
|
|
|
public static void DestroyData()
|
|
{
|
|
_instance = null;
|
|
}
|
|
|
|
public class BossInfo
|
|
{
|
|
public int m_BossTabId;
|
|
public WorldBossPlayerInfo m_LastKiller;
|
|
public int m_LeaveBloodRate;
|
|
public int m_DugUseTimes;
|
|
public int m_DugLeaveTimes;
|
|
public float m_LeaveTime;
|
|
public bool m_Killed;
|
|
}
|
|
|
|
public void AskHomeBossInfo()
|
|
{
|
|
ReqBossHomeUserInfo cmd = new ReqBossHomeUserInfo();
|
|
cmd.SendMsg();
|
|
|
|
ReqPrivateBossUserInfo cmd1 = new ReqPrivateBossUserInfo();
|
|
cmd1.SendMsg();
|
|
}
|
|
|
|
public void SendAskData()
|
|
{
|
|
Module.Log.LogModule.DebugLog("World Boss SendAskData");
|
|
AskWorldBossInfo cmd = new AskWorldBossInfo();
|
|
cmd.activity_type = (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_WORLD_BOSS;
|
|
cmd.SendMsg();
|
|
|
|
//AskWorldBossInfo cmd1 = new AskWorldBossInfo();
|
|
//cmd1.activity_type = (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_CROSSSERVERBOSS;
|
|
//cmd1.SendMsg();
|
|
}
|
|
|
|
public void SendAskRankData(int profession)
|
|
{
|
|
AskWorldBossLastRankInfo cmd = new AskWorldBossLastRankInfo();
|
|
cmd.npcId = m_CurrentShowBossId;
|
|
cmd.professionId = profession;
|
|
cmd.SendMsg();
|
|
}
|
|
|
|
public void SendAskDug(int bossId,byte state)
|
|
{
|
|
WorldBossTreasure cmd = new WorldBossTreasure();
|
|
cmd.npcId = bossId;
|
|
cmd.isall = state;
|
|
cmd.SendMsg();
|
|
}
|
|
|
|
private Dictionary<int, BossInfo> m_BossInfos = new Dictionary<int, BossInfo>();
|
|
public BossInfo GetBossInfo(int Id)
|
|
{
|
|
if (m_BossInfos.ContainsKey(Id) == false)
|
|
return null;
|
|
return m_BossInfos[Id];
|
|
}
|
|
|
|
public void DugTimesChange(int bossId,int LeaveTimes,int UseTimes)
|
|
{
|
|
BossInfo boss = m_BossInfos.ContainsKey(bossId) ? m_BossInfos[bossId] : null;
|
|
if(boss!=null)
|
|
{
|
|
boss.m_DugLeaveTimes = LeaveTimes;
|
|
boss.m_DugUseTimes = UseTimes;
|
|
m_BossInfos[bossId] = boss;
|
|
}
|
|
}
|
|
|
|
public void AddOneBoss(WorldBossInfo boss)
|
|
{
|
|
BossInfo info = new BossInfo();
|
|
if(m_BossInfos.ContainsKey(boss.npcId))
|
|
{
|
|
info = m_BossInfos[boss.npcId];
|
|
}
|
|
info.m_BossTabId = boss.npcId;
|
|
info.m_DugUseTimes = boss.usedDigTimes;
|
|
info.m_DugLeaveTimes = boss.remainDigTimes;
|
|
info.m_Killed = (boss.beKilled == 1 ? true : false);
|
|
info.m_LastKiller = boss.lastKiller;
|
|
info.m_LeaveBloodRate = boss.remainBloodRate;
|
|
m_BossInfos[info.m_BossTabId] = info;
|
|
}
|
|
|
|
#region //记录一下BOSS相关场景的信息 主要是WorldBoss这张表格
|
|
Dictionary<int, BossSceneInfo> m_BossSceneInfos = new Dictionary<int, BossSceneInfo>();
|
|
public class BossSceneInfo
|
|
{
|
|
public int SceneId;
|
|
public int FubenId;
|
|
public int BossType; //1 世界BOSS 2 BOSS之家 3跨服BOSS
|
|
public int LimitLevel;
|
|
public int VipFreeLevel;
|
|
|
|
public BossSceneInfo()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
SceneId = -1;
|
|
FubenId = -1;
|
|
BossType = -1;
|
|
LimitLevel = 0;
|
|
VipFreeLevel = 0;
|
|
}
|
|
}
|
|
private void InitBossSceneInfo()
|
|
{
|
|
m_BossSceneInfos.Clear();
|
|
Dictionary<int, Tab_WorldBoss> bossInfos = TableManager.GetWorldBoss();
|
|
foreach (var boss in bossInfos)
|
|
{
|
|
if (m_BossSceneInfos.ContainsKey(boss.Value.SceneID))
|
|
continue;
|
|
|
|
BossSceneInfo info = new BossSceneInfo();
|
|
info.SceneId = boss.Value.SceneID;
|
|
info.FubenId = boss.Value.FubenID;
|
|
info.LimitLevel = boss.Value.Level;
|
|
info.BossType = boss.Value.Type;
|
|
info.VipFreeLevel = boss.Value.VipLevel;
|
|
m_BossSceneInfos[info.SceneId] = info;
|
|
}
|
|
}
|
|
public bool IsInHomeBossFuben(int sceneID = -1)
|
|
{
|
|
if(m_BossSceneInfos.Count<=0)
|
|
{
|
|
InitBossSceneInfo();
|
|
}
|
|
return m_BossSceneInfos.ContainsKey(sceneID) && m_BossSceneInfos[sceneID].BossType == 2;
|
|
}
|
|
|
|
public int SceneVipLevel(int sceneID)
|
|
{
|
|
if (m_BossSceneInfos.ContainsKey(sceneID) == false)
|
|
return 0;
|
|
return m_BossSceneInfos[sceneID].VipFreeLevel;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region//记录当前场景BOSS信息
|
|
|
|
public class SceneBossInfo
|
|
{
|
|
public int BossID; //WorldBoss.txt
|
|
public int BossType;
|
|
public int BossLevel;
|
|
public string BossName;
|
|
public string NameDesc;
|
|
public int LeaveBlood;
|
|
public bool BeKilled;
|
|
public List<long> ServerAttacksValue;
|
|
public float OverTime;
|
|
|
|
public SceneBossInfo()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
BossID = -1;
|
|
BossType = -1;
|
|
BossName = "";
|
|
NameDesc = "";
|
|
LeaveBlood = 100;
|
|
BeKilled = false;
|
|
ServerAttacksValue = new List<long>();
|
|
OverTime = 0;
|
|
}
|
|
}
|
|
private int _LastSceneId = -1;
|
|
private int _BossSceneType = -1;
|
|
public int BossSceneType
|
|
{
|
|
get { return _BossSceneType; }
|
|
}
|
|
List<SceneBossInfo> m_SceneBossInfos = new List<SceneBossInfo>(); //当前场景BOSS信息
|
|
public int SceneBossCount()
|
|
{
|
|
return m_SceneBossInfos.Count;
|
|
}
|
|
|
|
public List<SceneBossInfo> GetSceneBossList()
|
|
{
|
|
return m_SceneBossInfos;
|
|
}
|
|
|
|
public int AliveBossCount()
|
|
{
|
|
int Count = 0;
|
|
for (int j = 0; j < m_SceneBossInfos.Count; j++)
|
|
{
|
|
if (m_SceneBossInfos[j].BeKilled == false)
|
|
{
|
|
Count++;
|
|
}
|
|
}
|
|
return Count;
|
|
}
|
|
|
|
public void InitSceneBossList()
|
|
{
|
|
if (_LastSceneId > 0 && _LastSceneId == GameManager.gameManager.RunningScene)
|
|
return;
|
|
_LastSceneId = GameManager.gameManager.RunningScene;
|
|
_BossSceneType = -1;
|
|
m_SceneBossInfos.Clear();
|
|
Dictionary<int, Tab_WorldBoss> bossInfos = TableManager.GetWorldBoss();
|
|
foreach (var boss in bossInfos)
|
|
{
|
|
if (boss.Value.SceneID != GameManager.gameManager.RunningScene)
|
|
continue;
|
|
Tab_RoleBaseAttr role = TableManager.GetRoleBaseAttrByID(boss.Value.Id, 0);
|
|
if (role == null)
|
|
continue;
|
|
SceneBossInfo info = new SceneBossInfo();
|
|
info.BossID = boss.Value.Id;
|
|
info.BossName = role.Name;
|
|
info.BossLevel = boss.Value.Level;
|
|
info.OverTime = 0;
|
|
info.BossType = boss.Value.Type;
|
|
if (boss.Value.Type == 1 || boss.Value.Type == 2)
|
|
{
|
|
info.NameDesc = string.Format("LV.{0} BOSS_{1}", info.BossLevel, info.BossName);
|
|
}
|
|
if (boss.Value.Type == 3)
|
|
{
|
|
info.NameDesc = string.Format("{0} 100%", info.BossName);
|
|
}
|
|
m_SceneBossInfos.Add(info);
|
|
_BossSceneType = boss.Value.Type;
|
|
}
|
|
|
|
if (CrossServerBossInfo.Instance != null && CrossServerBossInfo.Instance.gameObject.activeInHierarchy)
|
|
CrossServerBossInfo.Instance.Close_Detial();
|
|
}
|
|
|
|
public void HomeBossInfo(AckBossHomeBossState bossState)
|
|
{
|
|
for (int i = 0; i < bossState.bossid.Count; i++)
|
|
{
|
|
for (int j = 0; j < m_SceneBossInfos.Count; j++)
|
|
{
|
|
if (m_SceneBossInfos[j].BossID == bossState.bossid[i])
|
|
{
|
|
if (bossState.birthtime[i] <= 0)
|
|
{
|
|
m_SceneBossInfos[j].OverTime = 0;
|
|
}
|
|
else
|
|
{
|
|
m_SceneBossInfos[j].OverTime = (int)Time.realtimeSinceStartup + bossState.birthtime[i] - GlobalData.ServerAnsiTime;
|
|
}
|
|
|
|
m_SceneBossInfos[j].LeaveBlood = bossState.curhp[i];
|
|
m_SceneBossInfos[j].BeKilled = (m_SceneBossInfos[j].LeaveBlood <= 0);
|
|
Module.Log.LogModule.DebugLog("AckBossHomeBossState " + m_SceneBossInfos[j].BossName + " : " + m_SceneBossInfos[j].LeaveBlood +" : " + bossState.birthtime[i]);
|
|
if (m_SceneBossInfos[j].BossType == 3)
|
|
{
|
|
m_SceneBossInfos[j].NameDesc = string.Format("{0} {1}%", m_SceneBossInfos[j].BossName, m_SceneBossInfos[j].LeaveBlood);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ServerAttackData(RetCrossWBGroupList binaryMsg)
|
|
{
|
|
if (binaryMsg.fubenid != GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID)
|
|
return;
|
|
for (int i = 0; i < m_SceneBossInfos.Count; i++)
|
|
{
|
|
if (m_SceneBossInfos[i].BossID == binaryMsg.bossid)
|
|
{
|
|
m_SceneBossInfos[i].ServerAttacksValue.Clear();
|
|
m_SceneBossInfos[i].ServerAttacksValue.AddRange(binaryMsg.damage);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//计算玩家附近BOSS数
|
|
public int CountNearlyBoss(float radius)
|
|
{
|
|
Obj_MainPlayer mainPlayer = Singleton<ObjManager>.Instance.MainPlayer;
|
|
if (mainPlayer == null)
|
|
return 0;
|
|
int Count = 0;
|
|
Vector2 mainPos = new Vector2(mainPlayer.Position.x, mainPlayer.Position.z);
|
|
for(int i=0;i<m_SceneBossInfos.Count;i++)
|
|
{
|
|
if (m_SceneBossInfos[i].BeKilled == false)
|
|
continue;
|
|
Tab_WorldBoss worldBossTab = TableManager.GetWorldBossByID(m_SceneBossInfos[i].BossID, 0);
|
|
if (Vector2.Distance(mainPos, new Vector2(worldBossTab.PosX, worldBossTab.PosZ)) <= radius)
|
|
Count++;
|
|
}
|
|
return Count;
|
|
}
|
|
|
|
Tab_Fuben m_fubenInfo = null;
|
|
public Tab_Fuben GetFubenInfo()
|
|
{
|
|
if (m_fubenInfo != null && (m_fubenInfo.Id == GameManager.gameManager.RunningScene || m_fubenInfo.Id == GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID))
|
|
return m_fubenInfo;
|
|
m_fubenInfo = TableManager.GetFubenByID(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID, 0);
|
|
if (m_fubenInfo == null)
|
|
m_fubenInfo = TableManager.GetFubenByID(GameManager.gameManager.RunningScene, 0);
|
|
return m_fubenInfo;
|
|
}
|
|
|
|
#endregion
|
|
|
|
} |