Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     text.text = hero.killreturn().ToString();
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (aggresive == false && increase <= hero.killreturn())
        {
            aggresive        = true;
            health          *= 2;
            speed           *= (float)1.5;
            increase        *= factor;
            aggresive        = false;
            engaugeDistance *= (float)1.6;
        }
        voldoAnimator.SetBool("isIdle", true);
        voldoAnimator.SetBool("isRunning", false);
        voldoAnimator.SetBool("isAttacking", false);
        if (Vector2.Distance(Target.position, this.transform.position) < engaugeDistance)
        {
            voldoAnimator.SetBool("isIdle", false);
            Vector2 Direction = Target.position - this.transform.position;
            if (Mathf.Sign(Direction.x) == 1 && facingLeft)
            {
                Flip();
            }
            else if (Mathf.Sign(Direction.x) == -1 && !facingLeft)
            {
                Flip();
            }
            if (Direction.magnitude >= attackDistance)
            {
                voldoAnimator.SetBool("isRunning", true);
                Debug.DrawLine(Target.transform.position, this.transform.position, Color.yellow);
                if (facingLeft)
                {
                    this.transform.Translate(Vector2.left * (Time.deltaTime * speed));
                }
                else if (!facingLeft)
                {
                    this.transform.Translate(Vector2.right * (Time.deltaTime * speed));
                }
            }
            if (Direction.magnitude < attackDistance)
            {
                Debug.DrawLine(Target.transform.position, this.transform.position, Color.red);
                voldoAnimator.SetBool("isAttacking", true);
                hero.playerDamage(1);
                Debug.Log("f**k");
            }
        }
        else if (Vector2.Distance(Target.position, this.transform.position) > engaugeDistance)
        {
            Debug.DrawLine(Target.position, this.transform.position, Color.green);
        }
        if (health <= 0)
        {
            //if(this.gameObject != null)
            //{
            hero.killcounter(1);
            Destroy(this.gameObject);
            //}
        }

        /*if()
         * voldoAnimator.Play("Voldo_Run");
         * if (dazedTime <= 0)
         * {
         *  speed = 5;
         * }
         * else
         * {
         *  voldoAnimator.Play("Voldo_Idle");
         *  voldoSpriteRenderer.material = matWhite;
         *  speed = 0;
         *  dazedTime -= Time.deltaTime;
         * }
         * if (health <= 0)
         * {
         *  Destroy(gameObject);
         * }
         * else
         * {
         *  voldoSpriteRenderer.material = matDefault;
         * }
         *
         * voldo_rb2d.velocity = new Vector2(4, voldo_rb2d.velocity.y);
         */
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (aggresive == false && increase <= hero.killreturn())
        {
            aggresive        = true;
            health          *= 2;
            speed           *= (float)1.3;
            increase        *= factor;
            aggresive        = false;
            engaugeDistance *= (float)1.3;
        }
        grubyAnimator.SetBool("isIdle", true);
        grubyAnimator.SetBool("isRunning", false);
        grubyAnimator.SetBool("isAttacking", false);
        if (Vector2.Distance(Target.position, this.transform.position) < engaugeDistance)
        {
            grubyAnimator.SetBool("isIdle", false);
            Vector2 Direction = Target.position - this.transform.position;
            if (Mathf.Sign(Direction.x) == 1 && facingLeft)
            {
                Flip();
            }
            else if (Mathf.Sign(Direction.x) == -1 && !facingLeft)
            {
                Flip();
            }
            if (Direction.magnitude >= attackDistance)
            {
                grubyAnimator.SetBool("isRunning", true);
                Debug.DrawLine(Target.transform.position, this.transform.position, Color.yellow);
                if (facingLeft)
                {
                    this.transform.Translate(Vector2.left * (Time.deltaTime * speed));
                }
                else if (!facingLeft)
                {
                    this.transform.Translate(Vector2.right * (Time.deltaTime * speed));
                }
            }
            if (Direction.magnitude < attackDistance)
            {
                Debug.DrawLine(Target.transform.position, this.transform.position, Color.red);

                grubyAnimator.SetBool("isAttacking", true);
                hero.playerDamage(1);
            }
        }
        else if (Vector2.Distance(Target.position, this.transform.position) > engaugeDistance)
        {
            Debug.DrawLine(Target.position, this.transform.position, Color.green);
        }
        if (health <= 0 && Death == false)
        {
            //if(this.gameObject != null)
            //{
            Death = true;
            grubyAnimator.Play("Gruby_Death");
            //grubySpriteRenderer.sortingOrder = 0;
            //yield WaitForSeconds(grubyAnimator["Gruby_Death"].length);
            Destroy(gameObject, 1.1f);

            hero.killcounter(1);
            //}
        }
    }