コード例 #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Bullet")                                             // Should probably have used lowercase, but I didn't when making the tag so I can't do so here.
     {
         Destroy(other.gameObject);                                         // Destroy the bullet - mostly because it was in the code given by the teacher, but we might as well.
         Instantiate(targetCorpse, transform.position, transform.rotation); // Spawn the corpse.
         // Do any special effect stuff, like blood-splatter or such. We should do SOMETHING, it feels underwhelming at the moment.
         print("Wolf hit, worth " + targetValue);                           // Debug stuff.
         manager.AddPoints(targetValue);
         Destroy(this.gameObject);                                          // Finish by destroying the 'live' enemy/Target.
     }
 }
コード例 #2
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "LevelEnd")
        {
            Debug.Log("END OF LEVEL");
            Destroy(gameObject);
            EndLevel = true;
            PlayerController.PlayerPassed = true;
            PlayerController.AddPoints(100, PlayerController.currentPlayer.ToString());
            PlayerController.PlayersTurnSwitch();
        }

        if (col.gameObject.tag == "Ground")
        {
            Debug.Log("Bee has hit the ground - Delete - Turn over");
            UIControl.PlayerAnimatedText.text = PlayerController.currentPlayer.ToString() + " Failed";
            Debug.Log(UIControl.PlayerAnimatedText.text);
            //StartCoroutine(PlayerController.TurnSwitchTimer(3.0f));
            Destroy(gameObject);
            PlayerController.PlayersTurnSwitch();
        }



        if (col.gameObject.tag == "Cherry")
        {
            Debug.Log("explosions");
            Vector3 playercurrentPos;
            Vector3 AddExplosion;
            Vector3 HazardOriginalLocation = col.collider.transform.position;
            Vector3 aimedDirection;
            float   thrust = 1000.0f;
            aimedDirection = (PlayerController.transform.position - transform.position).normalized;


            //Add animation


            Rigidbody.velocity = Vector3.zero;
            Rigidbody.AddForce(aimedDirection * thrust, ForceMode2D.Impulse);
            Destroy(col.collider.gameObject);

            PlayerController.PlayersTurnSwitch();
        }

        //if (col.gameObject.tag == "Mushroom")
        //{
        //	Debug.Log("MUSHROOMED");


        //	//Whatever the mushroom does

        //	PlayerController.playerOneBEE.gravityScale++;

        //}

        //if (col.gameObject.tag == "Thorn")
        //{
        //	Debug.Log("THORNS");


        //	//Bee is violently impaled by thorns

        //	Destroy(gameObject);
        //}

        //if (col.gameObject.tag == "Web")
        //{
        //	//Drag++;

        //	Debug.Log("SLOWED");
        //	//Bee is slowed down
        //	Debug.Log(PlayerController.playerOneBEE.angularDrag);

        //	PlayerController.playerOneBEE.angularDrag++;
        //	PlayerController.playerOneBEE.drag++;



        //	//PlayerController.playerOneBEE.drag = Drag;

        //	Debug.Log(PlayerController.playerOneBEE.angularDrag);

        //}
    }