habit game choose next puzzle pack
This commit is contained in:
@@ -29,6 +29,7 @@ import HabitModel;
|
|||||||
import sys.FileSystem;
|
import sys.FileSystem;
|
||||||
import hx.strings.Strings;
|
import hx.strings.Strings;
|
||||||
import datetime.DateTime;
|
import datetime.DateTime;
|
||||||
|
import flixel.ui.FlxButton;
|
||||||
using kiss_flixel.CameraTools;
|
using kiss_flixel.CameraTools;
|
||||||
using kiss_flixel.GroupTools;
|
using kiss_flixel.GroupTools;
|
||||||
import haxe.ds.Option;
|
import haxe.ds.Option;
|
||||||
|
@@ -148,7 +148,8 @@
|
|||||||
(set shortcutHandler (new FlxKeyShortcutHandler))
|
(set shortcutHandler (new FlxKeyShortcutHandler))
|
||||||
|
|
||||||
(let [p (m.totalPoints)
|
(let [p (m.totalPoints)
|
||||||
&mut i 0 ]
|
&mut i 0
|
||||||
|
&mut puzzleUnlocked -1]
|
||||||
// Find, load, and add the current reward image as big as possible:
|
// Find, load, and add the current reward image as big as possible:
|
||||||
(unless currentRewardFile
|
(unless currentRewardFile
|
||||||
(set currentRewardFile (nth m.rewardFiles 0))
|
(set currentRewardFile (nth m.rewardFiles 0))
|
||||||
@@ -159,14 +160,9 @@
|
|||||||
(when (>= ++i m.rewardFiles.length)
|
(when (>= ++i m.rewardFiles.length)
|
||||||
(let [lastStartingPoints .startingPoints (nth m.rewardFiles --i)
|
(let [lastStartingPoints .startingPoints (nth m.rewardFiles --i)
|
||||||
nextStartingPoints (+ lastStartingPoints TOTAL_PIECES)]
|
nextStartingPoints (+ lastStartingPoints TOTAL_PIECES)]
|
||||||
(if (> p nextStartingPoints)
|
(when (> p nextStartingPoints)
|
||||||
{
|
(set puzzleUnlocked nextStartingPoints))
|
||||||
// TODO give the player a puzzle pack choice using (availablePacks)
|
(break)))))
|
||||||
(m.addRewardFile .path (firstUnsolvedPuzzle m "puzzles/trentnelson") nextStartingPoints)
|
|
||||||
(setModel m)
|
|
||||||
(return)
|
|
||||||
}
|
|
||||||
(break))))))
|
|
||||||
|
|
||||||
(set save (new FlxSave))
|
(set save (new FlxSave))
|
||||||
(save.bind currentRewardFile.path)
|
(save.bind currentRewardFile.path)
|
||||||
@@ -321,7 +317,10 @@
|
|||||||
(map (m.activeTodoEntries) makeText)
|
(map (m.activeTodoEntries) makeText)
|
||||||
(set _color FlxColor.GRAY)
|
(set _color FlxColor.GRAY)
|
||||||
(_makeText "[SPACE] Cycle background color" 0)
|
(_makeText "[SPACE] Cycle background color" 0)
|
||||||
(add entryTexts))
|
(add entryTexts)
|
||||||
|
|
||||||
|
(when !(= puzzleUnlocked -1)
|
||||||
|
(startPuzzlePackChoice puzzleUnlocked)))
|
||||||
|
|
||||||
(doFor e (m.allEntries)
|
(doFor e (m.allEntries)
|
||||||
(when (HabitModel.isActive e)
|
(when (HabitModel.isActive e)
|
||||||
@@ -474,3 +473,29 @@
|
|||||||
(collected.push piece)
|
(collected.push piece)
|
||||||
(recursivelyConnectedPieces piece collected))))
|
(recursivelyConnectedPieces piece collected))))
|
||||||
collected)
|
collected)
|
||||||
|
|
||||||
|
(prop &mut :FlxGroup nextPuzzleChoiceGroup null)
|
||||||
|
|
||||||
|
(method startPuzzlePackChoice [nextStartingPoints]
|
||||||
|
(unless nextPuzzleChoiceGroup
|
||||||
|
(set nextPuzzleChoiceGroup (new FlxGroup))
|
||||||
|
(set nextPuzzleChoiceGroup.cameras [uiCamera])
|
||||||
|
|
||||||
|
// TODO position these aesthetically with a partly transparent background behind them
|
||||||
|
// like the habit ui window should also have
|
||||||
|
(let [x 0 &mut y 0]
|
||||||
|
(doFor pack (availablePacks model)
|
||||||
|
(let [text (new FlxText x y 0 "$(haxe.io.Path.withoutDirectory pack.path): ${pack.puzzlesDone}/${pack.puzzlesTotal}" textSize)]
|
||||||
|
// TODO not that color though
|
||||||
|
(set text.color FlxColor.LIME)
|
||||||
|
(nextPuzzleChoiceGroup.add text)
|
||||||
|
(whenLet [(Some np) pack.nextPuzzle]
|
||||||
|
(nextPuzzleChoiceGroup.add (new FlxButton (+ x text.width) y "CHOOSE" ->:Void {
|
||||||
|
(remove nextPuzzleChoiceGroup)
|
||||||
|
(set nextPuzzleChoiceGroup null)
|
||||||
|
(model.addRewardFile np.path nextStartingPoints)
|
||||||
|
(setModel model)
|
||||||
|
|
||||||
|
}))))
|
||||||
|
(+= y textSize)))
|
||||||
|
(add nextPuzzleChoiceGroup)))
|
||||||
|
Reference in New Issue
Block a user