123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 游戏数据管理
- /// </summary>
- public class GameDateManager
- {
- // <summary>
- /// 单键
- /// </summary>
- private static GameDateManager m_Instance;
- /// <summary>
- /// 单键
- /// </summary>
- public static GameDateManager Instance
- {
- get
- {
- if (m_Instance == null)
- {
- m_Instance = new GameDateManager();
- }
- return m_Instance;
- }
- }
- /// <summary>
- /// 游戏开始时间
- /// </summary>
- private float _gameStartTime = 0;
- /// <summary>
- /// 游戏时间
- /// </summary>
- public void SetGameTime(float runTime)
- {
- _gameStartTime = runTime;
- }
- /// <summary>
- /// 获取游戏时间
- /// </summary>
- /// <returns></returns>
- public float GetGameTime()
- {
- return _gameStartTime;
- }
- /// <summary>
- /// 玩家死亡人数
- /// </summary>
- public int PlayerDeathNumber { get; set; }
- /// <summary>
- /// 玩家受击次数
- /// </summary>
- public int PlayerBehitCount { get; set; }
- /// <summary>
- /// 指定玩家
- /// </summary>
- public bool HaveAppointPlayer { get; set; }
- /// <summary>
- /// 对战信息
- /// </summary>
- public VSHeroInfo VsInfo { get; set; }
- /// <summary>
- /// 指定玩家
- /// </summary>
- public List<int> appointPlayers = new List<int>();
- public bool isMultiRoom = false;
- /// <summary>
- /// 检测是否有指定玩家
- /// </summary>
- /// <param name="heros"></param>
- public void CheckHaveAppointPlayers(List<GameHeroVo> heros)
- {
- for (int i = 0; i < heros.Count; i++)
- {
- if (heros[i] == null)
- {
- continue;
- }
- if (appointPlayers.Contains(int.Parse(heros[i].typeId)))
- {
- HaveAppointPlayer = true;
- return;
- }
- }
- HaveAppointPlayer = false;
- }
- /// <summary>
- /// 玩家总连击次数
- /// </summary>
- public int PlayerComboCount { get; set; }
- /// <summary>
- /// 玩家使用必杀技的次数
- /// </summary>
- public int PlayerUseSkillCount { get; set; }
- public BattleDefine.EBattleSceneType lastBattleType = BattleDefine.EBattleSceneType.EBattleType_Default;
- public bool IsNotBattleScene()
- {
- if(lastBattleType == BattleDefine.EBattleSceneType.EBattleType_Safe)
- {
- return true;
- }
- else if (lastBattleType == BattleDefine.EBattleSceneType.EBattleType_YanJiuSuo)
- {
- return true;
- }
- else if (lastBattleType == BattleDefine.EBattleSceneType.EBattleType_HuanLingShi)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 清理
- /// </summary>
- public void Clear()
- {
- _gameStartTime = 0;
- PlayerDeathNumber = 0;
- PlayerBehitCount = 0;
- PlayerComboCount = 0;
- PlayerUseSkillCount = 0;
- GateStar = 3;
- }
- /// <summary>
- /// 前往关卡
- /// </summary>
- public bool gotoGate = false;
- /// <summary>
- /// 大陆 ID
- /// </summary>
- public int LandID { get; set; }
- /// <summary>
- /// 关卡章节
- /// </summary>
- public int ZoneID { get; set; }
- /// <summary>
- /// 即将前往的 关卡 ID
- /// </summary>
- public int GateID { get; set; }
- /// <summary>
- /// 前往下一张地图之前的ID
- /// </summary>
- public int OldGateID { get; set; }
- /// <summary>
- /// 角色地图 出生点(场景切换器)
- /// </summary>
- public int CreateMapSwitchPoint { get; set; }
- /// <summary>
- /// 是否 传送门 返回传送点
- /// </summary>
- public bool IsBackDoor { get; set; }
- /// <summary>
- /// 回城
- /// </summary>
- public bool isBackTicket { get; set; }
- /// <summary>
- /// 死亡回城
- /// </summary>
- public bool isBackDie = false;
- public int CreateMapId { get; set; }
- /// <summary>
- /// 返回 回城点的位置
- /// </summary>
- public Vector3 CreatePosition { get; set; }
- /// <summary>
- /// 世界BOSS ID
- /// </summary>
- public int WordBossID { get; set; }
- /// <summary>
- /// 关卡难度
- /// </summary>
- public int GateDifficulty { get; set; }
- /// <summary>
- /// 关卡星级
- /// </summary>
- public int GateStar = 3;
- /// <summary>
- /// 当前无尽任务进度序号
- /// </summary>
- public int EndlessIndex = 1;
- /// <summary>
- /// 关卡数据
- /// </summary>
- public UIVO_Gate.SelectGateVo GateVO = null;
- /// <summary>
- /// 当前选中的英雄龙骨资源名称
- /// </summary>
- public string HeroDragonBonesName { get; set; }
- /// <summary>
- /// 通关条件是否OK
- /// </summary>
- /// <param name="conditionType">通关条件类型</param>
- /// 1.通关耗时不超过n秒, 参数: n秒
- /// 2.无人阵亡下通关, 参数: 无
- /// 3.唤灵师血量高于n%, 参数: n
- /// 4.装备指定言灵,参数: 言灵TypeId
- /// 5.至少装备n个指定x属性的言灵,参数: 数量n,元素类型s(见言灵表weaktype)
- /// 6.开启关卡内所有宝箱, 参数: 无 default(0)
- /// <param name="conditionParas">参数</param>
- /// <returns></returns>
- public bool GameGateOK(sm_gate_passCondition condition)
- {
- int conditionType = condition.conditionType;
- List<int> iParas = condition.GetParas();
- int val1 = 0;
- int val2 = 0;
- if (iParas.Count >= 2)
- {
- val1 = iParas[0];
- val2 = iParas[1];
- }
- else if (iParas.Count >= 1)
- {
- val1 = iParas[0];
- }
- switch (conditionType)
- {
- case 1:// 通关耗时不超过n秒, 参数: n秒
- {
- if (GetGameTime() <= val1)
- {
- return true;
- }
- }
- break;
- case 2:// 无人阵亡下通关, 参数: 无
- {
- if (PlayerDeathNumber <= val1)
- {
- return true;
- }
- }
- break;
- case 3:// 唤灵师血量高于n%, 参数: n
- Role role = RoleManager.Instance.GetPlayer();
- int hpVal = 100;
- if (role != null)
- {
- hpVal = role.mData.HP_Final * 100 / role.mData.MaxHP_Final;
- }
- if (hpVal >= val1)
- {
- return true;
- }
- break;
- case 4:// 装备指定言灵,参数: 言灵TypeId
- {
- return UserProxy.Instance.player.heroTeamConfig.CurTeam.IsWearingXYanling(val1);
- }
- break;
- case 5:// 至少装备n个指定x属性的言灵,参数: 数量n,元素类型s(见言灵表weaktype)
- {
- return UserProxy.Instance.player.heroTeamConfig.CurTeam.IsWearingN_XProperty_Yanling(val1, val2);
- }
- break;
- case 6:// 开启关卡内所有宝箱, 参数: 无 default(0)
- {
- return SceneCmptManager.Instance.IsAllTreasureBoxFinish();
- }
- break;
- }
- return false;
- }
- }
|