mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-24 17:02:50 +00:00
easter egg and signs
This commit is contained in:
parent
1a5529efb6
commit
ab59e51e24
11 changed files with 138 additions and 15 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package src;
|
||||
|
||||
import shapes.EasterEgg;
|
||||
import shapes.Sign;
|
||||
import triggers.TeleportTrigger;
|
||||
import triggers.DestinationTrigger;
|
||||
import shapes.Nuke;
|
||||
|
|
@ -600,6 +602,8 @@ class MarbleWorld extends Scheduler {
|
|||
shape = new TriangleBumper();
|
||||
else if (dataBlockLowerCase == "helicopteritem")
|
||||
shape = new Helicopter(cast element);
|
||||
else if (dataBlockLowerCase == "easteregg")
|
||||
shape = new EasterEgg(cast element);
|
||||
else if (dataBlockLowerCase == "ductfan")
|
||||
shape = new DuctFan();
|
||||
else if (dataBlockLowerCase == "smallductfan")
|
||||
|
|
@ -616,7 +620,7 @@ class MarbleWorld extends Scheduler {
|
|||
shape = new ShockAbsorber(cast element);
|
||||
else if (dataBlockLowerCase == "superspeeditem")
|
||||
shape = new SuperSpeed(cast element);
|
||||
else if (dataBlockLowerCase == "timetravelitem")
|
||||
else if (dataBlockLowerCase == "timetravelitem" || dataBlockLowerCase == "timepenaltyitem")
|
||||
shape = new TimeTravel(cast element);
|
||||
else if (dataBlockLowerCase == "tornado")
|
||||
shape = new Tornado();
|
||||
|
|
@ -624,6 +628,8 @@ class MarbleWorld extends Scheduler {
|
|||
shape = new Trapdoor();
|
||||
else if (dataBlockLowerCase == "oilslick")
|
||||
shape = new Oilslick();
|
||||
else if (dataBlockLowerCase == "arrow" || StringTools.startsWith(dataBlockLowerCase, "sign"))
|
||||
shape = new Sign(cast element);
|
||||
else {
|
||||
onFinish();
|
||||
return;
|
||||
|
|
@ -682,6 +688,8 @@ class MarbleWorld extends Scheduler {
|
|||
shape = new TriangleBumper();
|
||||
else if (dataBlockLowerCase == "helicopteritem")
|
||||
shape = new Helicopter(cast element);
|
||||
else if (dataBlockLowerCase == "easteregg")
|
||||
shape = new EasterEgg(cast element);
|
||||
else if (dataBlockLowerCase == "ductfan")
|
||||
shape = new DuctFan();
|
||||
else if (dataBlockLowerCase == "smallductfan")
|
||||
|
|
@ -698,7 +706,7 @@ class MarbleWorld extends Scheduler {
|
|||
shape = new ShockAbsorber(cast element);
|
||||
else if (dataBlockLowerCase == "superspeeditem")
|
||||
shape = new SuperSpeed(cast element);
|
||||
else if (dataBlockLowerCase == "timetravelitem")
|
||||
else if (dataBlockLowerCase == "timetravelitem" || dataBlockLowerCase == "timepenaltyitem")
|
||||
shape = new TimeTravel(cast element);
|
||||
else if (dataBlockLowerCase == "tornado")
|
||||
shape = new Tornado();
|
||||
|
|
@ -706,6 +714,8 @@ class MarbleWorld extends Scheduler {
|
|||
shape = new Trapdoor();
|
||||
else if (dataBlockLowerCase == "oilslick")
|
||||
shape = new Oilslick();
|
||||
else if (dataBlockLowerCase == "arrow" || StringTools.startsWith(dataBlockLowerCase, "sign"))
|
||||
shape = new Sign(cast element);
|
||||
else {
|
||||
onFinish();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -266,9 +266,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function getTexture(path:String) {
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
path = getProperFilepath(path);
|
||||
if (textureCache.exists(path))
|
||||
return textureCache.get(path);
|
||||
if (fileSystem.exists(path)) {
|
||||
|
|
@ -355,7 +353,7 @@ class ResourceLoader {
|
|||
var fname = Path.withoutDirectory(path).toLowerCase();
|
||||
for (file in files) {
|
||||
var fname2 = file.name;
|
||||
if (Path.withoutExtension(fname2).toLowerCase() == fname)
|
||||
if (Path.withoutExtension(fname2).toLowerCase() == fname || fname2.toLowerCase() == fname)
|
||||
names.push(file.path);
|
||||
}
|
||||
return names;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ typedef TouchSettings = {
|
|||
class Settings {
|
||||
public static var highScores:Map<String, Array<Score>> = [];
|
||||
|
||||
public static var easterEggs:Map<String, Float> = [];
|
||||
|
||||
public static var optionsSettings:OptionsSettings = {
|
||||
screenWidth: 1280,
|
||||
screenHeight: 720,
|
||||
|
|
@ -153,14 +155,23 @@ class Settings {
|
|||
highscoreName: highscoreName
|
||||
};
|
||||
var scoreCount = 0;
|
||||
var eggCount = 0;
|
||||
for (key => value in highScores) {
|
||||
scoreCount++;
|
||||
}
|
||||
for (key => value in easterEggs) {
|
||||
eggCount++;
|
||||
}
|
||||
#if hl
|
||||
if (scoreCount != 0)
|
||||
outputData.highScores = highScores;
|
||||
else
|
||||
outputData.highScores = {};
|
||||
if (eggCount != 0) {
|
||||
outputData.easterEggs = easterEggs;
|
||||
} else {
|
||||
outputData.easterEggs = {};
|
||||
}
|
||||
#end
|
||||
#if js
|
||||
var kvps:Array<Dynamic> = [];
|
||||
|
|
@ -168,6 +179,11 @@ class Settings {
|
|||
kvps.push([key, value]);
|
||||
var jobj = js.lib.Object.fromEntries(kvps);
|
||||
outputData.highScores = jobj;
|
||||
kvps = [];
|
||||
for (key => value in easterEggs)
|
||||
kvps.push([key, value]);
|
||||
jobj = js.lib.Object.fromEntries(kvps);
|
||||
outputData.easterEggs = jobj;
|
||||
#end
|
||||
var json = Json.stringify(outputData);
|
||||
#if (hl && !android)
|
||||
|
|
@ -204,6 +220,12 @@ class Settings {
|
|||
for (key => value in highScoreData) {
|
||||
highScores.set(key, value);
|
||||
}
|
||||
var easterEggData:DynamicAccess<Float> = json.easterEggs;
|
||||
if (easterEggData != null) {
|
||||
for (key => value in easterEggData) {
|
||||
easterEggs.set(key, value);
|
||||
}
|
||||
}
|
||||
optionsSettings = json.options;
|
||||
if (optionsSettings.fov == 0 #if js || optionsSettings.fov == null #end)
|
||||
optionsSettings.fov = 60;
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ class MissionElementItem extends MissionElementBase {
|
|||
var rotate:String;
|
||||
var showhelponpickup:String;
|
||||
var timebonus:Null<String>;
|
||||
var timepenalty:Null<String>;
|
||||
|
||||
public function new() {
|
||||
_type = MissionElementType.Item;
|
||||
|
|
|
|||
44
src/shapes/EasterEgg.hx
Normal file
44
src/shapes/EasterEgg.hx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package shapes;
|
||||
|
||||
import src.Settings;
|
||||
import mis.MissionElement.MissionElementItem;
|
||||
import src.ResourceLoader;
|
||||
|
||||
class EasterEgg extends PowerUp {
|
||||
public function new(element:MissionElementItem) {
|
||||
super(element);
|
||||
this.dtsPath = "data/shapes/items/easteregg.dts";
|
||||
this.isCollideable = false;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "EasterEgg";
|
||||
this.pickUpName = "Easter Egg";
|
||||
this.autoUse = true;
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
var found:Bool = false;
|
||||
if (Settings.easterEggs.exists(this.level.mission.path)) {
|
||||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
Settings.easterEggs.set(this.level.mission.path, this.level.timeState.currentAttemptTime);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/easter.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
this.customPickupMessage = "You found an Easter Egg!";
|
||||
} else {
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/easterfound.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
this.customPickupMessage = "You already found this Easter Egg.";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override function init(level:src.MarbleWorld, onFinish:() -> Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/easter.wav").entry.load(() -> {
|
||||
ResourceLoader.load("data/sound/easterfound.wav").entry.load(onFinish);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function use(timeState:src.TimeState) {}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ class Magnet extends ForceObject {
|
|||
this.isCollideable = true;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "Magnet";
|
||||
this.useInstancing = true;
|
||||
this.forceDatas = [
|
||||
{
|
||||
forceType: ForceCone,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ abstract class PowerUp extends DtsObject {
|
|||
public var element:MissionElementItem;
|
||||
public var pickupSound:Sound;
|
||||
|
||||
var customPickupMessage:String = null;
|
||||
|
||||
public function new(element:MissionElementItem) {
|
||||
super();
|
||||
this.isCollideable = false;
|
||||
|
|
@ -54,7 +56,10 @@ abstract class PowerUp extends DtsObject {
|
|||
if (this.autoUse)
|
||||
this.use(timeState);
|
||||
|
||||
this.level.displayAlert('You picked up a ${this.pickUpName}!');
|
||||
if (customPickupMessage != null)
|
||||
this.level.displayAlert(customPickupMessage);
|
||||
else
|
||||
this.level.displayAlert('You picked up a ${this.pickUpName}!');
|
||||
if (this.element.showhelponpickup == "1" && !this.autoUse)
|
||||
this.level.displayHelp('Press <func:bind mousefire> to use the ${this.pickUpName}!');
|
||||
|
||||
|
|
|
|||
37
src/shapes/Sign.hx
Normal file
37
src/shapes/Sign.hx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package shapes;
|
||||
|
||||
import hxd.Direction;
|
||||
import mis.MissionElement.MissionElementStaticShape;
|
||||
import src.DtsObject;
|
||||
|
||||
class Sign extends DtsObject {
|
||||
public function new(element:MissionElementStaticShape) {
|
||||
super();
|
||||
this.dtsPath = "data/shapes/signs/sign.dts";
|
||||
this.isCollideable = true;
|
||||
this.useInstancing = true;
|
||||
|
||||
var d = "";
|
||||
if (element.datablock.toLowerCase() != 'arrow') {
|
||||
// Determine the direction to show
|
||||
var direction = element.datablock.substring("Sign".length).toLowerCase();
|
||||
switch (direction) {
|
||||
case "":
|
||||
this.dtsPath = "data/shapes/signs/sign.dts";
|
||||
case "down":
|
||||
this.dtsPath = "data/shapes/signs/signdown.dts";
|
||||
case "up":
|
||||
this.dtsPath = "data/shapes/signs/signup.dts";
|
||||
case "side":
|
||||
this.dtsPath = "data/shapes/signs/signside.dts";
|
||||
case "downside":
|
||||
this.dtsPath = "data/shapes/signs/signdown-side.dts";
|
||||
case "upside":
|
||||
this.dtsPath = "data/shapes/signs/signup-side.dts";
|
||||
}
|
||||
d = direction;
|
||||
}
|
||||
|
||||
this.identifier = "Sign" + d;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,12 +8,13 @@ class SignCaution extends DtsObject {
|
|||
super();
|
||||
this.dtsPath = "data/shapes/signs/cautionsign.dts";
|
||||
this.isCollideable = true;
|
||||
this.useInstancing = true;
|
||||
|
||||
var type = element.datablock.substring("SignCaution".length);
|
||||
var type = element.datablock.substring("SignCaution".length).toLowerCase();
|
||||
switch (type) {
|
||||
case "Caution":
|
||||
case "caution":
|
||||
this.matNameOverride.set("base.cautionsign", "caution.cautionsign");
|
||||
case "Danger":
|
||||
case "danger":
|
||||
this.matNameOverride.set("base.cautionsign", "danger.cautionsign");
|
||||
}
|
||||
this.identifier = "CautionSign" + type;
|
||||
|
|
|
|||
|
|
@ -9,17 +9,18 @@ class SignPlain extends DtsObject {
|
|||
|
||||
this.dtsPath = "data/shapes/signs/plainsign.dts";
|
||||
this.isCollideable = true;
|
||||
this.useInstancing = true;
|
||||
|
||||
// Determine the direction to show
|
||||
var direction = element.datablock.substring("SignPlain".length);
|
||||
var direction = element.datablock.substring("SignPlain".length).toLowerCase();
|
||||
switch (direction) {
|
||||
case "Right":
|
||||
case "right":
|
||||
this.matNameOverride.set("base.plainsign", "right.plainsign");
|
||||
case "Left":
|
||||
case "left":
|
||||
this.matNameOverride.set("base.plainsign", "left.plainsign");
|
||||
case "Up":
|
||||
case "up":
|
||||
this.matNameOverride.set("base.plainsign", "up.plainsign");
|
||||
case "Down":
|
||||
case "down":
|
||||
this.matNameOverride.set("base.plainsign", "down.plainsign");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ class TimeTravel extends PowerUp {
|
|||
if (element.timebonus != null) {
|
||||
this.timeBonus = MisParser.parseNumber(element.timebonus) / 1000;
|
||||
}
|
||||
if (element.timepenalty != null) {
|
||||
this.timeBonus = -MisParser.parseNumber(element.timepenalty) / 1000;
|
||||
}
|
||||
|
||||
this.pickUpName = '${this.timeBonus} second Time ${this.timeBonus >= 0 ? 'Modifier' : 'Penalty'}';
|
||||
this.cooldownDuration = 1e8;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue