Example #1
0
 void Update()
 {
     if (ai.GetIsMove())
     {
         anim.SetInteger("dir", 0);
         dir       = ai.WhatIsDir();
         ai.speed += ai.speed * Time.deltaTime;
         dd        = true;
     }
     else if (dd) //sadece bir defa girsin.
     {
         dd = false;
         anim.SetInteger("dir", dir);
         ai.speed = BaseSpeed;
         if (HeadType == Type.Rock && dir > 0 && dir < 5)
         {
             Collider2D[] c = Physics2D.OverlapCircleAll(DirTransform[dir - 1].position, 0.2f);
             foreach (Collider2D cc in c)
             {
                 if (cc.gameObject.CompareTag("Player"))
                 {
                     cc.GetComponent <PlayerController>().PlayerDead();
                 }
             }
         }
     }
     ai.Move();
 }
Example #2
0
 void Update()
 {
     if (ai.enabled)
     {
         anim.SetBool("isWalk", ai.GetIsMove());
         ai.Move(true);
     }
     if (GreenDie && isDie)
     {
         timer += Time.deltaTime;
         if (timer > .5f)
         {
             isDie = false;
         }
     }
 }
Example #3
0
    void Update()
    {
        if (!ai.enabled)
        {
            return;
        }
        ai.Move(true);

        /* if (ai.GetIsMove())
         * {
         *   anim.SetBool("run", false);
         * }
         * else
         *   anim.SetBool("run", true);*/
        anim.SetBool("run", ai.GetIsMove());
    }
Example #4
0
 void Update()
 {
     //with shell
     if (!isDie)
     {
         ai.Move(true);
         anim.SetBool("walk", ai.GetIsMove());
     }
     else if (shellCollision)
     {
         if (rb.bodyType == RigidbodyType2D.Dynamic)
         {
             rb.velocity = v2 * shellSpeed * Time.deltaTime;
         }
     }
 }
Example #5
0
 void Update()
 {
     if (isFirstHit)
     {
         GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
         ai.moveSpots = groundSpot;
         ai.speed    *= 2;
         ai.SetIndex(0);
         ai.SetTime(waitTime);
         isFirstHit = false;
         //isDie = false;
         anim.SetBool("hit", true);
         Instantiate(leafsPrefab, transform.position, Quaternion.identity);
     }
     else if (anim.GetBool("hit") && GetComponent <Rigidbody2D>().velocity.y < 0.1f)
     {
         transform.localScale = new Vector3(1, 1, 1);
         anim.SetBool("hit", false);
     }
     ai.Move(true);
     anim.SetBool("run", ai.GetIsMove());
 }
Example #6
0
    void Update()
    {
        v2 = transform.localScale.x == 1 ? Vector2.left : Vector2.right;
        RaycastHit2D[] hit = Physics2D.RaycastAll(checkPos.position, v2);
        attack = false;
        foreach (RaycastHit2D h in hit)
        {
            if (h.collider.gameObject.layer == 8)
            {
                break;                                   //ground
            }
            if (h && h.collider.tag == "Player")
            {
                timer  = 0f;
                attack = true;
                break;
            }
        }


        if (attack == false)
        {
            anim.SetBool("attack", false);
            timer += Time.deltaTime;
            if (timer < AttackWaitTime)
            {
                anim.SetBool("run", false);
                return;
            }
            ai.Move(true);
            anim.SetBool("run", ai.GetIsMove());
        }
        else
        {
            anim.SetBool("attack", true);
        }
    }