Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (transform.parent == null && GlobalLogic.Overlaps(gameObject, "Water"))
     {
         Destroy(gameObject);
         Instantiate(potteryInWater, transform.position, Quaternion.identity);
     }
 }
Exemplo n.º 2
0
 void Update()
 {
     if (transform.parent == null && GlobalLogic.Overlaps(gameObject, "Water"))
     {
         GetComponent <SpriteRenderer>().sprite = droppedSprite;
     }
     else
     {
         GetComponent <SpriteRenderer>().sprite = filledSprite;
     }
 }
Exemplo n.º 3
0
    public void Jump()
    {
        if (GlobalLogic.Overlaps(gameObject, "Hero"))
        {
            Vector2 rockTarget = Random.insideUnitCircle * 4;

            while (Vector2.Distance(rockTarget, transform.position) < 2f)
            {
                rockTarget = Random.insideUnitCircle * 4;
            }

            GameObject rockInstance = Instantiate(rock, rockTarget + new Vector2(0, 15f), Quaternion.identity);
            rockInstance.GetComponent <DraggableItem>().Drop(rockTarget, true);
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (transform.parent != null)
        {
            return;
        }

        if (growth >= 1f && !GameObject.Find("Global").GetComponent <GlobalLogic>().IsRaining())
        {
            Instantiate(flower, transform.position, Quaternion.identity);
            Destroy(gameObject);
            return;
        }

        transform.localScale = Vector2.one * Mathf.Lerp(0f, 0.15f, growth);

        if (!GlobalLogic.Overlaps(gameObject, "Ground"))
        {
            growth -= Time.deltaTime * GROWTH_SPEED;

            if (growth <= 0)
            {
                Destroy(gameObject);
            }
            return;
        }

        growth += Time.deltaTime * GROWTH_SPEED;

        if (GameObject.Find("Global").GetComponent <GlobalLogic>().IsRaining())
        {
            growth += Time.deltaTime * GROWTH_SPEED;
        }

        growth = Mathf.Clamp(growth, -0.1f, 1f);
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        if (transform.parent != null)
        {
            return;
        }

        transform.localScale = Vector2.one * Mathf.Lerp(0f, 0.15f, growth);

        if (GameObject.Find("Global").GetComponent <GlobalLogic>().IsRaining())
        {
            generation = 0;
            growCount  = GROW_COUNT;
        }

        if (!GlobalLogic.Overlaps(gameObject, "Ground"))
        {
            growth -= Time.deltaTime * GROWTH_SPEED;

            if (growth <= 0)
            {
                Destroy(gameObject);
            }
            return;
        }

        growth += Time.deltaTime * GROWTH_SPEED;

        if (GameObject.Find("Global").GetComponent <GlobalLogic>().IsRaining())
        {
            growth += Time.deltaTime * GROWTH_SPEED;
        }

        growth = Mathf.Clamp(growth, -0.1f, 1f);


        if (growCount == 0 || generation >= MAX_GENERATION || growth < 1f)
        {
            return;
        }

        cooldown -= Time.deltaTime;

        if (cooldown < 0 && GlobalLogic.grassCount < 80f)
        {
            Vector2 pos = transform.position + (Vector3)(Random.insideUnitCircle * GROW_RANGE);

            GameObject prefab = Random.Range(0f, 100f) > 85f ? bud : grass;

            GameObject child = Instantiate(prefab, pos, Quaternion.identity);
            GlobalLogic.grassCount++;

            if (prefab == grass)
            {
                child.GetComponent <Grass>().generation = generation + 1;
            }

            cooldown = GROWING_TIME;
            growCount--;
        }
    }