Well this seems to work an absolute treat
Code:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission
{
public class clsMsgList //create a new class to hold the 2D list
{
public clsMsgList(string _theMessage, int _timeOnString = 5) // if _timeOnString is not present as parameter, use default value (10)
{
strMessage = _theMessage;
intTimeOnScreen = _timeOnString;
}
public string strMessage; // { get; set; } not needed here
public int intTimeOnScreen; // { get; set; } not needed here
}
//Declare stuff that is going to be used in the class
Stopwatch MissionTimer = new Stopwatch(); //Create a new timer. Uses System.Diagnostics
int intArrayMsg = 0; //This holds the current message number that will be displayed
static List<clsMsgList> lstMessageList = new List<clsMsgList>(); //Declare the new list item - new version
int intInterval = 0; // This value will be updated from the array value of lstMessageList.intTimeOnScreen
int nextTime = 2; // by default, display 1st message after 2 seconds
public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionTimer.Start(); // start the stopwatch
BuildNewMsgList(); //Run the new list builder
}
public override void OnTickGame()
{
base.OnTickGame();
if (intArrayMsg < (lstMessageList.Count - 1)) // all messages not displayed yet
{
if (MissionTimer.Elapsed.Seconds >= nextTime) //New code
{
DisplayMsgToPlayer();
}
}
}
public void DisplayMsgToPlayer()
{
nextTime = MissionTimer.Elapsed.Seconds + lstMessageList[intArrayMsg].intTimeOnScreen; // Update the time for next message
GamePlay.gpHUDLogCenter(lstMessageList[intArrayMsg].strMessage + " [OS-T:" + lstMessageList[intArrayMsg].intTimeOnScreen + "]");
intArrayMsg++; //Increment the list counter
}
static void BuildNewMsgList()
{
//Looks like a 100 characters is OK to display on screen i.e. msg 1 below
lstMessageList.Add(new clsMsgList("Good morning pilot, today you are going to have a lesson on starting and taking off in the Hurricane.", 10));
lstMessageList.Add(new clsMsgList("Are you sitting comfortably?", 5));
lstMessageList.Add(new clsMsgList("OK, lets begin.", 4));
lstMessageList.Add(new clsMsgList("So, welcome to your new 'Office'...", 6));
lstMessageList.Add(new clsMsgList("You can have half a minute to look round.", 30));
lstMessageList.Add(new clsMsgList("Right, back to work, enough gawping about!", 4));
lstMessageList.Add(new clsMsgList("Prevent an overflow in the console.")); //default time = 5 seconds (from constructor) //This message is never shown
}
}
Thanks muchly to all who have chipped in And OBT~Eazy, you have been a legend
Will go and have a look at the mission brief screen next - another day though...
Cheers
Glyn
Bookmarks