mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-02-15 02:36:01 +00:00
easter egg achievement and pmg
This commit is contained in:
parent
632f7fd732
commit
f1e4b44ce1
5 changed files with 82 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package src;
|
||||
|
||||
import haxe.Json;
|
||||
import mis.MissionElement.MissionElementItem;
|
||||
import haxe.io.BytesBuffer;
|
||||
import h2d.Tile;
|
||||
import hxd.BitmapData;
|
||||
|
|
@ -28,8 +30,8 @@ class Mission {
|
|||
public var difficultyIndex:Int;
|
||||
public var id:Int;
|
||||
public var isClaMission:Bool;
|
||||
|
||||
public var game:String;
|
||||
public var hasEgg:Bool;
|
||||
|
||||
var next:Mission;
|
||||
|
||||
|
|
@ -45,6 +47,24 @@ class Mission {
|
|||
var misParser = new MisParser(ResourceLoader.fileSystem.get(this.path).getText());
|
||||
var contents = misParser.parse();
|
||||
root = contents.root;
|
||||
|
||||
function scanMission(simGroup:MissionElementSimGroup) {
|
||||
for (element in simGroup.elements) {
|
||||
if (this.hasEgg)
|
||||
break;
|
||||
if ([MissionElementType.Item].contains(element._type)) {
|
||||
if (element._type == MissionElementType.Item) {
|
||||
var so:MissionElementItem = cast element;
|
||||
if (so.datablock.toLowerCase() == 'easteregg')
|
||||
this.hasEgg = true;
|
||||
}
|
||||
} else if (element._type == MissionElementType.SimGroup && !this.hasEgg) {
|
||||
scanMission(cast element);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
scanMission(root); // Scan for egg
|
||||
}
|
||||
|
||||
public function dispose() {
|
||||
|
|
@ -76,6 +96,35 @@ class Mission {
|
|||
return mission;
|
||||
}
|
||||
|
||||
public function toJSON() {
|
||||
return Json.stringify({
|
||||
artist: this.artist,
|
||||
description: this.description,
|
||||
goldTime: this.goldTime,
|
||||
ultimateTime: this.ultimateTime,
|
||||
qualifyTime: this.qualifyTime,
|
||||
hasEgg: this.hasEgg,
|
||||
title: this.title,
|
||||
type: this.type,
|
||||
path: this.path,
|
||||
});
|
||||
}
|
||||
|
||||
public static function fromJSON(jsonData:String) {
|
||||
var jdata = Json.parse(jsonData);
|
||||
var mission = new Mission();
|
||||
mission.artist = jdata.artist;
|
||||
mission.description = jdata.description;
|
||||
mission.goldTime = jdata.goldTime;
|
||||
mission.ultimateTime = jdata.ultimateTime;
|
||||
mission.qualifyTime = jdata.qualifyTime;
|
||||
mission.hasEgg = jdata.hasEgg;
|
||||
mission.title = jdata.title;
|
||||
mission.type = jdata.type;
|
||||
mission.path = jdata.path;
|
||||
return mission;
|
||||
}
|
||||
|
||||
public function getNextMission() {
|
||||
return this.next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ class MissionList {
|
|||
var mInfo = misParser.parseMissionInfo();
|
||||
var mission = Mission.fromMissionInfo(file.path, mInfo);
|
||||
mission.game = game;
|
||||
// do egg thing
|
||||
if (StringTools.contains(file.getText().toLowerCase(), 'datablock = "easteregg"')) { // Ew
|
||||
mission.hasEgg = true;
|
||||
}
|
||||
missions.set(file.path, mission);
|
||||
difficultyMissions.push(mission);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class AchievementsGui extends GuiImage {
|
|||
|
||||
var totalPlatinums = 0;
|
||||
var totalUltimates = 0;
|
||||
var totalEggs = 0;
|
||||
|
||||
for (difficulty => missions in MissionList.missionList["platinum"]) {
|
||||
completions.set(difficulty, missions.map(mis -> {
|
||||
|
|
@ -144,6 +145,13 @@ class AchievementsGui extends GuiImage {
|
|||
var beatPlatinum = bestTime.time < mis.goldTime;
|
||||
var beatUltimate = bestTime.time < mis.ultimateTime;
|
||||
var beaten = beatPar || beatPlatinum || beatUltimate;
|
||||
|
||||
if (beatPlatinum)
|
||||
totalPlatinums++;
|
||||
if (beatUltimate)
|
||||
totalUltimates++;
|
||||
if (Settings.easterEggs.exists(mis.path))
|
||||
totalEggs++;
|
||||
return {
|
||||
mission: mis,
|
||||
beatPar: beatPar,
|
||||
|
|
@ -160,6 +168,8 @@ class AchievementsGui extends GuiImage {
|
|||
var expertFinishAchiev = completions["expert"].filter(x -> !x.beatPar).length == 0;
|
||||
var beatPlatinumAchiev = totalPlatinums == 120;
|
||||
var beatUltimateAchiev = totalUltimates == 120;
|
||||
var easterEggAny = totalEggs != 0;
|
||||
var easterEggAll = totalEggs == 96;
|
||||
|
||||
if (beginnerFinishAchiev)
|
||||
bmp1.bmp.tile = ResourceLoader.getResource("data/ui/achiev/n1.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
|
|
@ -173,5 +183,9 @@ class AchievementsGui extends GuiImage {
|
|||
bmp5.bmp.tile = ResourceLoader.getResource("data/ui/achiev/n6.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
if (beatUltimateAchiev)
|
||||
bmp6.bmp.tile = ResourceLoader.getResource("data/ui/achiev/n5.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
if (easterEggAny)
|
||||
bmp7.bmp.tile = ResourceLoader.getResource("data/ui/achiev/1.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
if (easterEggAll)
|
||||
bmp8.bmp.tile = ResourceLoader.getResource("data/ui/achiev/2.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -573,7 +573,7 @@ class PlayGui {
|
|||
this.powerupImageScene.setElapsedTime(timeState.dt);
|
||||
|
||||
if (this.fpsMeter != null) {
|
||||
this.fpsMeter.text.text = '${cast (ProfilerUI.instance.fps, Int)} fps';
|
||||
this.fpsMeter.text.text = '${Math.floor(ProfilerUI.instance.fps)} fps';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -779,6 +779,19 @@ class PlayMissionGui extends GuiImage {
|
|||
} else
|
||||
pmNext.disabled = false;
|
||||
|
||||
if (pmPreview.children.contains(pmEgg))
|
||||
pmPreview.removeChild(pmEgg);
|
||||
if (currentMission.hasEgg) {
|
||||
if (Settings.easterEggs.exists(currentMission.path)) {
|
||||
pmEgg.bmp.tile = ResourceLoader.getResource('data/ui/play/eggfound.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
} else {
|
||||
pmEgg.bmp.tile = ResourceLoader.getResource('data/ui/play/eggnotfound.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
}
|
||||
|
||||
pmPreview.addChild(pmEgg);
|
||||
pmEgg.render(MarbleGame.canvas.scene2d);
|
||||
}
|
||||
|
||||
// if (currentCategory != "custom"
|
||||
// && Settings.progression[["beginner", "intermediate", "advanced", "expert"].indexOf(currentCategory)] < currentSelection) {
|
||||
// noQualText.text.visible = true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue