コード例 #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Shot")
     {
         ShotDestroyerScript SDS = other.gameObject.GetComponent <ShotDestroyerScript>();
         if (!SDS.IsUsed)
         {
             if (MyLCP.hasShield)
             {
                 LocalPlayerController LPC = gameObject.GetComponentInParent <LocalPlayerController>();
                 Instantiate(shieldExplosion, LPC.mesh.transform.position, new Quaternion());
                 LPC.DisableShield();
                 Destroy(other.transform.root.gameObject);
             }
             else
             {
                 SDS.IsUsed = true;
                 Debug.Log("PLAYER HIT");
                 MyLCP.DestroyObject();
             }
             //explosionInstance.transform.SetParent(transform);
         }
     }
     else if (other.gameObject.tag == "Boundary" || other.gameObject.tag == "PiercingShot" || other.gameObject.tag == "StarPulse")
     {
         MyLCP.DestroyObject();
     }
 }
コード例 #2
0
 void SegmentTriggerBehaviour.Enter(Collider2D other, SegmentController segmentController)
 {
     if (other.gameObject.tag == "Shot")
     {
         ShotDestroyerScript SDS = other.GetComponent <ShotDestroyerScript> ();
         if (SDS.IsUsed == false)                    //if the shot has not yet hit something, destroy the segment and mark the shot used
         {
             Vector3 spawnPos = UtilityScript.transformToCartesian(other.transform.position);
             segmentController.DestroySegment(spawnPos);
             SDS.IsUsed = true;
         }
     }
     else if (other.gameObject.tag == "PiercingShot" || other.gameObject.tag == "StarPulse")
     {
         Vector3 spawnPos = UtilityScript.transformToCartesian(other.transform.position);
         segmentController.DestroySegment(spawnPos);
     }
 }