public void Init(UIBattleMainData data) { uiData = data; InitSkillBuffEffect(); List <GameObject> tempPool = new List <GameObject>(); for (int i = 0; i < 4; i++) { UIMatchSelfSkillComponent selfSkillComponent = new UIMatchSelfSkillComponent(); GameObject clone = PoolingSystem.Instance.GetOneClone_NotActive(uiData.go_BuffTemplate); tempPool.Add(clone); selfSkillComponent.Init(clone.transform, this, uiData); goInstanceID_to_manageComponent.Add(clone.GetInstanceID(), selfSkillComponent); } foreach (GameObject clone in tempPool) { PoolingSystem.Instance.ReturnClone(clone); } }
public void SetSelfSkill(string skillName, bool isRemove, int skillId, double skillHaveTimed) { float skillHaveTime = (float)skillHaveTimed; if (DicSelfHorseSkill.ContainsKey(skillId)) { if (isRemove) { if (DicSelfHorseSkillComponent.ContainsKey(skillId)) { //DicSelfHorseSkillComponent[skillId].Release(); DicSelfHorseSkillComponent[skillId].DisAble(); } } else {//更新 //SoundTools.PlaySoundEffect(EffectSoundNames.Trigger); if (skillHaveTime == -1) {//永久的,用全长的时间 } if (skillHaveTime > 0) { DicSelfHorseSkill[skillId] += skillHaveTime; } else { DicSelfHorseSkill[skillId] = skillHaveTime; } if (DicSelfHorseSkillComponent.ContainsKey(skillId)) { DicSelfHorseSkillComponent[skillId].RefreshExistTime(skillHaveTime); } } } else { if (!isRemove) { //SoundTools.PlaySoundEffect(EffectSoundNames.Trigger); DicSelfHorseSkill.Add(skillId, skillHaveTime); GameObject goBuffTemplate = PoolingSystem.Instance.GetOneClone_NotActive(uiData.go_BuffTemplate); //var goBuffTemplate = GameObject.Instantiate<GameObject>(uiData.go_BuffTemplate); goBuffTemplate.transform.SetParent(uiData.go_Content.transform, false); goBuffTemplate.transform.localEulerAngles = Vector3.zero; goBuffTemplate.transform.localScale = Vector3.one; goBuffTemplate.transform.localPosition = new Vector3(goBuffTemplate.transform.localPosition.x, goBuffTemplate.transform.localPosition.y, 0); goBuffTemplate.SetActive(true); UIMatchSelfSkillComponent selfSkillComponent = null; int keyID = goBuffTemplate.GetInstanceID(); if (goInstanceID_to_manageComponent.ContainsKey(keyID)) { selfSkillComponent = goInstanceID_to_manageComponent[keyID]; selfSkillComponent.ReInit(); } else { //在比赛整个过程中,每次都要初始化组件的形式也是值得考虑需要优化的地方 selfSkillComponent = new UIMatchSelfSkillComponent(); selfSkillComponent.Init(goBuffTemplate.transform, this, uiData); goInstanceID_to_manageComponent.Add(keyID, selfSkillComponent); } DicSelfHorseSkillComponent.Add(skillId, selfSkillComponent); DicSelfHorseSkillObj.Add(skillId, goBuffTemplate); selfSkillComponent.SetSkillIdAndExistTime(skillId, skillHaveTime, skillName); skillIdList.Add(skillId); if (!isPlayBuffEffect) { isPlayBuffEffect = true; skillIndex = 0; uiData.go_SkillBuffNode.SetActive(true); RunSkillBuffEffect(); } } } }