Пример #1
0
    void Update()
    {
        if (timer <= 0.75f)
        {
            timer += Time.deltaTime;
        }
        else if (timer < 1.5f)
        {
            timer = 1.5f;
            if (CubeMove.countAudio < generalCount)
            {
                musicSource.Play();
            }
        }
        else if ((timer < 3.5f) && (endWave == false))
        {
            timer += Time.deltaTime;
        }
        else
        {
            timer = 0;
        }



        if ((countToDestroy == CubeMove.destroyedCubes) && (endWave == false))
        {
            endWave = true;
        }
        else if (generalCount == CubeMove.destroyedCubes + CubeMove.destroyedMistake)
        {
            timer = -8f;

            if (endWave == true)
            {
                level++;
                if (CubeMove.blackFallen == CubeMove.destroyedMistake)
                {
                    PlatformLength platform = this.GetComponent <PlatformLength> ();
                    StartCoroutine(platform.Enlargement());
                }
            }
            else
            {
                PlatformLength platform = this.GetComponent <PlatformLength> ();
                platform.Decrease();
            }
            endWave = false;
            CubeMove.destroyedCubes   = 0;
            CubeMove.destroyedMistake = 0;
            CubeMove.blackFallen      = 0;
            CubeMove.countAudio       = 0;
            Debug.Log(level);
            StartCoroutine(Create());
        }
    }
Пример #2
0
    private IEnumerator ReactSphere(GameObject bomb)
    {
        yield return(new WaitUntil(() => CreatingLevel.timer > 1.5f));

        musicSource.clip = sphereClip;
        musicSource.Play();
        RaycastHit[] hits = Physics.SphereCastAll(bomb.transform.position, 1.1f, new Vector3(0, -1f, 0), 10f);
        foreach (RaycastHit q in hits)
        {
            GameObject hitObject = q.transform.gameObject;
            CubeMove   target    = hitObject.GetComponent <CubeMove> ();
            if (target != null)
            {
                if ((int)target.kind == 2)
                {
                    spheres.Add(Instantiate(sphere, new Vector3(Mathf.Round(target.transform.position.x), target.transform.position.y + 1f, Mathf.Round(target.transform.position.z)), Quaternion.identity));
                    target.ReactToHit(true);
                }
                else if ((int)target.kind == 3)
                {
                    Ray        ray = new Ray(new Vector3(target.transform.position.x, 0.99f, target.transform.position.z), new Vector3(0, -1f, 0));
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        hitObject = hit.transform.gameObject;
                        PlatformLength platform = hitObject.GetComponent <PlatformLength> ();
                        if (platform != null)
                        {
                            platform.Decrease();
                        }
                    }
                    target.ReactToHit(false);
                }
                else
                {
                    target.ReactToHit(true);
                }
            }
        }
        spheres.RemoveAt(0);
        Destroy(bomb);
    }
Пример #3
0
    private IEnumerator ReactPlane(GameObject plane)
    {
        yield return(new WaitUntil(() => CreatingLevel.timer > 1.5f));

        musicSource.clip = planeCrashClip;
        musicSource.Play();
        Ray        ray = new Ray(plane.transform.position, new Vector3(0, 1f, 0));
        RaycastHit hit;

        Destroy(plane);
        if (Physics.Raycast(ray, out hit))
        {
            GameObject hitObject = hit.transform.gameObject;
            CubeMove   target    = hitObject.GetComponent <CubeMove> ();
            if (target != null)
            {
                if ((int)target.kind == 2)                      //for green blocks
                {
                    spheres.Add(Instantiate(sphere, new Vector3(Mathf.Round(target.transform.position.x), target.transform.position.y + 1f, Mathf.Round(target.transform.position.z)), Quaternion.identity));
                    target.ReactToHit(true);
                }
                else if ((int)target.kind == 3)                      // for black blocks
                {
                    ray = new Ray(new Vector3(target.transform.position.x, 0.99f, target.transform.position.z), new Vector3(0, -1f, 0));
                    if (Physics.Raycast(ray, out hit))
                    {
                        hitObject = hit.transform.gameObject;
                        PlatformLength platform = hitObject.GetComponent <PlatformLength> ();
                        if (platform != null)
                        {
                            platform.Decrease();
                        }
                    }
                    target.ReactToHit(false);
                }
                else
                {
                    target.ReactToHit(true);
                }
            }
        }
    }