条件達成で通れる道

要件

  1. コレクティブルオブジェクトの配列を作成する
  2. コレクティブルオブジェクトを収集した時のイベントを登録する
  3. コレクティブルオブジェクトを獲得した回数を記録する
  4. バリアの仕掛けを設置する
  5. ボタンの仕掛けを設置する
  6. HUDメッセージの仕掛けを設置する
    • 「条件を満たしませんでした」とメッセージの設定をする
  7. ボタンの仕掛けをインタラクトすると以下の条件で動く
    • コレクティブルオブジェクトを回収した回数が3以上の場合はバリアが無効になる
    • コレクティブルオブジェクトを回収した回数が3未満の場合はHUDメッセージを表示する

使用する仕掛け

  1. コレクティブルオブジェクトの仕掛け(3個以上)
  2. バリアの仕掛け(x1)
  3. ボタンの仕掛け(x1)
  4. HUDメッセージの仕掛け(x1)

回答

回答を見る
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

collect_coin_device := class(creative_device):
    @editable
    CollectibleObjectDevices:[]collectible_object_device = array{}
    @editable
    ButtonDevice:button_device = button_device{}
    @editable
    BarrierDevice:barrier_device = barrier_device{}
    @editable
    HUDMessageDevice:hud_message_device = hud_message_device{}

    var CollectCount:int = 0

    OnBegin<override>()<suspends>:void=
        for(CollectibleObject : CollectibleObjectDevices):
            CollectibleObject.CollectedEvent.Subscribe(OnCollect)

        ButtonDevice.InteractedWithEvent.Subscribe(OnInteract)

    OnCollect(Agent:agent):void=
        set CollectCount += 1

    OnInteract(Agent:agent):void=
        if(CollectCount >= 3):
            BarrierDevice.Disable()
        else:
            HUDMessageDevice.Show()