/// <summary> /// 更新时检测技能的cd /// </summary> void Update() { if (NetReconnect.Instance.IsReconnect) { return; } // 普通攻击按键,定时自动触发点击消息 if (mIsPressed) { if (GameInput.Instance.GetEnableInput() == false || mHoleOpen == false) { mIsPressed = false; return; } if (UIInputEvent.TouchedUI() == false)// 应用被切出,失去焦点 { mIsPressed = false; StopPressWait(); return; } float t = Time.time; if (t > mNextTime) { OnClick(null); mNextTime = t + DetalTime; } } var localPlayer = Game.Instance.GetLocalPlayer(); if (localPlayer == null)// 角色为空 { return; } // 技能槽未开启 if (SkillHoleManager.Instance.IsHoleOpen(mFitPos) == false || SkillHoleManager.Instance.IsHoleWillOpen(mFitPos)) { OnHoldHide(); return; } // 技能未装配 if (mSkillIdx == 0) { OnSkillNotFit(); return; } // 技能为空 Skill skill = localPlayer.GetSelfSkill(mSkillIdx); if (skill == null) { OnHoldClose(); return; } // 技能正常 OnHoldOpen(); // 设置CD相关的显示 if (!skill.IsInCD())// 技能不在cd中 { SetObjectActive(mCDMask, false); if (mInCD)// 显示cd结束时候的特效 { mInCD = false; if (mCDLevel != null) { SetTextContent(mCDLevel, string.Empty); } if (mCDBlink != null) { SetObjectActive(mCDBlink, false); SetObjectActive(mCDBlink, true); if (mCDBlinkDelayer == null) { mCDBlinkDelayer = mCDBlink.AddComponent <DelayEnableComponent>(); } if (mCDBlinkDelayer != null) { mCDBlinkDelayer.DelayTime = 0.5f; mCDBlinkDelayer.SetEnable = false; mCDBlinkDelayer.Start(); } } } } else// 在cd中 { mInCD = true; SetObjectActive(mCDMask, true); if (mCDMaskImage != null) { CooldownCtrl.CDInstance cd_inst = skill.GetCurrentCD(); if (cd_inst != null) { if (mCDLevel != null) { float level_seconds = cd_inst.GetRemainSeconds(); SetTextContent(mCDLevel, string.Format("{0:N1}", level_seconds)); } mCDMaskImage.fillAmount = cd_inst.GetCDPercent(); } } } }
/// <summary> /// 更新时检测技能的cd /// </summary> public void Update() { if (NetReconnect.Instance.IsReconnect) { return; } // 普通攻击按键,定时自动触发点击消息 if (mIsPressed) { if (GameInput.Instance.GetEnableInput() == false || mHoleOpen == false) { mIsPressed = false; return; } if (UIInputEvent.TouchedUI() == false)// 应用被切出,失去焦点 { mIsPressed = false; StopPressWait(); return; } float t = Time.time; if (t > mNextTime) { OnClick(null); mNextTime = t + DetalTime; } } Actor local_player = Game.GetInstance().GetLocalPlayer(); if (local_player == null)// 角色为空 { return; } //DBInstance.InstanceInfo instanceInfo = InstanceManager.Instance.InstanceInfo; //if (instanceInfo != null && instanceInfo.mWarSubType == GameConst.WAR_SUBTYPE_ARENA) //{ // OnHoldHide(); // return; //} if (CanShowMateButton() == false) { OnHoldHide(); return; } if (SkillHoleManager.Instance.IsHoleOpen(m_FitPos) == false || SkillHoleManager.Instance.IsHoleWillOpen(m_FitPos))// 技能槽还没开启 { OnHoldHide(); return; } if (mSkillIdx == 0) { OnSkillNotFit(); return; } Skill skill = local_player.GetSelfSkill(mSkillIdx); if (skill == null)// 技能为空 { OnHoldClose(); return; } OnHoldOpen(); // 设置CD相关的显示 if (!skill.IsInCD())// 技能不在cd中 { if (mCDMask.activeSelf) { mCDMask.SetActive(false); } if (mInCD)// 显示cd结束时候的特效 { mInCD = false; if (mCDLevel != null) { mCDLevel.text = string.Empty; } if (mCDBlink != null) { mCDBlink.SetActive(false); mCDBlink.SetActive(true); if (mCDBlink_DelayEnableComponent == null) { mCDBlink_DelayEnableComponent = mCDBlink.AddComponent <DelayEnableComponent>(); } if (mCDBlink_DelayEnableComponent != null) { mCDBlink_DelayEnableComponent.DelayTime = 0.5f; mCDBlink_DelayEnableComponent.SetEnable = false; mCDBlink_DelayEnableComponent.Start(); } } } } else// 在cd中 { mInCD = true; if (!mCDMask.activeSelf) { mCDMask.SetActive(true); } if (mCDMaskImage != null) { CooldownCtrl.CDInstance cd_inst = skill.GetCurrentCD(); if (cd_inst != null) { if (mCDLevel != null) { float level_seconds = cd_inst.GetRemainSeconds(); mCDLevel.text = string.Format("{0:N1}", level_seconds); } mCDMaskImage.fillAmount = cd_inst.GetCDPercent(); } } } }