public override void Activity(bool firstTimeCalled)
{
base.Activity(firstTimeCalled);
removeDeadSprites();
removeDeadText();
undoColourOperationsOnFadedInTiles();
if (model.GameState == CoreModel.GameStates.GameOver)
{
if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
{
this.FadeOutComplete += new FadeEventDelegate(CoreGameScreen_MoveToMainMenuFadeOutComplete);
this.FadeOut();
}
}
else if (model.GameState == CoreModel.GameStates.GameComplete)
{
if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
{
this.FadeOut();
}
}
else
{
if (this._tutorialPanelShowing == false)
{
Tile t = findTileMouseIsOver();
if (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton))
{
// Left mouse button pushed - down this frame, not down last frame.
if (t != null && t.IsEmpty())
{
t.Atom = model.NextAtom;
model.PickNextAtom();
this.drawTile(t);
AudioManager.Instance.PlaySound(CoreModel.SOUND_FILE_PATH + "atom-placed.mp3");
this.drawNextAtom();
this.updateAtomsLeftOrPointsCounter();
BackgroundWorker reactionComputingThread = new BackgroundWorker();
reactionComputingThread.DoWork += new DoWorkEventHandler(reactionComputingThread_DoWork);
reactionComputingThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(reactionComputingThread_RunWorkerCompleted);
reactionComputingThread.RunWorkerAsync(t);
}
}
else
{
if (t != null && !t.IsEmpty())
{
if (this._startHoverTime == DateTime.MinValue)
{
this._startHoverTime = DateTime.Now;
}
else
{
TimeSpan time = (DateTime.Now - this._startHoverTime);
if (time.TotalMilliseconds >= 500)
{
infoPanel.Show(t.Atom);
}
}
}
else if (InputManager.Mouse.IsOn3D(this._nextAtom, false))
{
infoPanel.Show(model.NextAtom);
}
else
{
infoPanel.Hide();
this._startHoverTime = DateTime.MinValue;
}
}
if (model.IsLevelOver())
{
if (model.CurrentLevel != CoreModel.AVALANCHE_LEVEL && model.CurrentLevel != CoreModel.TRICKLE_LEVEL)
{
this.FadeOutHalf();
}
else
{
// Show random "good work" message, and add 1000 points
string message = this._greatWorkMessages[model.RandomGenerator.Next() % this._greatWorkMessages.Length] + " (+1000 points)";
model.Points += 1000;
this.updateAtomsLeftOrPointsCounter();
AudioManager.Instance.PlaySound(CoreModel.SOUND_FILE_PATH + "ulimited-mode-atoms-cleared.mp3");
TowerText messageText = new TowerText(this.AddText(message));
messageText.YVelocity = 15;
messageText.AlphaRate = -0.05f;
messageText.Scale = 48;
messageText.AddShadow();
messageText.Colour(255, 225, 64);
this._reactionText.Add(messageText.BaseText);
this._reactionText.Add(messageText.EffectText);
// Generate 40 tiles on the board.
int numGenerated = 0;
while (numGenerated < 40)
{
IList<Tile> tiles = model.SpewOutAtomsFromMachine();
numGenerated += tiles.Count;
foreach (Tile tile in tiles)
{
drawTile(tile);
fadeTileIn(tile);
}
}
}
}
}
}
}