コード例 #1
0
 private void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "bad")
     {
         GameObject   refObj = GameObject.Find("CloudFactory");
         CloudFactory cf     = refObj.GetComponent <CloudFactory>();
         cf.DestroyCloud();
         Player.ySpeed = -15.0f;
         Player.isJump = false;
         anim.SetBool("jump", false);
         anim.SetBool("run", false);
         anim.SetBool("down", true);
         audioSource.SoundBad();
     }
     if (collider.tag == "correct")
     {
         if (one)
         {
             GameObject obj = collider.gameObject;
             Destroy(obj);
             GameDirector.next = true;
             one = false;
             audioSource.SoundCorrect();
         }
     }
 }
コード例 #2
0
ファイル: GroundCheck.cs プロジェクト: tatsuyounggg/WebGLGame
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == "cloud")
        {
            if (SceneManager.GetActiveScene().name == "GameScene")
            {
                isGroundEnter = true;
            }
            else if (SceneManager.GetActiveScene().name == "TitleScene")
            {
                isGroundEnter = true;
                GameObject    refObj = GameObject.Find("CloudFactory");
                CloudFactoryT cf     = refObj.GetComponent <CloudFactoryT>();
                cf.MakeGround(collider);
            }
        }
        else if (collider.tag == "ground")
        {
            if (SceneManager.GetActiveScene().name == "GameScene")
            {
                // Physics2D.IgnoreLayerCollision(player_layer, ground_floor_layer, false);
                anim.SetBool("down", false);
                isGroundEnter = true;
                GameObject   refObj = GameObject.Find("CloudFactory");
                CloudFactory cf     = refObj.GetComponent <CloudFactory>();
                cf.DestroyCloud();
                cf.MakeChoice(collider);
            }

            else if (SceneManager.GetActiveScene().name == "TitleScene")
            {
                // Physics2D.IgnoreLayerCollision(player_layer, ground_floor_layer, false);
                isGroundEnter = true;
                GameObject    refObj = GameObject.Find("CloudFactory");
                CloudFactoryT cf     = refObj.GetComponent <CloudFactoryT>();
                cf.DestroyCloud();
                cf.MakeChoice(collider);
            }
        }

        else if (collider.tag == "choice")
        {
            if (SceneManager.GetActiveScene().name == "GameScene")
            {
                isGroundEnter = true;
                GameObject   refObj = GameObject.Find("CloudFactory");
                CloudFactory cf     = refObj.GetComponent <CloudFactory>();
                cf.MakeCloud(collider);
            }
            else if (SceneManager.GetActiveScene().name == "TitleScene")
            {
                isGroundEnter = true;
                GameObject    refObj = GameObject.Find("CloudFactory");
                CloudFactoryT cf     = refObj.GetComponent <CloudFactoryT>();
                cf.MakeCloud(collider);
            }
        }
    }