public override void Initialize()
{
base.Initialize();
this.FadeOutImmediately();
this.AddSprite("Content/menus/menu-screen.jpg");
Sprite title = this.AddSprite("Content/credits/credits.png");
// Align with top of the center area, plus our height, plus 8-16 padding
title.Y = 160 + title.Texture.Height + 16;
const int SPACE_BETWEEN_IMAGES = 4;
const int FULL_IMAGE_SIZE = 128;
const int ACTUAL_IMAGE_SIZE = FULL_IMAGE_SIZE - 2; // 2 for border
Point TOP_LEFT_OF_IMAGE_AREA = new Point(-325 + FULL_IMAGE_SIZE / 2, 200 - FULL_IMAGE_SIZE / 2);
// Make a 5x3 grid of sprites
// See procurement plan for first 13; last two are button/titlescreen
string[] images = new string[] {
"titlescreen.jpg",
"story-1.jpg",
"story-2.jpg",
"metal-background.jpg",
"metal-under-board.jpg",
"eroded-metal.jpg",
"extruded-metal.jpg",
"metal-gate.jpg",
"stripes.jpg",
"speaker-icon.png",
"speaker-icon.png",
"speaker-icon.png",
"speaker-icon.png",
"speaker-icon.png",
"speaker-icon.png"
};
int imageIndex = 0;
foreach (string imageFileName in images)
{
TowerSprite image = new TowerSprite(this, "Content/Credits/" + imageFileName);
// Shrink to 126x126
image.RightTextureCoordinate = (ACTUAL_IMAGE_SIZE / image.Texture.Width);
image.BottomTextureCoordinate = (ACTUAL_IMAGE_SIZE / image.Texture.Height);
FlatRedBall.Math.Geometry.AxisAlignedRectangle border = this.AddAxisAlignedRectangle(ACTUAL_IMAGE_SIZE / 2, ACTUAL_IMAGE_SIZE / 2);
image.AttachTo(border, true);
// Can't move image, it's bound to border
border.X = TOP_LEFT_OF_IMAGE_AREA.X + (imageIndex % 5 * ((SPACE_BETWEEN_IMAGES + ACTUAL_IMAGE_SIZE)));
border.Y = TOP_LEFT_OF_IMAGE_AREA.Y - ((imageIndex / 5) * (SPACE_BETWEEN_IMAGES + ACTUAL_IMAGE_SIZE));
this._imageToImageIndex[image] = imageIndex;
image.OnMouseEnter += () => {
int index = this._imageToImageIndex[image];
this._infoText.DisplayText = this._captions[index];
if (index >= 9)
{
// Sound file
AudioManager.Instance.PlaySound(CoreModel.SOUND_FILE_PATH + this._soundFiles[index - 9]);
}
};
imageIndex++;
}
Sprite infoWindow = this.AddSprite("Content/Credits/credits-info-window.png");
infoWindow.Y = -219;
_infoText = new TowerText(this.AddText("Some items used with the implicit permission of their authors. Hover over items for details."));
_infoText.Y = infoWindow.Y;
Tower3SliceButton backButton = new Tower3SliceButton(this, "Back", "bubble", 18, -5);
backButton.X = 340;
backButton.Y = -275;
backButton.Click += () =>
{
this.FadeOutComplete += (fadeType) =>
{
MoveToScreen(typeof(MainMenuScreen));
};
this.FadeOut();
};
this.FadeIn();
}