//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)); }
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"); } } }
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(); } } }