コード例 #1
0
 private void uncover(Utils.MessageBox sender, bool result)
 {
     if (result && levelHandler.player.HasItem(ItemTypes.Spade))
     {
         levelHandler.player.RemoveItem(ItemTypes.Spade);
         if (base.baseType == TileTypes.Grass)
         {
             TileOperators.changeTileAtLocation(this, TileTypes.Chest, Zone.Surface);
         }
         else if (base.baseType == TileTypes.Stone)
         {
             TileOperators.changeTileAtLocation(this, TileTypes.Chest, Zone.Cave);
         }
         levelHandler.player.callMove();
     }
     else if (base.isInRange())//Player could theoretically move before pressing no
     {
         Point pos = TileOperators.getGridPosition(this);
         levelHandler.player.MovePlayer(pos.X, pos.Y);
         levelHandler.player.callMove();
     }
     sender.Hide();
     Program.formRef.Controls.Remove(sender);
     sender.Controls.Clear();
     sender.Dispose();
 }
コード例 #2
0
 //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));
 }
コード例 #3
0
        //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));
        }
コード例 #4
0
ファイル: CraftingWindow.cs プロジェクト: djns99/RelicHunter
 //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();
 }
コード例 #5
0
 //TODO Change the zone to cave if implemented
 private void buildBridge(Utils.MessageBox sender, bool result)
 {
     if (result && levelHandler.player.HasItem(ItemTypes.Log))
     {
         TileOperators.changeTileAtLocation(this, TileTypes.Bridge, Zone.Surface);
         levelHandler.player.RemoveItem(ItemTypes.Log);
         levelHandler.player.callMove();
     }
     sender.Hide();
     Program.formRef.Controls.Remove(sender);
     sender.Controls.Clear();
     sender.Dispose();
 }
コード例 #6
0
 private void cutDown(Utils.MessageBox sender, bool result)
 {
     if (result && levelHandler.player.HasItem(ItemTypes.Axe))//It is possible for the player to use the item before pressing yes.
     {
         TileOperators.changeTileAtLocation(this, base.baseType, Zone.Surface);
         levelHandler.player.RemoveItem(ItemTypes.Axe);
         levelHandler.player.CollectItem(ItemTypes.Log);
         levelHandler.player.callMove();
     }
     sender.Hide();
     Program.formRef.Controls.Remove(sender);
     sender.Controls.Clear();
     sender.Dispose();
 }
コード例 #7
0
ファイル: CraftingWindow.cs プロジェクト: djns99/RelicHunter
 //Exit callback
 void DialogExitCallBack(Utils.MessageBox sender, bool result)
 {
     if (!result)
     {
         this.Close();
         lblClickHere.Hide();
     }
     else
     {
         sender.Hide();
         this.Controls.Remove(sender);
         sender.Controls.Clear();
         sender.Dispose();
     }
 }
コード例 #8
0
 //Callback for level complete message box
 private static void LevelCompleteCallback(Utils.MessageBox sender, bool result)
 {
     if (result)
     {
         Program.NextLevel();
     }
     else
     {
         Program.formRef.ReturnToMenu(null, EventArgs.Empty);
     }
     sender.Hide();
     Program.formRef.Controls.Remove(sender);
     sender.Controls.Clear();
     sender.Dispose();
 }
コード例 #9
0
ファイル: LevelMap.cs プロジェクト: djns99/RelicHunter
 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);
 }
コード例 #10
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");
         }
     }
 }
コード例 #11
0
ファイル: LevelMap.cs プロジェクト: djns99/RelicHunter
        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));
        }
コード例 #12
0
 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();
         }
     }
 }
コード例 #13
0
 private void attack(Utils.MessageBox sender, bool result)
 {
     if (result && levelHandler.player.HasItem(ItemTypes.Sword))
     {
         levelHandler.player.RemoveItem(ItemTypes.Sword);
         levelHandler.player.CollectItem(ItemTypes.Meat);
         if (base.baseType == TileTypes.Grass)
         {
             TileOperators.changeTileAtLocation(this, base.baseType, Zone.Surface);
         }
         else if (base.baseType == TileTypes.Stone)
         {
             TileOperators.changeTileAtLocation(this, base.baseType, Zone.Cave);
         }
         levelHandler.player.callMove();
     }
     sender.Hide();
     Program.formRef.Controls.Remove(sender);
     sender.Controls.Clear();
     sender.Dispose();
 }