Пример #1
0
 private void Start()
 {
     rb          = GetComponent <Rigidbody2D>();
     sr          = GetComponent <SpriteRenderer>();
     a           = GetComponent <Animator>();
     groundCheck = GetComponentInChildren <groundCheck>();
 }
Пример #2
0
    // Update is called once per frame
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!GameManager.gameOver && GameManager.gameStarted)
        {
            if (col.gameObject.tag == "GroundCheck")
            {
                check = col.gameObject.GetComponent <groundCheck> ();
            }
            else if (col.gameObject.tag == "Player")
            {
                player = col.gameObject.GetComponent <Player> ();
            }

            if (col.gameObject.tag == "GroundCheck" && (check.character.rb.velocity.y < 0 || check.character.rb.velocity.y == check.character.jumpSpeed) && !roundMotion && !isfake && !GameManager.gameOver)
            {
                anim.SetTrigger("shake");
            }
            else if (!isCracked && col.gameObject.tag == "GroundCheck" && (check.character.rb.velocity.y < 0 || check.character.rb.velocity.y == check.character.jumpSpeed) && !roundMotion && isfake)
            {
                anim.SetBool("broke", true);
                audi.Play();                 //Ses dosyamızı ne zaman çalışacağını gösterdik
                box.enabled = false;
                anim.SetBool("restarted", false);
            }
            else if (col.gameObject.tag == "Player" && (player.rb.velocity.y > 1 || player.rb.velocity.y != player.jumpSpeed && !Player.jetpack) && !roundMotion && !isfake && isBlock)
            {
                player.rb.velocity = new Vector2(player.rb.velocity.x, -1f);
                damage++;

                if (damage == 1)
                {
                    mySprite.sprite = damage1;
                }
                else if (damage == 2)
                {
                    mySprite.sprite = damage2;
                }
                else if (damage == 3)
                {
                    mySprite.sprite = null;
                }
                if (damage == 3)
                {
                    anim.SetTrigger("broke");
                    Invoke("despawnThis", 2f);
                    blockBroke.Play();
                }
                else
                {
                    audi.Play();
                    anim.SetTrigger("blockShake");                     //block
                }
            }
        }
    }
Пример #3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!check && col.gameObject.tag == "GroundCheck")
        {
            check = col.gameObject.GetComponent <groundCheck> ();
        }


        if (col.gameObject.tag == "GroundCheck" && check.character.rb.velocity.y < 0 && !GameManager.gameOver)
        {
            check.character.enableTrambolin();
            check.character.jump(check.character.jumpSpeed * 2);
            anim.SetTrigger("trambolin");
            audi.Play();
        }
    }
Пример #4
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!died)
        {
            if (col.gameObject.tag == "GroundCheck")
            {
                check = col.gameObject.GetComponent <groundCheck> ();
            }
            if (col.gameObject.tag == "Player")
            {
                player = col.gameObject.GetComponent <Player> ();
            }


            if (col.gameObject.name == "Player" && player && player.rb.velocity.y > 0 && AlttanOlum)              //karekter aşağıdan geliyor
            {
                player.die();
            }
            else if (col.gameObject.tag == "GroundCheck" && check && check.character.rb.velocity.y < 0 && !GameManager.gameOver)                 // karekter yukardan geliyor
            {
                if (UsttenOlum)
                {
                    check.character.die();                      // yukardan geliyorsa karakter ölür
                }
                else
                {
                    check.character.jump(check.character.jumpSpeed);
                    // eğer yukardan gelenden ölüyorsa ölür

                    if (AlttanOlum)
                    {
                        deleteEnemy();
                        audi.Play();
                    }
                }
            }
        }
    }