Ejemplo n.º 1
0
 void OnTriggerEnter(Collider coll)
 {
     if (coll.gameObject.tag == "upgradecrate")
     {
         upgrade_if_better(coll.gameObject);
         cs.GetComponent <CrateSpawnerScript>().return_crate(coll.gameObject);
     }
     else if (coll.gameObject.tag == "upgradefrontgun")
     {
         // What do we want to do here?
         Destroy(coll.gameObject);
     }
     else if (coll.gameObject.tag == "upgradesidegun")
     {
         // What do we want to do here?
         Destroy(coll.gameObject);
     }
     else if (coll.gameObject.tag == "shell")
     {
         // Week08 Week 08
         ShipStatsScript sss         = GetComponent <ShipStatsScript>();
         ShellScript     shellScript = coll.gameObject.GetComponent <ShellScript>();
         sss.take_damage(shellScript.damage);
         shellHolderScript.return_shell(coll.gameObject);
         shellHolderScript.get_Exp();
         //coll.point
     }
     else if (coll.gameObject.tag == "mine")
     {
         ShipStatsScript sss        = GetComponent <ShipStatsScript>();
         MineScript      mineScript = coll.gameObject.GetComponent <MineScript>();
         sss.take_damage(mineScript.damage);
     }
 }
Ejemplo n.º 2
0
    void OnCollisionEnter(Collision col)
    {
        if (debuggerScript == null)
        {
            Debug.Log("DebuggerScript null");
        }

        if (debugShellImpact == true)
        {
            Debug.Log("hit " + col.gameObject.name);
        }
        if (col.gameObject.name != gameObject.name && col.gameObject.layer == 9)
        {
            ShipStatsScript sss  = col.gameObject.GetComponent <ShipStatsScript>();
            ContactPoint    cont = col.contacts[0]; // new ContactPoint
            exp = shellHolderScript.get_Exp();
            if (!exp)
            {
                Debug.Log("Exp is null");
            }
            exp.transform.position = cont.point;
            // exp.transform.position = gameObject.transform.position;


            shellHolderScript.invoke_return_Exp(exp);

            sss.take_damage(damage);
            damage = Constants.MINIMUMDAMAGE;
        }

        if (col.gameObject.tag == "water")
        {
/*          ContactPoint cont = col.contacts[0];   // new ContactPoint
 *                      GameObject splash = Instantiate(splashPref, cont.point, Quaternion.identity);
 *                      Destroy(splash, 3.0f); */
        }
    }