예제 #1
0
        public void CreateElementIcon(long id, MiniMapElementType type, ForceMark mark, Vector2 pos)
        {
            if (this.gameObject.activeInHierarchy)
            {
                Image icon = TakeElementFromPool(type);

                SetIconColor(icon, mark);
                SetElementIconPosition(icon.transform, pos);
                icon.gameObject.SetActive(true);

                if (id != -1)
                {
                    elementIconDic.Add(id, icon.transform);
                }
            }
        }
예제 #2
0
        private Image TakeElementFromPool(MiniMapElementType type)
        {
            Image temp = null;

            if (type == MiniMapElementType.Soldier)
            {
                while (temp == null)
                {
                    for (int i = 0; i < soldierIconPool.Count; i++)
                    {
                        if (!soldierIconPool[i].gameObject.activeInHierarchy)
                        {
                            temp = soldierIconPool[i];
                            return(temp);
                        }
                    }

                    FillSoldierElementIconPool(6);
                }
            }
            else if (type == MiniMapElementType.Tower)
            {
                while (temp == null)
                {
                    for (int i = 0; i < towerIconPool.Count; i++)
                    {
                        if (!towerIconPool[i].gameObject.activeInHierarchy)
                        {
                            temp = towerIconPool[i];
                            return(temp);
                        }
                    }

                    FillTowerElementIconPool(4);
                }
            }
            else if (type == MiniMapElementType.Institute)
            {
                while (temp == null)
                {
                    for (int i = 0; i < instituteIconPool.Count; i++)
                    {
                        if (!instituteIconPool[i].gameObject.activeInHierarchy)
                        {
                            temp = instituteIconPool[i];
                            return(temp);
                        }
                    }

                    //I do't think this situation can happen
                    FillInstituteElementIconPool(2);
                }
            }
            else if (type == MiniMapElementType.Rune)
            {
                while (temp == null)
                {
                    for (int i = 0; i < runeIconPool.Count; i++)
                    {
                        if (!runeIconPool[i].gameObject.activeInHierarchy)
                        {
                            temp = runeIconPool[i];
                            return(temp);
                        }
                    }

                    FillRuneElementIconPool(2);
                }
            }
            else if (type == MiniMapElementType.Town)
            {
                //When town destroy will lose the play, not need cache more number.
                GameObject obj = GameObject.Instantiate(resourceLoad.LoadAsset <GameObject>("Town"));
                obj.transform.SetParent(elementIconParent, false);
                obj.transform.SetAsFirstSibling();
                obj.gameObject.SetActive(true);
                temp = obj.GetComponent <Image>();
                return(temp);
            }
            else
            {
                DebugUtils.LogError(DebugUtils.Type.MiniMap, string.Format("Can't find this type element{0}", type));
                return(null);
            }

            return(null);
        }