コード例 #1
0
        public virtual void Spawn(string id, int count, Sprite sprite)
        {
            // float spawnPosX = transform.position.x + (50f * count);
            // Vector3 spawnPos = new Vector3(spawnPosX, transform.position.y, transform.position.z);
            // Icons are 75 units square
            float           spawnPosX = (iconOffset * count);
            Vector3         spawnPos  = new Vector3(spawnPosX, 0, 0);
            EffectIconImage instance  = null;

            if (fxIconStack.Count == 0)
            {
                // instance = Instantiate(fxIcon, spawnPos, Quaternion.identity, transform);
                instance = Instantiate(fxIcon, transform);
                instance.SetPosition(spawnPos);
            }
            else
            {
                instance = fxIconStack.Pop();
                instance.SetPosition(spawnPos);
                instance.gameObject.SetActive(true);
                instance.transform.SetAsLastSibling();
            }
            instance.SetIcon(sprite);
            iconInstances[id] = instance;
        }
コード例 #2
0
        public override void Spawn(string id, int count, Sprite sprite)
        {
            float           spawnPosX = (50f * count);
            Vector3         spawnPos  = new Vector3(spawnPosX, 0, 0);
            EffectIconImage instance  = null;

            if (fxIconStack.Count == 0)
            {
                instance = Instantiate(fxIcon, transform);
                instance.SetPosition(spawnPos);
            }
            else
            {
                instance = fxIconStack.Pop();
                instance.SetPosition(spawnPos);
                instance.gameObject.SetActive(true);
                instance.transform.SetAsLastSibling();
            }
            instance.SetIcon(sprite);
            iconInstances[id] = instance;

            // Set tooltip info
            fxDisplay = instance.GetComponent <EffectDisplay>();
            fxDisplay.SetEffectName(id);
        }
コード例 #3
0
 public void UpdateStacks(string id, float stacks)
 {
     if (iconInstances.ContainsKey(id))
     {
         EffectIconImage instance = iconInstances[id];
         instance.UpdateStacks(stacks.ToString());
     }
 }
コード例 #4
0
 public void UpdateIconFill(string id, float fillPercent, float timeRemaining)
 {
     if (iconInstances.ContainsKey(id))
     {
         EffectIconImage instance = iconInstances[id];
         instance.UpdateIconFill(fillPercent, timeRemaining);
     }
 }
コード例 #5
0
 public override void DeactivateIcon(string id)
 {
     if (iconInstances.ContainsKey(id))
     {
         EffectIconImage instance = iconInstances[id];
         instance.gameObject.SetActive(false);
         instance.transform.SetAsFirstSibling();
         fxIconStack.Push(instance);
     }
 }
コード例 #6
0
        private void ReturnIconToPool(string id)
        {
            EffectIconImage instance   = iconInstances[id];
            int             childCount = transform.childCount;

            if (childCount > 1)
            {
                int fxIndex = instance.transform.GetSiblingIndex();
                for (int i = fxIndex + 1; i < childCount; i++)
                {
                    GameObject fxInstance = transform.GetChild(i).gameObject;
                    if (fxInstance.activeSelf)
                    {
                        EffectIconImage icon = fxInstance.GetComponent <EffectIconImage>();
                        icon.StartCoroutine(icon.MoveHorizontal(iconOffset));
                    }
                }
            }
            instance.gameObject.SetActive(false);
            instance.transform.SetAsFirstSibling();
            fxIconStack.Push(instance);
        }