//ショット切り替えボタン押下時の処理 public void shotChangerOnClick(int argBtnNum) { changeColor(argBtnNum); List <KeyValuePair <string, int> > sPair = new List <KeyValuePair <string, int> >(dicta); foreach (var item in sPair) { if (item.Value == argBtnNum) { Debug.Log(item.Key + "pressed..."); if (item.Key == "shot1") { shotType.setShotType_1(); shotType.setPlayerShotDelay_1(); } else if (item.Key == "shot2") { shotType.setShotType_2(); shotType.setPlayerShotDelay_2(); } else if (item.Key == "shot3") { shotType.setShotType_3(); shotType.setPlayerShotDelay_3(); } else if (item.Key == "shot4") { shotType.setShotType_4(); shotType.setPlayerShotDelay_4(); } } } }
// ぶつかった瞬間に呼び出される cはぶつかってきた物体のコライダ // 敵ならばダメージ アイテムならば取得処理を記載 void OnTriggerEnter2D(Collider2D c) { if (managerObj != null && managerObj.IsGamePause() != true) { // レイヤー名を取得 // 以下、コライダのレイヤー名で判定する string layerName = LayerMask.LayerToName(c.gameObject.layer); // レイヤー名がBullet(Enemy)の時は弾を削除 if (layerName == "Bullet(Enemy)") { // 弾の削除 Destroy(c.gameObject); } // レイヤー名がBullet(Enemy)またはEnemy,Boss1の場合は damage if (layerName == "Bullet(Enemy)" || layerName == "Enemy" || layerName == "Boss1") { playerlife.damagePlayerHp(); Debug.Log("Damage(Player.cs) == >" + playerlife.getPlayerHp()); spaceship.Explosion(); //Game Over if (playerlife.getPlayerHp() <= 0) { // Manager GameOverメソッドを呼び出す managerObj.GameOver(); // 爆発する spaceship.Explosion(); //オプションを削除 followerMng.destroyOldFollowers(); //ゲームを停止 managerObj.isPause = true; // プレイヤーを削除 Destroy(gameObject); } } //TODO アイテム獲得時の分岐 if (layerName == "ItemN") { Debug.Log("ItemN GET"); shotType.setShotType_1(); shotType.setPlayerShotDelay_1(); Destroy(c.gameObject); FindObjectOfType <ShotTypeChanger> ().changeShot(1); } else if (layerName == "ItemE") { Debug.Log("ItemE GET"); shotType.setShotType_2(); shotType.setPlayerShotDelay_2(); Destroy(c.gameObject); FindObjectOfType <ShotTypeChanger> ().changeShot(2); } else if (layerName == "ItemL") { Debug.Log("ItemL GET"); shotType.setShotType_3(); shotType.setPlayerShotDelay_3(); Destroy(c.gameObject); FindObjectOfType <ShotTypeChanger> ().changeShot(3); } else if (layerName == "ItemM") { Debug.Log("ItemM GET"); shotType.setShotType_4(); shotType.setPlayerShotDelay_4(); Destroy(c.gameObject); FindObjectOfType <ShotTypeChanger> ().changeShot(4); } else if (layerName == "ItemOpt") { //TODO オプションを生成処理 if (followerMng.IsFollowerMax() == false) { FindObjectOfType <BombManager>().increaseBombNum(); //ボムの数を加算 GameObject prefab = (GameObject)Resources.Load("followers"); Instantiate(prefab, transform.position, Quaternion.identity); } Destroy(c.gameObject); } else if (layerName == "ItemBarrier") { GameObject.Find("ItemBarrier").renderer.enabled = true; Destroy(c.gameObject); } else if (layerName == "ItemSuperShot") { GameObject.Find("ItemSuperShot").renderer.enabled = true; superShot.superShotFlg = 1; Destroy(c.gameObject); } } }