예제 #1
0
    void Start()
    {
        gameOver          = false;
        restart           = false;
        restartText.text  = "";
        gameOverText.text = "";

        CollisionProps collisionProps = GameObject.FindWithTag("Player").GetComponent <PlayerCollisionProps> ();

        SetHP(collisionProps.hitpoints, collisionProps.GetMaxHitPoints());

        score = 0;
        StartCoroutine(SpawnWaves());
    }
예제 #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        CollisionProps otherCollisionProps = other.gameObject.GetComponent <CollisionProps> ();
        CollisionProps thisCollisionProps  = gameObject.GetComponent <CollisionProps> ();

        if (otherCollisionProps != null && thisCollisionProps != null)
        {
            otherCollisionProps.SubtractHitpoints(thisCollisionProps.collisionDamage);
            thisCollisionProps.SubtractHitpoints(otherCollisionProps.collisionDamage);

            if (other.tag == "Player")
            {
                gameController.SetHP(otherCollisionProps.hitpoints, otherCollisionProps.GetMaxHitPoints());
            }

            if (thisCollisionProps.hitpoints <= 0)
            {
                ExplodeThis(gameObject);
            }

            if (otherCollisionProps.hitpoints <= 0)
            {
                if (other.tag == "Player")
                {
                    Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                    gameController.GameOver();
                    ExplodeOther(other.gameObject);
                }
                else
                {
                    Instantiate(explosion, other.transform.position, other.transform.rotation);
                    ExplodeOther(other.gameObject);
                }
            }
        }

        //if (other.tag != "Player") {  For God Mode
//		if (other.tag == "Player") {
//				Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
//			gameController.GameOver();
//			ExplodeOther (other.gameObject);
//		} else {
//			Instantiate (explosion, other.transform.position, other.transform.rotation);
//		}

        //if (other.tag == "Player") {
        //	Instantiate (playerExplosion, other.transform.position, other.transform.rotation);//FROM TUTORIAL
        //}

        //Transform t = gameObject.transform;
        //float growth = 1.02f;
        //t.localScale = new Vector3 (t.localScale.x*growth, t.localScale.y*growth, t.localScale.z*growth);

//		if (--hitpoints <= 0) {
//			ExplodeThis (gameObject);
//		}
    }