Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them has been replaced with a symlink. Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still be present.
187 lines
6.1 KiB
JavaScript
187 lines
6.1 KiB
JavaScript
// Creates MissionControl panel with mission information before gameplay
|
|
// Manages mission pre-brief and de-brief.
|
|
|
|
Script.include(["pd_utils.js", "pd_hudPanel.js", "pd_missions.js"]);
|
|
|
|
MissionControl = function()
|
|
{
|
|
this.MissionStates = {
|
|
BRIEF: 0,
|
|
DEBRIEF: 1,
|
|
};
|
|
|
|
this._missionState = this.MissionStates.BRIEF;
|
|
this.txt_missionCompleteUrl = pd_path("images/missionComplete.png");
|
|
this.isFinished = false; // True when all text shown to player
|
|
this.panel = this.createMissionPanel();
|
|
this.missionList = this.initializeMissions();
|
|
this.currentMission = null;
|
|
this._textIndex = 0; // Keeps track of which line of text is currently being presented
|
|
this._presenting = false;
|
|
this._missionIndex = -1; // Tracks which mission the player is on currently
|
|
this._timerOn = false; // Used for timing stuff
|
|
this._missionDelay = 0; // Time until mission is debriefed
|
|
this._timeStamp = null; // General timer marker
|
|
this._txt_missionComplete = this.createMissionCompleteText(); // Text image to show at mission complete
|
|
}
|
|
|
|
// Checks current mission needs against scan record
|
|
// Note: scanHistory is a dictionary with key = etd type, value = ScannedTarget object (see Scanner)
|
|
MissionControl.prototype.checkMissionProgress = function(scanHistory)
|
|
{
|
|
var playerScans = Object.keys(scanHistory);
|
|
|
|
// Test current mission here...
|
|
switch (this.currentMission.type)
|
|
{
|
|
case pd_MissionTypes.COUNT_ANY:
|
|
//printDebug("MissionControl.COUNT_ANY: " + this.currentMission.targetCount);
|
|
if (playerScans.length >= this.currentMission.targetCount)
|
|
{
|
|
printDebug("MissionControl.checkMissionProgress,Target count complete!");
|
|
// TODO: Mission success
|
|
return true;
|
|
|
|
}
|
|
break;
|
|
|
|
case pd_MissionTypes.SAMPLE_TARGET:
|
|
if (this.currentMission.targetEtd in scanHistory)
|
|
{
|
|
var numScans = scanHistory[this.currentMission.targetEtd].entityIds.length;
|
|
if (numScans >= this.currentMission.targetCount)
|
|
{
|
|
printDebug("MissionControl.checkMissionProgress, Mission " + this.currentMission.name + ", Complete!");
|
|
// TODO: Mission Success
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Shows panel for next mission, starts display
|
|
MissionControl.prototype.startNextMission = function()
|
|
{
|
|
this._missionIndex++;
|
|
this.currentMission = this.missionList[this._missionIndex];
|
|
printDebug("MissionControl.startNextMission, ");
|
|
this.startBrief();
|
|
}
|
|
|
|
// Introduce mission to player
|
|
MissionControl.prototype.startBrief = function()
|
|
{
|
|
this._missionState = this.MissionStates.BRIEF;
|
|
this.isFinished = false;
|
|
this._textIndex = 0;
|
|
this.panel.setStaticText("lbl_mission", "MISSION: " + this.currentMission.name);
|
|
this.panel.setDisplayText("mainText", this.currentMission.introText[this._textIndex]);
|
|
this.panel.show();
|
|
this._presenting = true;
|
|
this.panel.startAnimation();
|
|
}
|
|
|
|
// Show mission success text at end
|
|
MissionControl.prototype.startDebrief = function()
|
|
{
|
|
var _this = this;
|
|
this._missionState = this.MissionStates.DEBRIEF;
|
|
this.isFinished = false;
|
|
overlay_show(this._txt_missionComplete, true);
|
|
this._textIndex = 0;
|
|
this.panel.setStaticText("lbl_mission", "MISSION: " + this.currentMission.name);
|
|
this.panel.setDisplayText("mainText", this.currentMission.successText[this._textIndex]);
|
|
|
|
//overlay_show(this._txt_missionComplete);
|
|
Script.setTimeout( function() {
|
|
overlay_show(_this._txt_missionComplete, false);
|
|
_this.panel.show();
|
|
_this._presenting = true;
|
|
_this.panel.startAnimation();
|
|
}, 2000 );
|
|
}
|
|
|
|
// Defines order and existence of missions via unique mission structures.
|
|
// Missions MUST appear here or they won't be in the game.
|
|
MissionControl.prototype.initializeMissions = function()
|
|
{
|
|
// NOTE: These missions must match those in pd_missions.js
|
|
var missionList = [];
|
|
missionList.push( mis_layOfTheLand );
|
|
missionList.push( mis_drekHunt );
|
|
missionList.push( mis_riverWater );
|
|
missionList.push( mis_abandonedMine );
|
|
return missionList;
|
|
}
|
|
|
|
// Creates final "Mission Complete" image text
|
|
MissionControl.prototype.createMissionCompleteText = function()
|
|
{
|
|
var imageAspectRatio = 1200/103;
|
|
var imageWidth = Window.innerWidth * 0.75;
|
|
var imageHeight = imageWidth/imageAspectRatio;
|
|
var xPos = (Window.innerWidth - imageWidth)/2;
|
|
var imageOverlay = createImageOverlay(this.txt_missionCompleteUrl, {x:xPos, y:0.7*Window.innerHeight/2, z:0}, false, imageWidth, imageHeight );
|
|
return imageOverlay;
|
|
}
|
|
|
|
// Initializes panel and text elements
|
|
MissionControl.prototype.createMissionPanel = function()
|
|
{
|
|
var frameUrl = pd_path("images/missionFrame.png");
|
|
var hudPanel = new HudPanel({x:Window.innerWidth/2 - 150, y:130}, {x:300, y:420}, {x:10,y:0});
|
|
var titleColor = {red:255, green:255, blue:255};
|
|
var spacebarColor = {red:255, green:40, blue:40};
|
|
var textColor = {red:40, green:200, blue:40 };
|
|
|
|
hudPanel.addRectangle("bgRectangle", {x:0, y:0}, hudPanel.size.x, hudPanel.size.y, {red:20, green:20, blue:20} );
|
|
hudPanel.addImageFrame("frame", {x:-23, y:-21}, hudPanel.size.x + 47, hudPanel.size.y + 43, frameUrl );
|
|
hudPanel.addStaticText("lbl_mission", "MISSION BRIEFING", {x:0, y:0}, hudPanel.size.x, titleColor );
|
|
hudPanel.addDynamicText("mainText", "", {x:0, y:30}, hudPanel.size.x, textColor );
|
|
hudPanel.addDynamicText("spaceToContinue", "[ Press Spacebar To Continue ]", {x:35, y:hudPanel.size.y - 30}, hudPanel.size.x, spacebarColor );
|
|
|
|
hudPanel.hide();
|
|
return hudPanel;
|
|
}
|
|
|
|
MissionControl.prototype.onKeyPress = function(event)
|
|
{
|
|
if (event.key == SPACEBAR_CHARCODE)
|
|
{
|
|
this._textIndex++;
|
|
|
|
var playingText;
|
|
if (this._missionState == this.MissionStates.BRIEF)
|
|
playingText = this.currentMission.introText;
|
|
else
|
|
playingText = this.currentMission.successText;
|
|
|
|
if (playingText.length > this._textIndex)
|
|
{
|
|
this.panel.setDisplayText("mainText", playingText[this._textIndex]);
|
|
this.panel.startAnimation();
|
|
}
|
|
else
|
|
{
|
|
this.isFinished = true;
|
|
this.panel.hide();
|
|
}
|
|
}
|
|
}
|
|
|
|
// This function must be wired to the appropriate callback via parent objects
|
|
MissionControl.prototype.scriptUpdate = function(deltaTime)
|
|
{
|
|
//printDebug("MissionControl.scriptUpdate");
|
|
this.panel.scriptUpdate(deltaTime);
|
|
}
|
|
|
|
MissionControl.prototype.deconstruct = function()
|
|
{
|
|
this.panel.deconstruct();
|
|
}
|
|
|