static public void LoadHandler(LoadedData data) { JsonData jsonData = JsonMapper.ToObject(data.Value.ToString()); if (!jsonData.IsArray) { return; } for (int index = 0; index < jsonData.Count; index++) { JsonData element = jsonData[index]; SkillsPO po = new SkillsPO(element); SkillsData.Instance.m_dictionary.Add(po.Id, po); } }
/// <summary> /// 提供外部接口,初始化Boss数据 /// </summary> /// <param name="po"></param> public override void InitPO(AgentPO po) { _health = po.Health; _worth = po.Score; _moveSpeed = po.Speed; _agentID = po.Id; _moveOrRate = po.MoveOrProRate; _coolDic.Clear(); for (int i = 0; i < po.Skills.Length; ++i) { int skillID = po.Skills[i]; SkillsPO skill = SkillsData.Instance.GetSkillsPO(skillID); if (!_coolDic.ContainsKey(skill)) { _coolDic.Add(skill, skill.CoolTime); } } }
/// <summary> /// /// </summary> protected override void FSMUpdate() { SkillsPO[] array = new SkillsPO[_coolDic.Count]; _coolDic.Keys.CopyTo(array, 0); for (int i = 0; i < array.Length; ++i) { if (_coolDic[array[i]] > 0) { _coolDic[array[i]] -= Time.deltaTime; } else { // 重新冷却 _coolDic[array[i]] = 99; // 可用一个字典存储所有技能对应的冷却时间 //coolDic[array[i]] = MonsterPO.CoolTime; _skillQueue.Enqueue(array[i]); } } // 上个技能播放完毕, 如技能队列里还有技能,等待2秒再播放 if (_animationEnd) { if (_interval > 0) { _interval -= Time.deltaTime; } else { _canPlayNext = true; _animationEnd = false; } } // 播放下个技能 if (_canPlayNext && _skillQueue.Count > 0) { _skillPO = _skillQueue.Dequeue(); } UpdatePreFrame(); }