-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
173 additions
and
298 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Menu { | ||
let _callback: () => void | ||
let _choiceSprite: Sprite | ||
|
||
function startGame() { | ||
scene.setBackgroundImage(assets.image`empty`) | ||
controller.player1.A.removeEventListener(ControllerButtonEvent.Pressed, startGame) | ||
_choiceSprite.destroy() | ||
|
||
_callback() | ||
} | ||
|
||
export function init() { | ||
scene.setBackgroundImage(assets.image`Splash Screen`) | ||
_choiceSprite = textsprite.create('Arrrgh Be Greedy!', 0, 15) | ||
_choiceSprite.x = 80 | ||
_choiceSprite.y = 100 | ||
|
||
controller.player1.A.addEventListener(ControllerButtonEvent.Pressed, startGame) | ||
} | ||
|
||
export function onStartGame(callback: () => void) { | ||
_callback = callback | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
namespace TreasureStats { | ||
export type TreasureStat = { | ||
onBoat?: number | ||
onIsland?: number | ||
inPocket?: number | ||
} | ||
export type OnUpdateTreasureProps = TreasureStat & { | ||
pulledFromIsland?: Map.Island['id'] | ||
} | ||
|
||
let treasureSprite: Sprite | ||
let currentDisplayCombo: Array<'island' | 'boat' | 'pocket'> = ['island'] | ||
|
||
const currentTreasure: TreasureStat = { | ||
onBoat: 0, | ||
onIsland: 0, | ||
inPocket: 0 | ||
} | ||
|
||
export function updateTreasure({ onBoat, onIsland, inPocket, pulledFromIsland }: OnUpdateTreasureProps) { | ||
if (pulledFromIsland != null) { | ||
// Find the island | ||
const island = islands.find(i => { | ||
return i.id === pulledFromIsland | ||
}) | ||
|
||
if (island) { | ||
currentTreasure.onBoat += island.riches | ||
island.riches = 0 | ||
} | ||
} else { | ||
// If not from an island we assume from the boat | ||
currentTreasure.onIsland += currentTreasure.onBoat | ||
currentTreasure.onBoat = 0 | ||
} | ||
|
||
show() | ||
} | ||
|
||
export function show(combination?: Array<'island' | 'boat' | 'pocket'>) { | ||
currentDisplayCombo = combination ? combination : currentDisplayCombo | ||
|
||
if (treasureSprite) { | ||
treasureSprite.destroy() | ||
} | ||
|
||
treasureSprite = textsprite.create(currentTreasure.onBoat + '', 1, 15) | ||
treasureSprite.x = 80 | ||
treasureSprite.y = 8 | ||
treasureSprite.z = 100 | ||
} | ||
|
||
export function hide() { | ||
if (treasureSprite) { | ||
treasureSprite.destroy() | ||
} | ||
} | ||
} |