﻿============================================================

[drv_level]  OnSetText

============================================================

' ===== CROWD POWER : drv_level の OnSetText =====

' DataLinq: Column = g1 / Row = mbar（0〜1。OtoMotion のバーの値）

' 盛り上がり度 = mbar × 100。範囲は OtoMotion の 設定 › バーの動き で決める

' 部品の名前はファイル名から .png を取ったもの（tick_01・needle など。_Image は付けない）。無い部品は飛ばす

' → 縦ゲージ（A）・ダイヤル（B）・横並び・イコライザー（C）の どのシーンでも このスクリプトのまま動く

dim TRAVEL as Double

TRAVEL = 696               ' A の BEST の線が 0 → 100 で上がる距離（px）。A が無いシーンでは使わない

dim LINE_Y0 as Double

LINE_Y0 = 540              ' best_line_a を置いた Y-Pos（全画面の画像なので 540）

dim NUM_Y0 as Double

NUM_Y0 = 126               ' best_a_num を置いた Y-Pos（点線の高さ。Object Manager の Y-Pos を書く）



dim o as xpBaseObject

dim t as xpTextObject

dim v as Double

dim lv as Integer

dim best as Integer

dim rec as Integer

dim fr as Integer

dim armed as Integer

dim i as Integer

dim nm as String



v = text / 1

if v < 0 then v = 0

if v > 1 then v = 1

lv = Int(v * 100 + 0.5)



' ---- 覚えている値（見えないテキスト var_* をメモに使う）----

best = 0

rec = 0

fr = 0

armed = 0

if Scene.GetObjectByName("var_best", t) then

  if t.Text <> "" then best = CInt(t.Text)

end if

if Scene.GetObjectByName("var_rec", t) then

  if t.Text <> "" then rec = CInt(t.Text)

end if

if Scene.GetObjectByName("var_frame", t) then

  if t.Text <> "" then fr = CInt(t.Text)

end if

if Scene.GetObjectByName("var_armed", t) then

  if t.Text <> "" then armed = CInt(t.Text)

end if



' ---- 最高記録 ----

' 一度 記録から 20 以上下がったあとに記録を超えたときだけ NEW RECORD を 3 秒出す

if lv <= best - 20 then armed = 1

if lv > best then

  if armed = 1 and best >= 60 then rec = 180

  armed = 0

  best = lv

end if

if rec > 0 then rec = rec - 1

fr = (fr + 1) mod 12



' ---- A: 縦ゲージ（24 段）----

for i = 1 to 24

  nm = "seg_" & Right("0" & CStr(i), 2)

  if Scene.GetObjectByName(nm, o) then o.Visible = (lv * 24 >= i * 100)

next

if Scene.GetObjectByName("tierA_good", o) then o.Visible = (lv >= 40)

if Scene.GetObjectByName("tierA_great", o) then o.Visible = (lv >= 60)

if Scene.GetObjectByName("tierA_amazing", o) then o.Visible = (lv >= 80)

if Scene.GetObjectByName("tierA_max", o) then o.Visible = (lv >= 95)



' BEST の線と数字（A）: 0 の高さから、記録の分だけ上げる

if Scene.GetObjectByName("best_line_a", o) then o.PosY = LINE_Y0 + TRAVEL * best / 100

if Scene.GetObjectByName("best_a_num", o) then o.PosY = NUM_Y0 + TRAVEL * best / 100



' ---- B: ダイヤル（30 本）----

for i = 1 to 30

  nm = "tick_" & Right("0" & CStr(i), 2)

  if Scene.GetObjectByName(nm, o) then o.Visible = (lv * 30 >= (i * 2 - 1) * 50)

next

' XPression は値を増やすと時計回り。0 で左（-180）、100 で右（0）

if Scene.GetObjectByName("needle", o) then o.RotZ = 180 * v - 180

if Scene.GetObjectByName("best_marker_b", o) then o.RotZ = 1.8 * best - 180

if Scene.GetObjectByName("tierB_noise", o) then o.Visible = (lv < 40)

if Scene.GetObjectByName("tierB_good", o) then o.Visible = (lv >= 40 and lv < 60)

if Scene.GetObjectByName("tierB_great", o) then o.Visible = (lv >= 60 and lv < 80)

if Scene.GetObjectByName("tierB_amazing", o) then o.Visible = (lv >= 80 and lv < 95)

if Scene.GetObjectByName("tierB_max", o) then o.Visible = (lv >= 95)



' ---- 数字 ----

if Scene.GetObjectByName("num_a", t) then t.Text = CStr(lv)

if Scene.GetObjectByName("num_b", t) then t.Text = CStr(lv)

if Scene.GetObjectByName("num_c", t) then t.Text = CStr(lv)

if Scene.GetObjectByName("best_a_num", t) then t.Text = CStr(best)

if Scene.GetObjectByName("best_b_num", t) then t.Text = CStr(best)

if Scene.GetObjectByName("best_c_num", t) then t.Text = CStr(best)



' ---- 演出 ----

if Scene.GetObjectByName("flash", o) then o.Visible = (lv >= 95 and fr < 6)

if Scene.GetObjectByName("new_record", o) then o.Visible = (rec > 0)

if Scene.GetObjectByName("flash_a", o) then o.Visible = (lv >= 95 and fr < 6)

if Scene.GetObjectByName("new_record_a", o) then o.Visible = (rec > 0)

if Scene.GetObjectByName("flash_b", o) then o.Visible = (lv >= 95 and fr < 6)

if Scene.GetObjectByName("new_record_b", o) then o.Visible = (rec > 0)



' ---- 覚える ----

if Scene.GetObjectByName("var_best", t) then t.Text = CStr(best)

if Scene.GetObjectByName("var_rec", t) then t.Text = CStr(rec)

if Scene.GetObjectByName("var_frame", t) then t.Text = CStr(fr)

if Scene.GetObjectByName("var_armed", t) then t.Text = CStr(armed)





============================================================

[drv_elapsed]  OnSetText

============================================================

' ===== CROWD POWER : drv_elapsed の OnSetText =====

' DataLinq: Column = （空欄）/ Row = elapsed

' OtoMotion で「リセット」を押す（経過が 00:00:00 に戻る）と、最高記録を 0 に戻す

dim t as xpTextObject

dim prev as String

prev = ""

if Scene.GetObjectByName("var_elapsed", t) then prev = t.Text

if text = "00:00:00" and prev <> "00:00:00" and prev <> "" then

  if Scene.GetObjectByName("var_best", t) then t.Text = "0"

  if Scene.GetObjectByName("var_rec", t) then t.Text = "0"

  if Scene.GetObjectByName("var_armed", t) then t.Text = "0"

end if

if Scene.GetObjectByName("var_elapsed", t) then t.Text = text

