Beispiel #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     Debug.Log(other.name + " " + index);
     if (index == 1)
     {
         if (other.name == "16bullet(Clone)" || other.name == "Turret")
         {
             ps = Instantiate(enemyKillEffect,
                              this.gameObject.transform.position,
                              this.gameObject.transform.rotation);
             if (other.name == "Turret")
             {
                 setup.bloodNum -= 1;
                 setup.AddScore(-50);
             }
             else
             {
                 setup.AddScore(5);
             }
             Destroy(this.gameObject);
         }
     }
     else if (index == 0)
     {
         if (other.name == "8bullet(Clone)" || other.name == "Turret")
         {
             ps = Instantiate(enemyKillEffect,
                              this.gameObject.transform.position,
                              this.gameObject.transform.rotation);
             if (other.name == "Turret")
             {
                 setup.bloodNum -= 1;
                 setup.AddScore(-100);
             }
             else
             {
                 setup.AddScore(10);
             }
             Destroy(this.gameObject);
         }
     }
 }
Beispiel #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
//		Regex
        if (index == 1)
        {
            if (Regex.IsMatch(
                    other.name,
                    "16enemy",
                    RegexOptions.IgnoreCase))
            {
                Destroy(this.gameObject);
            }
            else if (Regex.IsMatch(other.name,
                                   "EnemySpawnPoint",
                                   RegexOptions.IgnoreCase))
            {
                Destroy(this.gameObject);
                setup.AddScore(-10);
            }
        }
        else
        {
            if (Regex.IsMatch(
                    other.name,
                    "8enemy",
                    RegexOptions.IgnoreCase))
            {
                Destroy(this.gameObject);
            }
            else if (Regex.IsMatch(
                         other.name,
                         "EnemySpawnPoint",
                         RegexOptions.IgnoreCase))
            {
                Destroy(this.gameObject);
                setup.AddScore(-20);
            }
        }
    }