Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "ScoreLine")
        {
            scoreline++;
        }

        if (other.tag == "item")
        {
            ItemJump o = other.gameObject.GetComponent <ItemJump>();
            if (o != null)
            {
                audioSource.PlayOneShot(ItemSE);
                IJumpH        = o.boundHeight; //踏んづけたものから跳ねる高さを取得する
                IJumpC       += o.boundCount;
                IJump         = true;
                o.playerjump  = true;       //踏んづけたものに対して踏んづけた事を通知する
                jumpText.text = string.Format("ジャンプ残り {0} 回", IJumpC);
            }
            else
            {
                Debug.Log("ObjectCollisionが付いてないよ!");
            }
        }

        if (other.gameObject.tag == "DeathGround")
        {
            Camera.main.gameObject.GetComponent <CameraScritpt>().Shake();
            Instantiate(playerDeathObj, transform.position, Quaternion.identity);

            //プレイヤー死亡
            isDeadFlag = true;
        }
        if (other.gameObject.tag == "ColorBlock")
        {
            hip  = false;
            stop = false;
        }
    }
Esempio n. 2
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Ground")
        {
            //プレイヤー死亡
            isDeadFlag = true;
        }

        if (other.gameObject.tag == "DGround")
        {
            OnDamegeEffect();
            Hp--;
            HPtext.text = string.Format("HP: {0}", Hp);
        }

        if (other.collider.tag == "item")
        {
            ItemJump o = other.gameObject.GetComponent <ItemJump>();
            if (o != null)
            {
                IJumpH       = o.boundHeight; //踏んづけたものから跳ねる高さを取得する
                IJumpC       = o.boundCount;
                IJump        = true;
                o.playerjump = true;        //踏んづけたものに対して踏んづけた事を通知する
            }
            else
            {
                Debug.Log("ObjectCollisionが付いてないよ!");
            }
        }
          
        if (other.collider.tag == "Enemy" || other.collider.tag == "HighEnemy")
        {
            //踏みつけ判定になる高さ
            float stepOnHeight = (capcol.size.y * (stepOnRate / 100f));
            //踏みつけ判定のワールド座標
            float judgePos = transform.position.y - (capcol.size.y / 2f) + stepOnHeight;
            Debug.Log("接触したよ");
            foreach (ContactPoint2D p in other.contacts)
            {
                if (p.point.y < judgePos)
                {
                    EnemyJump o = other.gameObject.GetComponent <EnemyJump>();
                    if (o != null)
                    {
                        otherJumpHeight = o.boundHeight;        //踏んづけたものから跳ねる高さを取得する
                        o.playerjump    = true;                 //踏んづけたものに対して踏んづけた事を通知する
                        jumpPos         = transform.position.y; //ジャンプした位置を記録する
                        isOtherJump     = true;
                        isJump          = false;
                        jumpTime        = 0.0f;
                        Debug.Log("ジャンプしたよ");
                        Camera.main.gameObject.GetComponent <CameraScritpt>().Shake();
                        if (other.collider.tag == "Enemy")
                        {
                            score += AddPoint / 2;//スコアを足す(4/17)
                        }
                        else
                        {
                            score += HighPoint / 2;
                        }
                    }
                    else
                    {
                        Debug.Log("ObjectCollisionが付いてないよ!");
                    }
                }
                else
                {
                    isDown = true;
                    break;
                }
            }
        }
    }