Exemplo n.º 1
0
    public void Update()
    {
        if (this.pairs.Count > 0)
        {
            for (int i = 0; i < this.pairs.Count; i++)
            {
                if (this.pairs[i].elapsedTime < 1f)
                {
                    MoveTo(i);
                    Scale(i, 0f, 1f);
                    MergeUpdate(i);
                }
                else
                {
                    MergePair pair = this.pairs[i];
                    if (pair.second != null)
                    {
                        Network.Destroy(pair.second);
                    }
                    if (pair.first != null)
                    {
                        Selectable select = pair.first.GetComponent <Selectable>();
                        if (select)
                        {
                            select.EnableSelection();
                            select.Deselect();
                        }
                        Divisible div = pair.first.GetComponent <Divisible>();
                        if (div != null)
                        {
                            div.SetDivisible(false);
                        }
                    }

                    if (pair.first == null || pair.second == null || pair.confirmedDestroyed)
                    {
                        this.pendingToRemove.Add(pair);
                        break;
                    }
                }
            }
        }
        if (this.pendingToRemove.Count > 0)
        {
            foreach (MergePair pair in this.pendingToRemove)
            {
                if (this.pairs.Contains(pair))
                {
                    Selectable select = pair.first.GetComponent <Selectable>();
                    if (select != null)
                    {
                        select.EnableSelection();
                        select.Deselect();
                    }
                    this.pairs.Remove(pair);
                }
            }
            this.pendingToRemove.Clear();
        }
    }
Exemplo n.º 2
0
    private void Cooldown(int index)
    {
        SpawnGroup group     = this.spawnGroups[index];
        Renderer   rendererA = group.owner.GetComponentInChildren <Renderer>();
        Renderer   rendererB = group.spawnedUnit.GetComponentInChildren <Renderer>();

        if (group.elapsedTime < 1f)
        {
            bool halfTime = group.elapsedTime < 0.5f;
            if (halfTime)
            {
                rendererA.material.color = Color.Lerp(Color.white, Color.cyan, group.elapsedTime);
                rendererB.material.color = Color.Lerp(Color.white, Color.cyan, group.elapsedTime);
            }
            else
            {
                rendererB.material.color = Color.Lerp(Color.cyan, Color.white, group.elapsedTime);
                rendererA.material.color = Color.Lerp(Color.cyan, Color.white, group.elapsedTime);
            }
        }
        else if (group.elapsedTime >= 1f)
        {
            Selectable selectable = group.owner.GetComponent <Selectable>();
            if (selectable != null && !selectable.IsSelectionEnabled())
            {
                selectable.EnableSelection();
            }
            selectable = group.spawnedUnit.GetComponent <Selectable>();
            if (selectable != null && !selectable.IsSelectionEnabled())
            {
                selectable.EnableSelection();
            }
            rendererA.material.color = Color.white;
            rendererB.material.color = Color.white;
        }
    }