void FixedUpdate()
    {
        _timer += Time.deltaTime;
        if (_timer > speedSpawn)
        {
            int x = Random.Range(-23, 11);
            spawner.position = new Vector3(x, spawner.position.y, spawner.position.z);
            int speed = Random.Range(5, maxAsteroidSpeed);
            poolAsteroids.barell = spawner;
            poolAsteroids.Shoot();
            _timer = 0;
        }

        if (playerStats.live <= 0)
        {
            losingPanel.SetActive(true);
            Time.timeScale = 0f;
        }

        if (playerStats.GetDogeCount() >= doge_count_to_win)
        {
            winPanel.SetActive(true);
            Time.timeScale = 0f;
            Save();
        }

        if (doge_count_lost_to_losing != -1 && doge_count_lost_to_losing < lostDoge)
        {
            losingPanel.SetActive(true);
            Time.timeScale = 0f;
        }

        doge_count_text.text = "Dog count \n" + playerStats.GetDogeCount();
        Live_count_text.text = "Live count \n" + playerStats.live;
    }
Esempio n. 2
0
    private void FixedUpdate()
    {
        if (_timer < 2)
        {
            _timer += Time.deltaTime;
        }
        int nowHp;
        int nowDCount;

        nowHp     = stats.live;
        nowDCount = stats.GetDogeCount();

        if (hp != nowHp)
        {
            changeimage(1);
            hp = nowHp;
        }
        if (dCount != nowDCount)
        {
            changeimage(2);
            dCount = nowDCount;
        }

        if (_timer > 0.5f)
        {
            gameObject.GetComponent <Image>().sprite = image[0];
        }
    }
Esempio n. 3
0
 // Start is called before the first frame update
 void Start()
 {
     stats  = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_stats>();
     hp     = stats.live;
     dCount = stats.GetDogeCount();
 }