/// <summary> /// 尝试创建一个元素 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="elementName"></param> /// <returns></returns> public T TryCreateElement <T>(string elementName, Transform parent, bool clearAble = true) where T : ISupportElement { T element = default(T); var prefab = runTimeElementPrefabs.Find(x => x.Name == elementName); if (prefab != null) { var e = CreateElement(prefab, parent); //e.Name = prefab.Name; if (e is T) { element = (T)e; element.IsRuntimeCreated = true; if (clearAble) { rutimeCreatedList.ScureAdd(element); } } else { Debug.LogError(e + "is not an " + typeof(T).FullName); } } else { Debug.LogError("prefab not exist:" + elementName); } return(element); }
protected void AutoCompleteItems() { if (target.Statu != ExecuteStatu.Completed) { var key = elementName; var item = elementPool.Find(x => x.Name == key && x.Actived && x.OperateAble && x is ActionItem) as ActionItem; if (item != null) { var completeFeature = item.RetriveFeature <CompleteAbleItemFeature>(); if (completeFeature != null) { completeFeature.RegistOnCompleteSafety(target, OnAutoComplete); completeFeature.AutoExecute(target); } } else { Debug.LogError("have no active useful element Name:" + key); } } }
private LinkItem[] SurchLinkItems() { List <LinkItem> linkItemGroup = new List <LinkItem>(); foreach (var itemName in linkItems) { var item = linkPool.Find(x => x.Name == itemName && !linkItemGroup.Contains(x) && x.CanUse); Debug.Assert(item != null, "缺少:" + itemName); linkItemGroup.Add(item); } return(linkItemGroup.ToArray()); }
/// <summary> /// 是否已经有足够的对象 /// </summary> /// <returns></returns> private bool ExistEnoughObj() { var keys = new List <ISupportElement>(); bool allComplete = true; if (finalGroup == null) { finalGroup = new ISupportElement[hoders.Count]; } else { foreach (var item in finalGroup) { if (item != null) { keys.Add(item); } } } for (int i = 0; i < finalGroup.Length; i++) { if (finalGroup[i] == null) { finalGroup[i] = supportPool.Find(x => x.Name == hoders[i].elementName && !keys.Contains(x) && !elementCtrl.IsLocked(x)); if (finalGroup[i] != null) { keys.Add(finalGroup[i]); } else { allComplete = false; break; } } } return(allComplete); }