/// <summary> /// 玩家角色的攻击动作结束时更新技能的可点击状态 /// </summary> public void UpdateActiveSkillButtonsWhenAttackAnimFinish() { for (int i = 0; i < activeSkillButtonContainer.childCount; i++) { ActiveSkillButton activeSkillButton = activeSkillButtonContainer.GetChild(i).GetComponent <ActiveSkillButton>(); ActiveSkill activeSkill = player.attachedActiveSkills[i]; //float coolenPercentage = activeSkillButton.mask.fillAmount; activeSkillButton.UpdateActiveSkillButton(activeSkill); } }
/// <summary> /// 角色攻击间隔计时器 /// </summary> /// <param name="skill">计时结束后使用的技能</param> protected IEnumerator InvokeAttack(ActiveSkill skill) { float timePassed = 0; while (timePassed < agent.attackInterval) { timePassed += Time.deltaTime; yield return(null); } UseSkill(skill); }
/// <summary> /// 攻击间隔时间后触发指定技能 /// </summary> /// <param name="skill">计时结束后使用的技能</param> protected IEnumerator InvokeAttack(ActiveSkill skill) { float timePassed = 0; float acutalAttackInterval = agent.attackInterval / armatureCom.animation.timeScale; while (timePassed < acutalAttackInterval) { timePassed += Time.deltaTime; yield return(null); } UseSkill(skill); }
public void SetupSkillDetail(Skill skill) { skillIcon.sprite = GameManager.Instance.gameDataCenter.allSkillSprites.Find(delegate(Sprite obj) { return(obj.name == skill.skillIconName); }); skillIcon.enabled = true; skillNameText.text = skill.skillName; if (skillLevelText != null) { skillLevelText.text = string.Format("Lv.{0}", skill.skillLevel); } if (upgradeSkillNumText != null) { upgradeSkillNumText.text = string.Format("升级需要技能点: {0}", skill.upgradeNum); } passiveSkillTint.enabled = skill.skillType != SkillType.Active; skillDescriptionText.text = skill.GetDisplayDescription(); if (skill.skillType == SkillType.Active) { ActiveSkill activeSkill = skill as ActiveSkill; manaConsumeText.text = string.Format("魔法消耗:{0}", activeSkill.manaConsume); coolenTimeText.text = string.Format("冷却时间:{0}", activeSkill.skillCoolenTime); } else { manaConsumeText.text = string.Empty; coolenTimeText.text = string.Empty; } upgradeButton.gameObject.SetActive(true); forgetButton.gameObject.SetActive(true); skillDetailContainer.gameObject.SetActive(true); }
public void SetUpSkillDetailInTrade(Skill skill) { if (skill == null) { ClearSkillDetailInTrade(); return; } skillDetailContainer.gameObject.SetActive(true); skillIcon.sprite = GameManager.Instance.gameDataCenter.allSkillSprites.Find(delegate(Sprite obj) { return(obj.name == skill.skillIconName); }); skillIcon.enabled = true; skillNameText.text = skill.skillName; skillDescriptionText.text = skill.skillDescription; if (skill is ActiveSkill) { ActiveSkill activeSkill = skill as ActiveSkill; manaConsumeText.text = string.Format("魔法消耗: {0}", activeSkill.manaConsume); coolenTimeText.text = string.Format("冷却时间: {0}s", activeSkill.skillCoolenTime); passiveHintText.text = string.Empty; } else { manaConsumeText.text = ""; coolenTimeText.text = ""; passiveHintText.text = "被动技能"; } bool skillHasLearned = Player.mainPlayer.CheckSkillHasLearned(skill.skillId); learnButton.gameObject.SetActive(!skillHasLearned); learnedHint.enabled = skillHasLearned; }
public void SetUpLearnedSkillHUD(Skill skill, CallBack quitCallBack) { GameManager.Instance.soundManager.PlayAudioClip(CommonData.paperAudioName); this.quitCallBack = quitCallBack; skillNameText.text = skill.skillName; skillIcon.sprite = GameManager.Instance.gameDataCenter.allSkillSprites.Find(delegate(Sprite obj) { return(obj.name == skill.skillIconName); }); if (skill is ActiveSkill) { ActiveSkill activeSkill = skill as ActiveSkill; manaConsumeText.text = string.Format("魔法消耗: {0}", activeSkill.manaConsume); coolenTimeText.text = string.Format("冷却时间: {0}s", activeSkill.skillCoolenTime); passiveHintText.text = string.Empty; } else { manaConsumeText.text = ""; coolenTimeText.text = ""; passiveHintText.text = "被动技能"; } skillDescriptionText.text = skill.skillDescription; if (zoomCoroutine != null) { StopCoroutine(zoomCoroutine); } zoomCoroutine = HUDZoomIn(); gameObject.SetActive(true); StartCoroutine(zoomCoroutine); }
public void SetUpActiveSkillButton(ActiveSkill activeSkill, int index, Transform skillButtonContainer) { this.skillButtonContainer = skillButtonContainer; if (maskTweener != null) { maskTweener.Kill(); } Sprite skillSprite = GameManager.Instance.gameDataCenter.allSkillSprites.Find(delegate(Sprite obj) { return(obj.name == activeSkill.skillIconName); }); skillIcon.sprite = skillSprite; skillName.text = activeSkill.skillName; manaConsume.text = activeSkill.manaConsume.ToString(); this.indexInPanel = index; this.skill = activeSkill; bool isManaEnough = Player.mainPlayer.mana >= skill.manaConsume; manaConsume.color = isManaEnough ? Color.white : Color.red; mask.fillAmount = isManaEnough ? 0 : 1; mask.enabled = !isManaEnough; float coolenPercentage = skill.coolenPercentage / 100f; mask.fillAmount = coolenPercentage; mask.enabled = !isManaEnough || skill.coolenPercentage > 0.01f; button.interactable = isManaEnough && skill.coolenPercentage <= 0.01f && !ExploreManager.Instance.battlePlayerCtr.isInEscaping; switch (skill.skillStatus) { case ActiveSkillStatus.None: mask.enabled = false; mask.fillAmount = 0; if (isManaEnough) { if (!validTint.gameObject.activeInHierarchy) { validTint.gameObject.SetActive(true); } if (!validTint.animation.isPlaying) { validTint.animation.Play("default", 0); } } else { validTint.gameObject.SetActive(false); } break; case ActiveSkillStatus.Waiting: mask.enabled = true; mask.fillAmount = 1; validTint.gameObject.SetActive(false); break; case ActiveSkillStatus.Cooling: mask.DOFillAmount(0, skill.skillCoolenTime * coolenPercentage).OnComplete(delegate { isManaEnough = Player.mainPlayer.mana >= skill.manaConsume; if (ExploreManager.Instance.battlePlayerCtr.isInSkillAttackAnimBeforeHit) { mask.enabled = true; mask.fillAmount = 1; skill.coolenPercentage = 0; button.interactable = false; skill.skillStatus = ActiveSkillStatus.Waiting; validTint.gameObject.SetActive(false); } else { mask.enabled = !isManaEnough; mask.fillAmount = 0; skill.coolenPercentage = 0; button.interactable = isManaEnough; skill.skillStatus = ActiveSkillStatus.None; if (isManaEnough) { if (!validTint.gameObject.activeInHierarchy) { validTint.gameObject.SetActive(true); } if (!validTint.animation.isPlaying) { validTint.animation.Play("default", 0); } } else { validTint.gameObject.SetActive(false); } manaConsume.color = isManaEnough ? Color.white : Color.red; } }); break; } }
public void UpdateActiveSkillButton(ActiveSkill activeSkill) { bool isManaEnough = Player.mainPlayer.mana >= activeSkill.manaConsume; manaConsume.color = isManaEnough ? Color.white : Color.red; switch (activeSkill.skillStatus) { case ActiveSkillStatus.None: button.interactable = isManaEnough; mask.enabled = isManaEnough; if (isManaEnough) { mask.fillAmount = 0; if (!validTint.gameObject.activeInHierarchy) { validTint.gameObject.SetActive(true); } if (!validTint.animation.isPlaying) { validTint.animation.Play("default", 0); } } else { validTint.gameObject.SetActive(false); mask.fillAmount = 1f; } break; case ActiveSkillStatus.Waiting: activeSkill.skillStatus = ActiveSkillStatus.None; button.interactable = isManaEnough; mask.enabled = isManaEnough; activeSkill.coolenPercentage = 0; if (isManaEnough) { mask.fillAmount = 0; if (!validTint.gameObject.activeInHierarchy) { validTint.gameObject.SetActive(true); } if (!validTint.animation.isPlaying) { validTint.animation.Play("default", 0); } } else { mask.fillAmount = 1f; validTint.gameObject.SetActive(false); } break; case ActiveSkillStatus.Cooling: button.interactable = false; mask.enabled = true; validTint.gameObject.SetActive(false); break; } }
public void AddListener(SkillButtonClickCallBack cb) { button.onClick.RemoveAllListeners(); button.onClick.AddListener(delegate { mask.fillAmount = 1.0f; mask.enabled = true; button.interactable = false; skill.skillStatus = ActiveSkillStatus.Cooling; cb(indexInPanel); if (maskTweener != null) { maskTweener.Kill(); } validTint.gameObject.SetActive(false); maskTweener = mask.DOFillAmount(0, skill.skillCoolenTime).OnComplete(delegate { bool isManaEnough = Player.mainPlayer.mana >= skill.manaConsume; if (ExploreManager.Instance.battlePlayerCtr.isInSkillAttackAnimBeforeHit) { mask.enabled = true; mask.fillAmount = 1; skill.coolenPercentage = 0; button.interactable = false; skill.skillStatus = ActiveSkillStatus.Waiting; validTint.gameObject.SetActive(false); } else { mask.enabled = !isManaEnough; mask.fillAmount = 0; skill.coolenPercentage = 0; button.interactable = isManaEnough; skill.skillStatus = ActiveSkillStatus.None; if (isManaEnough) { if (!validTint.gameObject.activeInHierarchy) { validTint.gameObject.SetActive(true); } if (!validTint.animation.isPlaying) { validTint.animation.Play("default", 0); } } else { validTint.gameObject.SetActive(false); } } manaConsume.color = isManaEnough ? Color.white : Color.red; }); for (int i = 0; i < skillButtonContainer.childCount; i++) { ActiveSkill activeSkill = Player.mainPlayer.attachedActiveSkills[i]; if (activeSkill.skillId == skill.skillId) { continue; } ActiveSkillButton activeSkillButton = skillButtonContainer.GetChild(i).GetComponent <ActiveSkillButton>(); bool manaEnough = Player.mainPlayer.mana >= activeSkill.manaConsume; activeSkillButton.manaConsume.color = manaEnough ? Color.white : Color.red; if (activeSkill.skillStatus != ActiveSkillStatus.Cooling) { activeSkillButton.mask.enabled = true; activeSkillButton.button.interactable = false; activeSkillButton.mask.fillAmount = 1f; activeSkill.coolenPercentage = 100; activeSkill.skillStatus = ActiveSkillStatus.Waiting; } activeSkillButton.validTint.gameObject.SetActive(false); } }); }
// 使用技能 public abstract void UseSkill(ActiveSkill skill);
/// <summary> /// 使用技能 /// </summary> /// <param name="skill">Skill.</param> protected abstract void UseSkill(ActiveSkill skill);