Ejemplo n.º 1
0
    void Power()
    {
        if (lastDowngrade == -1)
        {
            lastDowngrade = Time.time;
        }

        if (Time.time - lastDowngrade > powerRate)
        {
            currentPower -= powerAmount;
            lastDowngrade = Time.time;
            SavePower();
            if (currentPower <= 0)
            {
                inAnimation = true;
                dying       = true;
                StartCoroutine("WaitAndEnd");
            }
        }

        walkSpeed = currentPower / 100f;

        float amount = Mathf.Lerp(barController.current, 33 - currentPower, Time.deltaTime * 3f);

        barController.SetAmount(amount);
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (check)
        {
            if (Input.GetMouseButtonDown(0) && alive)
            {
                Vector2    point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Collider2D hit   = Physics2D.OverlapPoint(point);

                if (hit != null && hit.gameObject == gameObject)
                {
                    health           -= decrement;
                    jave.source.pitch = 1f;
                    if (health <= 0)
                    {
                        check = false;
                        if (seed != null)
                        {
                            Instantiate(seed, transform.position, Quaternion.identity);
                        }
                        jave.source.PlayOneShot(jave.die);
                        Instantiate(drop, transform.position, Quaternion.identity);
                        GetComponentInChildren <ParticleSystem>().Play();
                        GetComponent <SpriteRenderer>().enabled = false;
                        bar.gameObject.SetActive(false);
                        alive = false;
                        Destroy(gameObject, 2f);
                    }
                    else
                    {
                        jave.source.PlayOneShot(jave.hit);
                    }
                }
            }
        }
        float amount = Mathf.Lerp(bar.current, 33f - health, Time.deltaTime * 3f);

        bar.SetAmount(amount);
    }