Nodes

by Sam Fereday

HTML

<button id="go">
Go
</button>

JavaScript

/// All puzzles stand on their own. In Unity again as an example they should just be droppable. Their state is global, so if you need a same sort of trap in a different place, it should have a totally new set of data for that. The prefab can obviously be the same, it's the data that must be unique. One single point of reference to multiple points of requirement. Traps are obviously fairly simple and don't care.
const puzzles = [{
  id: 1,
  name: 'Some Random Puzzle',
  solved: false,
  reward: ['itemId']
}]

// Room data / object example, in Unity this might be a physical game object with attributes. For now we're just using an id to indicate a unique puzzle.
// It's worth noting that by default, a room exit should make sure that its locally assigned puzzle id be complete. Multiple exits may need the same puzzle to complete, but that doesn't matter. As it will exist as part of the room as its own entity.
/// Excluding props and trap data for now of course, but either could be important to reaching the puzzle solution so bear that in mind.
/// Portal id may not always be set, as the exit might be a bridge to the next part of the room, or, just simple change the environment and the exit for the room might not even need a requirement.
/// In the end, exits can be in an on/off state exactly the same as puzzles. They just require each other in a sort of condition/reaction partnership. So each one will have a prefab or 'thing' to reflect the state it's in.
const squareData = {
  localPuzzles: [1],
  exitData: [
    // An example exit that may be a locked door requiring a local puzzle, and remote ones to be solved
    {
      exitId: 1,
      portalId: 2,
      locked: true,
      localPuzzlesRequired: [1],
      remoteRequired: [2, 3]
    },
    // An example exit that may just need a remote puzzle to be solved somewhere
    {
      exitId: 2,
      portalId: 3,
      locked: true,
      localPuzzlesRequired: [],
      remotePuzzlesRequired: [4]
    },
    // An...