Exemplo n.º 1
0
 public void Config(ItemFallFood itemFallFood, float speedFall)
 {
     m_IsFood = true;
     GetComponent<Image>().sprite = itemFallFood.m_Icon;
     m_GoodItem = itemFallFood.m_GoodItem;
     m_Speed = speedFall;
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (m_GameOver)
        {
            return;
        }

        m_Counter          += Time.deltaTime;
        m_CounterDifficult += Time.deltaTime;
        m_FloatPoints      += Time.deltaTime;
        m_Points            = (int)m_FloatPoints;
        m_TextPoints.text   = m_Points.ToString();

        if (m_Counter >= m_TimeToSpawn)
        {
            int indexSpaw;
            do
            {
                indexSpaw = Random.Range(0, m_Spawns.Length);
            } while (m_LastSpawn == indexSpaw);

            m_LastSpawn = indexSpaw;
            Transform tempPos = m_Spawns[indexSpaw];

            int          indexItem = Random.Range(0, m_ItensFallFood.Length);
            ItemFallFood tempItem  = m_ItensFallFood[indexItem];

            float prop   = Random.Range(0, 100);
            bool  isFood = prop <= 85;

            if (isFood)
            {
                PrefabFallFood tempPrefab = null;
                if (CURRENT_POOL < 30)
                {
                    tempPrefab = Instantiate(m_PrefabFallFood, tempPos.position, Quaternion.identity, m_PrefabCanvas);
                    CURRENT_POOL++;
                }
                else if (m_PoolFallFoods.Count > 0)
                {
                    tempPrefab = m_PoolFallFoods[0];
                    RemovePoll(tempPrefab);
                    tempPrefab.transform.position = tempPos.position;
                    tempPrefab.gameObject.SetActive(true);
                }

                if (tempPrefab != null)
                {
                    tempPrefab.Config(tempItem, m_GravityScale);
                }
            }
            else
            {
                PrefabFallFood tempPrefab = null;
                if (CURRENT_POOL < 30)
                {
                    tempPrefab = Instantiate(m_PrefabFallFood, tempPos.position, Quaternion.identity, m_PrefabCanvas);
                    CURRENT_POOL++;
                }
                else if (m_PoolFallFoods.Count > 0)
                {
                    tempPrefab = m_PoolFallFoods[0];
                    RemovePoll(tempPrefab);
                    tempPrefab.transform.position = tempPos.position;
                    tempPrefab.gameObject.SetActive(true);
                }

                if (tempPrefab != null)
                {
                    tempPrefab.Config(m_GravityScale);
                }
            }

            m_Counter = 0;
        }

        if (m_CounterDifficult >= m_TimeMakeDifficult)
        {
            if (m_TimeToSpawn > 0.12f)
            {
                m_TimeToSpawn -= 0.01f;
            }
            if (m_GravityScale < 400)
            {
                m_GravityScale += 5;
            }
            m_CounterDifficult = 0;
        }

        if (SaveGameController.Instance != null)
        {
            float dv = SaveGameController.Instance.dataGame.dataGame.diversao;
            dv += Time.deltaTime / 3;
            dv  = dv > 100 ? 100 : dv;
            SaveGameController.Instance.dataGame.dataGame.diversao = dv;

            float hg = SaveGameController.Instance.dataGame.dataGame.higiene;
            hg -= Time.deltaTime / 10;
            hg  = hg < 0 ? 0 : hg;
            SaveGameController.Instance.dataGame.dataGame.higiene = hg;
        }
    }