//Function for restarting level if the player dies public static void restartLevel() { Utils.MessageBox levelFailed = new Utils.MessageBox(Program.formRef.ClientSize, Program.formRef.BackgroundImage); Program.formRef.Controls.Add(levelFailed); levelFailed.BringToFront(); levelFailed.ShowMessageBox("Level Failed, Retry?", new Utils.MessageBox.DialogResultCallBack(RestartLevelCallback)); }
//Handles if the level is complete and moves to the next level public static void levelComplete() { string rankString = "Level Complete"; if (Program.levelsComplete[Program.level].medal == 0)//Will always be either 1,2,3 ir 4 if initialised { Program.levelsComplete[Program.level].movesTaken = Int32.MaxValue; Program.levelsComplete[Program.level].medal = 4; //Remove the lock symbol if this is ther first time you completed the level if (Program.level + 1 < Program.numberOfLevels) { ((Utils.nonAntialiasingPictureBox)(Program.mapRef.Controls.Find("naPicLevel" + (Program.level + 2).ToString(), true).FirstOrDefault())).Image = null; } else { ((Utils.nonAntialiasingPictureBox)(Program.mapRef.Controls.Find("naPicFinal", true).FirstOrDefault())).Image = null; } } if (moveNumber <= gold) { rankString = "Level Completed with GOLD rank"; if (Program.levelsComplete[Program.level].medal > 1) { ((Utils.nonAntialiasingPictureBox)(Program.mapRef.Controls.Find("naPicLevel" + (Program.level + 1).ToString(), true).FirstOrDefault())).Image = global::TileGamePrototype.Properties.Resources.GoldMedal; Program.levelsComplete[Program.level].medal = 1; } } else if (moveNumber <= silver) { rankString = "Level Completed with Silver rank!"; if (Program.levelsComplete[Program.level].medal > 2) { ((Utils.nonAntialiasingPictureBox)(Program.mapRef.Controls.Find("naPicLevel" + (Program.level + 1).ToString(), true).FirstOrDefault())).Image = global::TileGamePrototype.Properties.Resources.SilverMedal; Program.levelsComplete[Program.level].medal = 2; } } else if (moveNumber <= bronze) { rankString = "Level Completed with Bronze rank"; if (Program.levelsComplete[Program.level].medal > 3) { ((Utils.nonAntialiasingPictureBox)(Program.mapRef.Controls.Find("naPicLevel" + (Program.level + 1).ToString(), true).FirstOrDefault())).Image = global::TileGamePrototype.Properties.Resources.BronzeMedal; Program.levelsComplete[Program.level].medal = 3; } } if (moveNumber < Program.levelsComplete[Program.level].movesTaken)//Update best score if it was improved { Program.levelsComplete[Program.level].movesTaken = moveNumber; } Utils.MessageBox levelComplete = new Utils.MessageBox(Program.formRef.ClientSize, Program.formRef.BackgroundImage); Program.formRef.Controls.Add(levelComplete); levelComplete.BringToFront(); levelComplete.ShowMessageBox(rankString + "\n Continue to the next level", new Utils.MessageBox.DialogResultCallBack(LevelCompleteCallback)); }
//Close, unless player hasn't finished crafting private void btnExit_Click(object sender, EventArgs e) { if (itemInSlots >= 2) { Utils.MessageBox messagebox = new Utils.MessageBox(new Size(this.ClientSize.Width, this.ClientSize.Height), global::TileGamePrototype.Properties.Resources.WoodTexture); this.Controls.Add(messagebox); messagebox.ShowMessageBox("Do you wish to continue crafting your " + extractItemToCraft(toolToCraft.Name).ToString() + "?", new Utils.MessageBox.DialogResultCallBack(DialogExitCallBack)); return; } this.Close(); }
private void gameComplete(Utils.MessageBox sender, bool result) { if (!result) { levelHandler.requestPlayersBrutallyPainfulDeath();//Kill the player if they didn't like the game :-( } else //Tell the player the dev hacks if they said they liked the game :-) { for (int i = 10; i > 0; i--) { sender.ShowMessageBox("I am glad you enjoyed the game and I hope you learnt something from playing it.\nBy the way, next time you play you can click on Madagascar to unlock all the levels!\nThanks for playing!\n\nWARNING\nThis message will self destruct in " + i.ToString(), null); System.Threading.Thread.Sleep(1000); } } Environment.Exit(0); }
public override void ClickedOn(object sender, EventArgs e) { if (base.isInRange()) { if (levelHandler.player.HasItem(ItemTypes.Sword)) { Utils.MessageBox messageBox = new Utils.MessageBox(Program.formRef.ClientSize, global::TileGamePrototype.Properties.Resources.WoodTexture); Program.formRef.Controls.Add(messageBox); messageBox.BringToFront(); messageBox.ShowMessageBox("Do you wish to slay the cow?", new Utils.MessageBox.DialogResultCallBack(attack)); } else { Console.WriteLine("Requires Sword"); } } }
private void naPicFinal_Click(object sender, EventArgs e) { if (Program.levelsComplete.ToList().Contains(new LevelContainerClass.rank())) { //Tell the user they have not completed the previous levels lblTitle.Text = "Find all three relics first!"; lblTitle.Refresh(); System.Threading.Thread.Sleep(1000); lblTitle.Text = "Select the level you wish to play"; lblTitle.Refresh(); return; } int gold = 0; int silver = 0; int bronze = 0; foreach (LevelContainerClass.rank rank in Program.levelsComplete) { if (rank.medal == 1) { gold++; } else if (rank.medal == 2) { silver++; } else if (rank.medal == 3) { bronze++; } } this.KeyDown -= LevelMap_KeyDown; this.MaximumSize = Program.formRef.Size; this.MinimumSize = Program.formRef.Size; this.ClientSize = Program.formRef.ClientSize; this.Controls.Clear(); Utils.MessageBox messageBox = new Utils.MessageBox(this.ClientSize, Program.formRef.BackgroundImage); this.Controls.Add(messageBox); messageBox.ShowMessageBox("Congratulations!\nYou completed the game with :\n" + gold.ToString() + "/" + Program.numberOfLevels.ToString() + " levels at gold\n" + (gold + silver).ToString() + "/" + Program.numberOfLevels.ToString() + " levels at silver or better\n" + (gold + silver + bronze).ToString() + "/" + Program.numberOfLevels.ToString() + " levels at bronze or better\n\nDid you enjoy playing it?", new Utils.MessageBox.DialogResultCallBack(gameComplete)); }
public override void ClickedOn(object sender, EventArgs e) { if (base.isInRange()) { if (levelHandler.player.HasItem(ItemTypes.Spade)) { Utils.MessageBox messageBox = new Utils.MessageBox(Program.formRef.ClientSize, global::TileGamePrototype.Properties.Resources.WoodTexture); Program.formRef.Controls.Add(messageBox); messageBox.BringToFront(); messageBox.ShowMessageBox("Do you wish to uncover the treasure?", new Utils.MessageBox.DialogResultCallBack(uncover)); } else { Point pos = TileOperators.getGridPosition(this); levelHandler.player.MovePlayer(pos.X, pos.Y); levelHandler.player.callMove(); } } }