private void FillPos(AbilityBase ab, Transform parent) { if (parent.childCount == 0) { GameObject go = (GameObject)GameObject.Instantiate(ResMgr.Instance.LoadAssetFromResource("Prefabs/UI/HeroAbility/abilityIcon")); go.GetComponent <UISprite>().spriteName = string.Format(CommonDefine.RoleAbilityDic[RoleManager.Instance.SelectedHero.m_roleInfo.type], ab.Index); go.transform.parent = parent; go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; } else { parent.GetChild(0).GetComponent <UISprite>().spriteName = string.Format(CommonDefine.RoleAbilityDic[RoleManager.Instance.SelectedHero.m_roleInfo.type], ab.Index); } //判断这个技能是否可用,如果不可用就灰态 if (ab.IsValid()) { parent.GetChild(0).GetComponent <UISprite>().color = Color.white; parent.GetChild(0).GetComponent <BoxCollider>().enabled = true; } else { parent.GetChild(0).GetComponent <UISprite>().color = Color.black; parent.GetChild(0).GetComponent <BoxCollider>().enabled = false; } UIEventListener.Get(parent.GetChild(0).gameObject).onClick = (go) => { m_logic.onSelectAbility(ab); }; }
public void onSelectAbility(AbilityBase ability) { if (ability != null && ability.IsValid() && GameData.Instance.BattleSceneActionFlag.HasFlag((long)StateDef.BattleActionFlag.OnChoosingSkill)) { ability.onSelect(); } }