コード例 #1
0
 public void OnCollisionDefault(Collider2D other)
 {
     if (other.CompareTag("Obstacle"))
     {
         GameObstacle go = other.gameObject.GetComponent <GameObstacle> ();
         if (go.GetColor() != mr.material.color)
         {
             if (onDeath != null)
             {
                 onDeath();
             }
         }
     }
 }
コード例 #2
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.CompareTag("Obstacle"))
     {
         GameObstacle go = collider.gameObject.GetComponent <GameObstacle> ();
         if (go.GetColor() != mr.material.color)
         {
             GameObject explPrefab = Resources.Load <GameObject> ("PowerIcons/ExploDeath");
             if (onDeath != null)
             {
                 GameObject g = Instantiate(explPrefab) as GameObject;
                 g.transform.position = transform.position;
                 onDeath();
             }
         }
     }
 }
コード例 #3
0
ファイル: RandomSwitch.cs プロジェクト: Plenituz/Same
 void Update()
 {
     if (go == null)
     {
         go = GetComponent <GameObstacle> ();
     }
     if (go.GetColor() != color)
     {
         go.SetColor(color);
     }
     if (Time.time - startTime >= waitTime)
     {
         startTime = Time.time;
         waitTime  = Random.Range(minTimeBeforeSwitch, maxTimeBeforeSwitch);
         color     = color.r == 0f ? Color.white : Color.black;
         go.SetColor(color);
     }
 }