Ejemplo n.º 1
0
 void OnCollisionEnter2D(Collision2D collision)  
 {
     if (collision.gameObject.name == playerTag)
     {
           {
             if (transform.position.y + 0.3f < this.player.transform.position.y)
             {
                   {
                     this.speed = 0;
                     this.animator.SetTrigger("DaiTrigger");
                     this.player.GetComponent <Rigidbody2D>().AddForce(transform.up * 5.0f, ForceMode2D.Impulse);
                 }
             }
              else  {
                 count.SetPoint(this.point);
                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
             }
         }
     }
     else if (collision.gameObject.tag != groundTag && collision.gameObject.transform.position.y > this.transform.position.y - 0.2f)
     {
           {
             key = key * -1;
         }
     }
 }
Ejemplo n.º 2
0
 void FlyCollision(Collision2D collision)
 {
     if (collision.gameObject.name.Equals(playerTag) && this.isCollision == false && transform.position.y + 0.3f < this.player.transform.position.y)
     {
         this.isCollision = true;
         this.player.GetComponent <Rigidbody2D>().AddForce(transform.up * 5.0f, ForceMode2D.Impulse);
         this.animator.SetTrigger("NomalTrigger");
         this.rigid2D.bodyType = RigidbodyType2D.Dynamic;
         this.mode             = "nomal";
     }
     else if (collision.gameObject.name.Equals(playerTag))
     {
         count.SetPoint(this.point);
         SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     }
 }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.name == "Player")
     {
         count.SetPoint(this.point);
         SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     }
 }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        //ジャンプ処理:isJumpがfalseの時ジャンプできるようにしている
        if (Input.GetKeyDown(KeyCode.Space) && this.isJump == false)
        {
            this.animator.SetTrigger("JumpTrigger");
            this.rigid2D.AddForce(transform.up * this.jumpForce, ForceMode2D.Impulse);
            this.isJump = true;
        }
        //左右移動
        int key = 0;

        if (Input.GetKey(KeyCode.RightArrow))
        {
            key = 1;
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            key = -1;
        }

        //プレイヤの速度
        float speedx = Mathf.Abs(this.rigid2D.velocity.x);

        //スピード制限
        if (speedx < this.maxWalkSpeed)
        {
            this.rigid2D.AddForce(transform.right * key * this.walkForce, ForceMode2D.Force);
        }

        //キャラ反転
        if (key != 0)
        {
            transform.localScale = new Vector3(key, 1, 1);
        }
        //アニメーションの速度
        if (this.rigid2D.velocity.y == 0)
        {
            this.animator.speed = speedx / 3.0f;
        }
        else
        {
            this.animator.speed = 1.0f;
        }

        if (transform.position.y < -9)
        {
            count.SetPoint(this.point);
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
    }
Ejemplo n.º 5
0
    // Start is called before the first frame update

    void OnCollisionEnter2D(Collision2D collision)
    {
        //playerとの衝突判定
        if (collision.gameObject.name.Equals(playerTag) && this.span == false)
        {
            this.span = true;
            //動かない甲羅状態()かノコノコもしくは動いている甲羅状態かで判定を分けている
            if (mode == "kora")
            {
                if (transform.position.x < this.player.transform.position.x)
                {
                    this.key = -1;
                }
                else
                {
                    this.key = 1;
                }
                this.speed = 0.03f;
                mode       = "killer";
            }
            else
            {
                //上から踏まれているかで処理を変えている.
                if (transform.position.y + 0.3f < this.player.transform.position.y)
                {
                    mode       = "kora";
                    this.speed = 0;
                    this.animator.SetTrigger("koraTrigger");
                    this.player.GetComponent <Rigidbody2D>().AddForce(transform.up * 5.0f, ForceMode2D.Impulse);
                    CircleCollider2D collider = GetComponent <CircleCollider2D>();
                    collider.offset = new Vector2(0.0f, 0.0f);
                    collider.radius = 0.25f;
                }
                else
                {
                    count.SetPoint(this.point);
                    SceneManager.LoadScene(SceneManager.GetActiveScene().name);
                }
            }
        }
        else if (mode == "killer" && collision.gameObject.tag.Equals(kuriboTag))
        {
            Destroy(collision.gameObject);
        }

        else if (collision.gameObject.tag != groundTag && collision.gameObject.tag != playerTag)
        {
            key = key * -1;
        }
    }