Beispiel #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //MhCommon.Print("StgPlayer::OnTriggerEnter2D tag=" + collision.tag);
     if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kEnemy))
     {
         MhCommon.Assert(health != null, "StgPlayer::OnTriggerEnter2D health null");
         int beforeHealth = health.GetHealth();
         health.Sub(-1);
         if (health.GetHealth() <= 0)
         {
             health.SetHealth(0);
         }
         // HP変更通知
         healthObservable.NotifyObservers(health.GetMaxHealth(), health.GetHealth(), beforeHealth - health.GetHealth());
         MhCommon.Print("StgPlayer::OnTriggerEnter2D health=" + health.GetHealth());
     }
     else if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kItemPowerup))
     {
         // パワーアップアイテム取得処理
         Powerup();
     }
     else if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kItemScoreup))
     {
         // スコアアイテム
     }
 }
Beispiel #2
0
 /// <summary>
 /// 当たり判定処理
 /// </summary>
 /// <param name="collision">当たり判定対象</param>
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kPlayer))
     {
         // プレイヤーと触れた時に消滅、スコアを加算
         Destroy(this.gameObject);
         AdditionalScore(StgItemConstant.kScorePowerup);
     }
 }
Beispiel #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //MhCommon.Print("StgPlayerBullet::OnTriggerEnter2D tag=" + collision.tag);
     if (collision.tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kEnemy))
     {
         // 敵と当たったら消滅する
         Destroy(this.gameObject);
     }
 }
Beispiel #4
0
 /// <summary>
 /// 当たったか(プレイヤーかプレイヤーの弾なら当たったとみなす)
 /// </summary>
 /// <returns>trueなら当たっている</returns>
 protected bool IsHit(string tag)
 {
     if ((tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kPlayerBullet)) ||
         (tag == StgGameObjectTag.ToString(StgGameObjectTag.Type.kPlayer)))
     {
         return(true);
     }
     return(false);
 }