// ------------------------------------------------------------------------ // ロックオンレーザー発射. // ------------------------------------------------------------------------ private void StartLockonLaser() { int countLockon = 0; // ロックオン数を数える. for (int i = 0; i < MAX_LOCKON_COUNT; i++) { if (lockedOnEnemyIds[i] != invalidInstanceId) { if (lockonLaserIds[i] == invalidInstanceId) { // ロックオンボーナス. countLockon++; lockBonus.SetLockCount(countLockon); } } } for (int i = 0; i < MAX_LOCKON_COUNT; i++) { if (lockedOnEnemyIds[i] != invalidInstanceId) { // ロックオンレーザーをまだ作成していない時のみ. if (lockonLaserIds[i] == invalidInstanceId) { // ------------------------------------------------------------ // ロックオンレーザー作成. // ------------------------------------------------------------ // プレイヤーの座標取得. Vector3 playerPos = player.transform.position; Quaternion playerRot = player.transform.rotation; // レーザーの射出角度を決める. Quaternion startRotation = player.transform.rotation; float laserRotationAngle = startRotation.eulerAngles.y; laserRotationAngle += lockonLaserStartRotation[i]; Quaternion tiltedRotation = Quaternion.Euler(0, laserRotationAngle, 0); playerRot = tiltedRotation; // ロックオンレーザー作成. GameObject tmpLockonLaser; tmpLockonLaser = Instantiate(lockonLaser, playerPos, playerRot) as GameObject; tmpLockonLaser.SendMessage("SetLockonBonus", Mathf.Pow(2, countLockon)); tmpLockonLaser.SendMessage("SetTargetEnemy", lockedOnEnemys[i]); lockonLaserIds[i] = tmpLockonLaser.GetInstanceID(); } } } // メッセージ消去. if (countLockon == 0) { } }
// ------------------------------------------------------------------------ // 发射锁定激光 // ------------------------------------------------------------------------ private void StartLockonLaser() { int countLockon = 0; // 统计锁定数量 for (int i = 0; i < MAX_LOCKON_COUNT; i++) { if (lockedOnEnemyIds[i] != invalidInstanceId) { if (lockonLaserIds[i] == invalidInstanceId) { // 锁定奖励 countLockon++; lockBonus.SetLockCount(countLockon); } } } for (int i = 0; i < MAX_LOCKON_COUNT; i++) { if (lockedOnEnemyIds[i] != invalidInstanceId) { // 只在锁定激光未生成时执行 if (lockonLaserIds[i] == invalidInstanceId) { // ------------------------------------------------------------ // 生成锁定激光 // ------------------------------------------------------------ // 获取玩家的坐标 Vector3 playerPos = player.transform.position; Quaternion playerRot = player.transform.rotation; // 决定激光的射出角度 Quaternion startRotation = player.transform.rotation; float laserRotationAngle = startRotation.eulerAngles.y; laserRotationAngle += lockonLaserStartRotation[i]; Quaternion tiltedRotation = Quaternion.Euler(0, laserRotationAngle, 0); playerRot = tiltedRotation; // 生成锁定激光 GameObject tmpLockonLaser; tmpLockonLaser = Instantiate(lockonLaser, playerPos, playerRot) as GameObject; tmpLockonLaser.SendMessage("SetLockonBonus", Mathf.Pow(2, countLockon)); tmpLockonLaser.SendMessage("SetTargetEnemy", lockedOnEnemys[i]); lockonLaserIds[i] = tmpLockonLaser.GetInstanceID(); } } } // 消除消息 if (countLockon == 0) { } }