using System;
using System.Collections;
using System.Collections.Specialized;
using System.Drawing;
using Global;
using Global.GlobalClass;
namespace KillerInstinct{
public class MessageClass
{
private enum MessageStates
{
NotDisplaying,
PoppingUp,
Displaying,
PoppingDown
}
// current state of pop-up box
private MessageStates m_messageState = MessageStates.NotDisplaying;
private MapClass.MissionTypes m_mission;
private StringCollection m_messageText = new StringCollection();
private int m_width = 150;
private int m_height = 50;
private int m_posX;
private int m_posY;
//
public MessageClass()
{
m_posX = global.options.SCR_WIDTH - m_width;
m_posY = global.options.SCR_HEIGHT;
}
// pop's new message onto screen (add)
public void Popup(MapClass.MissionTypes mission)
{
m_mission = mission;
// if a message is already popped-up, pop-down
if (m_messageState == MessageStates.Displaying)
m_messageState = MessageStates.PoppingDown;
else
m_messageState = MessageStates.PoppingUp;
}
private void FillMessageText()
{
// clear any old messages
m_messageText.Clear();
if (m_mission == MapClass.MissionTypes.KillAll)
{
m_messageText.Add("Kill All Enemies!");
}
// show mission counter (energy, score limit, time limit)
else if (m_mission == MapClass.MissionTypes.TimeLimit)
{
m_messageText.Add("Countdown: " + (global.options.TimeLimit-(System.Environment.TickCount-global.options.GameStartTime)/1000));
}
// display how many things left to destroy
else if (m_mission == MapClass.MissionTypes.Destroy)
{
m_messageText.Add("Countdown: " + (global.Map.DestroyTimeLimit-(System.Environment.TickCount-global.options.GameStartTime)/1000));
m_messageText.Add("Mines to Destroy: " + global.Map.ObjectsLeftToDestroy);
}
// display which exits are available
else if (m_mission == MapClass.MissionTypes.UseExit)
{
m_messageText.Add("Go" + global.Map.GetCurrentExits());
}
}
public void Draw()
{
if (m_messageState != MessageStates.NotDisplaying)
{
switch (m_messageState)
{
case MessageStates.PoppingUp:
m_posY--;
if (m_posY < global.options.SCR_HEIGHT-m_height)
m_messageState = MessageStates.Displaying;
break;
case MessageStates.Displaying:
// update message text to be displayed
FillMessageText();
break;
case MessageStates.PoppingDown:
m_posY++;
if (m_posY > global.options.SCR_HEIGHT)
{
m_messageState = MessageStates.PoppingUp;
// update message text to be displayed
FillMessageText();
}
break;
}
// only draw what can be drawn
int newHeight = global.options.SCR_HEIGHT - m_posY;
if (newHeight > 0)
{
// draw black box where information is written
global.DC.DrawBox(m_posX, m_posY, m_width, newHeight, Color.Black, Color.Transparent);
for (int i=0; i<m_messageText.Count; ++i)
{
global.DC.DrawText(m_posX+10, m_posY+(12*(i+1)), m_messageText[i], Color.Firebrick);
}
}
}
}
}
}
|