コード例 #1
0
        /// <summary>
        /// 获取指定元素名的列表
        /// </summary>
        /// <param name="elementName"></param>
        /// <returns></returns>
        public List <T> GetElements <T>(string elementName) where T : ISupportElement
        {
            var list = elementList.FindAll(x => x.Name == elementName && x is T);

            if (list.Count > 0)
            {
                return(list.ConvertAll <T>(x => (T)x));
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// 获取指定元素名的列表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="elementName"></param>
        /// <param name="priorityList"></param>
        /// <returns></returns>
        public List <T> GetElements <T>(string elementName, bool priorit) where T : ISupportElement
        {
            List <ISupportElement> list = new List <ISupportElement>();

            if (priorit)
            {
                list = priorityList.FindAll(x => x.Name == elementName && x is T);
            }

            var otherList = elementList.FindAll(x => x.Name == elementName && x is T);

            list.AddRange(otherList.Where(x => !list.Contains(x)));

            if (list.Count > 0)
            {
                return(list.ConvertAll <T>(x => (T)x));
            }
            return(null);
        }
コード例 #3
0
        protected void ForEachElement(UnityAction <IActiveAble> onFind)
        {
            var objs = elementPool.FindAll(x => x.Name == elementName);

            Debug.Assert(objs != null, "no element name:" + elementName);
            foreach (var item in objs)
            {
                onFind.Invoke(item);
            }
        }
コード例 #4
0
 protected void ForEachElement(UnityAction <ISupportElement> onFind)
 {
     for (int i = 0; i < itemList.Count; i++)
     {
         var element = itemList[i];
         var objs    = elementPool.FindAll(x => x.Name == element);
         Debug.Assert(objs != null, "no element name:" + element);
         foreach (var item in objs)
         {
             onFind.Invoke(item);
         }
     }
 }
コード例 #5
0
        private void CompleteElements(LinkObj element, bool undo)
        {
            lockQueue.Remove(element);

            foreach (var linkItem in linkItems)
            {
                var active = lockQueue.Find(x => x.linkItems.Contains(linkItem));

                if (active == null)
                {
                    var objs = linkPool.FindAll(x => x.Name == linkItem);
                    if (objs == null)
                    {
                        return;
                    }
                    for (int i = 0; i < objs.Count; i++)
                    {
                        if (log)
                        {
                            Debug.Log("CompleteElements:" + element.Name + objs[i].Active);
                        }

                        if (objs[i].Active)
                        {
                            objs[i].onConnected -= TryComplete;

                            if (undo)
                            {
                                objs[i].StepUnDo();
                            }
                            else
                            {
                                objs[i].StepComplete();
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// 将所能点击的目标设置为激活状态
        /// </summary>
        private void FindOperateAbleItems()
        {
            var elements = elementPool.FindAll(x => x.Name == elementName && x.OperateAble);

            elements.ForEach(element =>
            {
                element.SetActive(target);
                var feature = element.RetriveFeature <CompleteAbleItemFeature>();
                if (feature != null)
                {
                    feature.RegistOnCompleteSafety(target, TryComplete);
                }
            });
        }
コード例 #7
0
        /// <summary>
        /// 选择性结束element
        /// </summary>
        /// <param name="undo"></param>
        protected virtual void CompleteElements()
        {
            foreach (var element in itemList)
            {
                //找到所有被激活的对象
                var active = from item in target.StartedList
                             let f = item.RetriveFeature <CollectNodeFeature>()
                                     where f != null
                                     where f.itemList.Contains(element)
                                     select item;

                if (active == null || active.Count() == 0)
                {
                    var objs = elementPool.FindAll(x => x.Name == element);
                    if (objs == null)
                    {
                        return;
                    }
                    for (int i = 0; i < objs.Count; i++)
                    {
                        var activeAble = objs[i] as IActiveAble;
                        if (activeAble == null)
                        {
                            continue;
                        }
                        if (log)
                        {
                            Debug.Log("CompleteElements:" + element + activeAble.Actived);
                        }

                        if (activeAble.Actived)
                        {
                            activeAble.SetInActive(target);
                        }
                    }
                }
            }
        }