Example #1
0
    private IEnumerator PlayCoroutine(Vector3 hitPoint, BoxScript box)
    {
        GameObject        ob        = BoxManagerScript.instance.PlaceBox(hitPoint, box, color, colors[color]);
        BoxScript         box1      = ob.GetComponent <BoxScript>();
        List <GameObject> toDestroy = new List <GameObject>();

        toDestroy.Add(ob);
        box1.Check(color, toDestroy);
        yield return(new WaitForSeconds(0.1f));

        if (toDestroy.Count > 1)
        {
            score += ScoreScript.instance.CountScore(toDestroy.Count);
            foreach (GameObject gO in toDestroy)
            {
                Vector3 pos = gO.transform.position;
                Color32 col = colors[gO.GetComponent <BoxScript>().Color];
                BoxManagerScript.instance.BoxInGame.Remove(gO);
                Destroy(gO);
                GameObject g = Instantiate(destroyPrefab);
                g.transform.position = pos;

                /*
                 * var mainMod = g.GetComponent<ParticleSystem>().main;
                 * mainMod.startColor = new ParticleSystem.MinMaxGradient(col);
                 */
                g.GetComponent <Renderer>().material.color = col;
                g.GetComponent <ParticleSystem>().Play();
                Destroy(g, 3);
            }
            GuiScript.instance.SetScore(score);
        }
        if (SetNewColor())
        {
            End();
        }
        else
        {
            yield return(new WaitForSeconds(0.4f));

            isEnabled = true;
        }
    }