public void SetSkillCD(int skillID, float cd) { SkillCDData tmpData = null; for (int i = 0, max = mSkillCDs.Count; i < max; ++i) { if (mSkillCDs[i].SkillID == skillID) { tmpData = mSkillCDs[i]; break; } } if (null == tmpData) { tmpData = new SkillCDData(); tmpData.SkillID = skillID; mSkillCDs.Add(tmpData); } tmpData.CD = cd; var tmpEvent = ReferencePool.Fetch <PlayerCtrlEvent.UpdateSkillCD>(); tmpEvent.SkillID = skillID; tmpEvent.CD = cd; Game.EventMgr.FireNow(this, tmpEvent); }
public bool GetSkillCDData(int entityID, int skillId, out SkillCDData cdData) { if (m_skillCDCoolDict.TryGetValue(skillId, out cdData)) { return(true); } return(false); }
public void UpdateCD() { Dictionary <int, SkillCDData> .Enumerator iter = m_skillCDCoolDict.GetEnumerator(); while (iter.MoveNext()) { //int skillId = iter.Current.Key; SkillCDData cdData = iter.Current.Value; float fDurTime = Time.time - cdData.fBeginTime; if (fDurTime * 1000 > (cdData.iCDCoolTime + 1000f)) { cdData.bCDEnable = false; cdData.bInCDCoolState = false; } } UpdateShareCDOverTime(); }
//是否CD时间中 public bool IsInCoolDownTime(int skillID) { if (!m_skillCDCoolDict.ContainsKey(skillID)) { return(false); } SkillCDData cdData = m_skillCDCoolDict[skillID]; float lastTime = cdData.fBeginTime; float curTime = Time.time; if ((curTime - lastTime) * 1000 <= cdData.iCDCoolTime) { return(true); } return(false); }
//当前距CD时间结束还有多久 public float QuerySkillCDOverTime(int skillID) { if (!m_skillCDCoolDict.ContainsKey(skillID)) { return(0f); } SkillCDData cdData = m_skillCDCoolDict[skillID]; float curTime = Time.time; float lastTime = cdData.fBeginTime; float remainTime = cdData.iCDCoolTime - (curTime - lastTime) * 1000; if (remainTime < 0) { remainTime = 0f; } return(remainTime); }
public void UpdateSkillCD() { m_playerObj = CoreEntry.gActorMgr.MainPlayer; if (m_playerObj == null) { return; } int nPlayerID = m_playerObj.EntityID; Dictionary <int, SkillCDData> .Enumerator iter = m_skillCDCoolDict.GetEnumerator(); while (iter.MoveNext()) { int skillId = iter.Current.Key; SkillCDData cdData = iter.Current.Value; if (cdData.bInCDCoolState == true) { EventParameter param = EventParameter.Get(); param.intParameter1 = skillId; param.intParameter2 = nPlayerID; //m_playerObj.SetShareCoolDownTime(skillId); CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_EU_ONSKILLCOOLDOWN, param); } } }