コード例 #1
0
ファイル: Bullet_Collide.cs プロジェクト: diaosuyidsy/Crush
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Target")
        {
            Score_param a = new Score_param(Time.time, true);
            GameObject.FindGameObjectWithTag("GameManager").SendMessageUpwards("Score", a);
            GameObject.FindGameObjectWithTag("GameManager").SendMessage("playSound", "Explosion");

            sendPos();
            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "Brick" || other.gameObject.tag == "Deathzone")
        {
            Score_param a = new Score_param(Time.time, false);
            GameObject.FindGameObjectWithTag("GameManager").SendMessageUpwards("Score", a);
            GameObject.FindGameObjectWithTag("GameManager").SendMessage("playSound", "Explosion");

            sendPos();
            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "Bounce" || other.gameObject.tag == "EnvironmentBounce")
        {
            GameObject.FindGameObjectWithTag("GameManager").SendMessage("playSound", "Bounce");
        }
    }
コード例 #2
0
ファイル: Controller.cs プロジェクト: diaosuyidsy/Crush
    void Score(Score_param a)
    {
        float time    = a.time;
        bool  succeed = a.succeed;

        timeContainer.Add(time);
        if (succeed)
        {
            countForLevel++;
        }
        else
        {
            countForFail++;
        }
        if (countForLevel + countForFail >= target_num)
        {
            if (countForFail > 0)
            {
//				FailStep ();
                StartCoroutine(FailStep());
            }
            else
            {
                CalculateScore();
            }
            save_launchers_info();
        }
    }
コード例 #3
0
ファイル: Bullet_Collide.cs プロジェクト: diaosuyidsy/Crush
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Target")
        {
            Score_param a = new Score_param(Time.time, true);
            GameObject.FindGameObjectWithTag("GameManager").SendMessageUpwards("Score", a);
            GameObject.FindGameObjectWithTag("GameManager").SendMessage("playSound", "Explosion");
            sendPos();
            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "Brick" || other.gameObject.tag == "Deathzone")
        {
            Score_param a = new Score_param(Time.time, false);
            GameObject.FindGameObjectWithTag("GameManager").SendMessageUpwards("Score", a);
            GameObject.FindGameObjectWithTag("GameManager").SendMessage("playSound", "Explosion");
            sendPos();
            Destroy(gameObject);
        }
        else if (other.gameObject.tag == "Bounce" || other.gameObject.tag == "EnvironmentBounce")
        {
            GameObject.FindGameObjectWithTag("GameManager").SendMessage("playSound", "Bounce");
        }
        else if (other.gameObject.tag == "Bullet")
        {
//			if (!hit) {
//				Vector2 newV = elasticCollision (gameObject.GetComponent<Rigidbody2D> ().velocity, other.gameObject.GetComponent<Rigidbody2D> ().velocity, transform.position, other.gameObject.transform.position);
//				Vector2 newVP = elasticCollision (other.gameObject.GetComponent<Rigidbody2D> ().velocity, gameObject.GetComponent<Rigidbody2D> ().velocity, other.gameObject.transform.position, transform.position);
//
//				gameObject.GetComponent<Rigidbody2D> ().velocity = newV;
//				other.attachedRigidbody.velocity = newVP;
//				other.gameObject.GetComponent<Bullet_Collide> ().hit = true;
//			} else {
//				hit = false;
//			}
        }
    }