Пример #1
0
    // Update is called once per frame
    void Update()
    {
        transform.LookAt(planet);



        if (waveStart)
        {
            if (elapsedTime < waitTime)
            {
                //Indicator.enabled = true;

                if (!blink)
                {
                    StartCoroutine(DangerAnimationTimed());
                }

                elapsedTime += Time.deltaTime;


                //Vector2 npos = Camera.main.WorldToScreenPoint(transform.position);

                //Vector2 sc = new Vector2(Screen.width / 2, Screen.width / 2);

                //Vector2 fpos = npos;

                //fpos.x = Mathf.Clamp(fpos.x, 100, Screen.width - 100);
                //fpos.y = Mathf.Clamp(fpos.y, 100, Screen.height - 100);


                //Indicator.rectTransform.position = fpos;
            }
            else
            {
                //Indicator.enabled = false;
                if (currentSpawn < spawn)
                {
                    if (!fire)
                    {
                        float yoffset = Random.Range(-yOffset, yOffset);

                        ////GameObject g = Instantiate(hazzard, transform.position + transform.up * yoffset, Quaternion.identity);
                        //float size=Random.Range(1.51915f, 4f);
                        float size = Random.Range(sizeVariance.x, sizeVariance.y);

                        //g.transform.localScale = new Vector3(size, size, size);
                        //g.GetComponent<Rigidbody2D>().AddForce(transform.forward * Random.Range(speedVariance.x, speedVariance.y), ForceMode2D.Impulse);


                        Hazzard h = HazzardPool.GetPooledObject();

                        h.Begin(transform.position + transform.up * yoffset);
                        h.SetSize(new Vector3(size, size, size));
                        h.Fire(transform.forward * Random.Range(speedVariance.x, speedVariance.y));

                        fire = true;


                        if (currentSpawn == ufoSpawn && SpawnUFO)
                        {
                            //Spawn uFO
                            //Debug.Log("SPAWN UFO");
                            //GameObject u = Instantiate(ufo, new Vector2(-27, 17), Quaternion.identity);

                            //u.GetComponent<Ufo>().SetRandomStartPoint();

                            UFO_script.Revitalize();
                            UFO_script.SetRandomStartPoint();
                        }

                        currentSpawn++;
                    }
                    else
                    {
                        elapsed += Time.deltaTime;

                        if (elapsed >= spawnTimeDelay)
                        {
                            elapsed = 0;
                            fire    = false;
                        }
                    }
                }
                else
                {
                    if (!handle)
                    {
                        StartCoroutine(DelayEnd());
                    }
                    //END OF WAVE
                    //waveEnd = true;
                }
            }
        }



        //Indicator



        //Vector2 d = transform.position - planet.position;
        //Indicator.rectTransform.localPosition = Vector2.zero;
        //Indicator.rectTransform.localPosition = (Vector2)Indicator.rectTransform.localPosition + d.normalized * 300;

        ////Debug.Log(Indicator.transform.position);

        //Debug.Log(Camera.main.WorldToScreenPoint(transform.position));
    }