Beispiel #1
0
    void ParsePattern()
    {
        Queue <char> patternQueue  = new Queue <char>(pattern.ToCharArray());
        int          count         = patternQueue.Count;
        int          sphereCounter = 0;
        int          counter       = 0;
        bool         doubleCount   = false;

        while (patternQueue.Count > 0)
        {
            char c = patternQueue.Dequeue();
            if (c.Equals('S'))
            {
                SphereGroup sGroup = Instantiate(sphereGroup, new Vector3(0, 0, boxCollider.bounds.min.z + (boxCollider.size.z / count) * counter), Quaternion.identity).GetComponent <SphereGroup>();
                sGroup.RandomColor();
                sphereCounter++;
                counter++;
            }
            else if (c.Equals('r') || c.Equals('g') || c.Equals('y'))
            {
                if (!doubleCount)
                {
                    count      *= 2;
                    doubleCount = true;
                }

                InGameColor color   = InGameColor.Yellow;
                Gate        newGate = Instantiate(gate, new Vector3(0, 0, boxCollider.bounds.min.z + (boxCollider.size.z / count) * counter), Quaternion.identity).GetComponent <Gate>();
                counter++;
                SphereGroup sGroup = Instantiate(sphereGroup, new Vector3(0, 0, boxCollider.bounds.min.z + (boxCollider.size.z / count) * counter), Quaternion.identity).GetComponent <SphereGroup>();


                if (c.Equals('r'))
                {
                    color = InGameColor.Red;
                }
                else if (c.Equals('g'))
                {
                    color = InGameColor.Green;
                }
                else if (c.Equals('y'))
                {
                    color = InGameColor.Yellow;
                }

                sGroup.OneColor(color);
                newGate.SetColor(color);
                sphereCounter++;
                counter++;
                continue;
            }
            else if (c.Equals('G'))
            {
                Instantiate(gate, new Vector3(0, 0, boxCollider.bounds.min.z + (boxCollider.size.z / count) * counter), Quaternion.identity);
                counter++;
            }
        }

        gauge.SetSphereCounter(sphereCounter);
    }
Beispiel #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag.Equals("GoalLine"))
        {
            // Debug.Log("[Boy.cs] - Passed goal line");
            movementDisabled = true;
            isStopping       = true;
            animator.Play("kick_ani");
            gauge.StartHit();
            StartCoroutine(KickBall());
        }
        else if (other.gameObject.tag.Equals("Gate"))
        {
            Gate gate = other.gameObject.GetComponent <Gate>();
            SetColor(gate.GetColor());
            Destroy(other.gameObject);
        }
        else if (other.gameObject.tag.Equals("Sphere"))
        {
            SpherePickup sphere      = other.gameObject.GetComponent <SpherePickup>();
            InGameColor  sphereColor = sphere.GetColor();

            if (color == sphereColor)
            {
                SpherePickedup(true);
            }
            else
            {
                SpherePickedup(false);
            }

            Destroy(other.transform.parent.gameObject);
        }
    }
Beispiel #3
0
    void SetColor(InGameColor color)
    {
        this.color = color;

        ballRenderer.material = MaterialCatalog.instance.GetColor(color.ToString());
        foreach (SkinnedMeshRenderer renderer in body)
        {
            renderer.material = MaterialCatalog.instance.GetColor(color.ToString());
        }
    }
Beispiel #4
0
 void Shuffle(InGameColor[] colors)
 {
     // Knuth shuffle algorithm :: courtesy of Wikipedia :)
     for (int t = 0; t < colors.Length; t++)
     {
         InGameColor tmp = colors[t];
         int         r   = Random.Range(t, colors.Length);
         colors[t] = colors[r];
         colors[r] = tmp;
     }
 }
Beispiel #5
0
    public void OneColor(InGameColor color)
    {
        for (int i = 0; i < 3; i++)
        {
            SpherePickup sPickup = ballsRenderer[i].GetComponent <SpherePickup>();
            sPickup.color = color;

            Material material = MaterialCatalog.instance.GetColor(sPickup.color.ToString());
            ballsRenderer[i].material = material;
        }
    }
Beispiel #6
0
    public void SetColor(InGameColor color)
    {
        this.color = color;
        ParticleSystem.MainModule main = pSystem.main;

        if (color == InGameColor.Green)
        {
            main.startColor = new Color(0.0901f, 1, 0.0274f, .25f);
        }
        else if (color == InGameColor.Red)
        {
            main.startColor = new Color(0.7372f, 0, 0.0941f, .25f);
        }
        else
        {
            main.startColor = new Color(0.8705f, 0.9450f, 0.2862f, .25f);
        }
    }
Beispiel #7
0
    void Awake()
    {
        pSystem = GetComponent <ParticleSystem>();

        int randomColor = Random.Range(0, 3);

        if (randomColor == 1)
        {
            color = InGameColor.Green;
            ParticleSystem.MainModule main = pSystem.main;
            main.startColor = new Color(0.0901f, 1, 0.0274f, .25f);
        }
        else if (randomColor == 2)
        {
            color = InGameColor.Red;
            ParticleSystem.MainModule main = pSystem.main;
            main.startColor = new Color(0.7372f, 0, 0.0941f, .25f);
        }
        else
        {
            color = InGameColor.Yellow;
        }
    }