예제 #1
0
        public void CreateEffectIcon(MiniMapEffectType type, long id, Vector2 pos)
        {
            if (this.gameObject.activeInHierarchy)
            {
                MiniMapEffect effect = TakeEffectItemFromPool(type, id);
                if (effect != null)
                {
                    SetElementIconPosition(effect.transform, pos);

                    if (type == MiniMapEffectType.Warning)
                    {
                        MiniMapEffect_Warning warning = ( MiniMapEffect_Warning )effect;
                        warning.EffectStart();
                    }
                    //TODO:If have more minimapEffectType add here.
                    //else if( type == MiniMapEffectType.None )
                    //{

                    //}
                }
                else
                {
                    DebugUtils.Log(DebugUtils.Type.MiniMap, "CreateEffectIcon is null");
                }
            }
        }
예제 #2
0
        private MiniMapEffect TakeEffectItemFromPool(MiniMapEffectType type, long id)
        {
            DebugUtils.Log(DebugUtils.Type.MiniMap, string.Format("TakeEffect, Type is {0} ", type));

            if (effectElementDic == null)
            {
                effectElementDic = new Dictionary <long, MiniMapEffect>();
            }

            MiniMapEffect temp = null;

            //Not need too more warning in one place.
            if (type == MiniMapEffectType.Warning)
            {
                effectElementDic.TryGetValue(id, out temp);

                if (temp != null)
                {
                    DebugUtils.Log(DebugUtils.Type.MiniMap, string.Format("This waring effect is playing. EffectID is {0} effect HolderID is {1}", temp.GetEffectID(), temp.GetHolderID()));
                    return(null);
                }
            }

            while (temp == null)
            {
                for (int i = 0; i < effectItemPool.Count; i++)
                {
                    if (effectItemPool[i].GetEffectType() == type && effectItemPool[i].GetEffctItemStatus())
                    {
                        DebugUtils.Log(DebugUtils.Type.MiniMap, string.Format("Find can use effect, Type is {0} .", type));
                        effectItemPool[i].SetHolderID(id);
                        effectElementDic.Add(id, effectItemPool[i]);
                        temp = effectItemPool[i];
                        return(temp);
                    }
                }

                FillEffectItemPool(5);
            }

            return(null);
        }