protected void reset_Click(object sender, EventArgs e) { game = new BeehiveGame(); Session["gamedata"] = game; Response.Redirect(Request.RawUrl); }
protected void updateView() { if (Session["gamedata"] == null) { game = new BeehiveGame(); Session["gamedata"] = game; } else { game = (BeehiveGame)Session["gamedata"]; } if (game.checkWinState()) { nameInput.Visible = false; nameSubmit.Visible = false; for (int i = 1; i <= 6; i++) { Image a = (Image)this.FindControl("dancingBee" + i); a.Visible = true; } if (scores.ElementAt(scores.Count() - 1).time >= game.totalTime) { System.Diagnostics.Debug.WriteLine("winstate"); nameInput.Visible = true; nameSubmit.Visible = true; } } else { for (int i = 1; i <= 6; i++) { Image a = (Image)this.FindControl("dancingBee" + i); a.Visible = false; } } for (int i = 1; i <= 6; i++) { ImageButton img = (ImageButton)this.FindControl("flower" + i); if (game.getFlowerStack(i).Count() == 0) { img.ImageUrl = "~/resources/cards_png/blank.png"; } else { img.ImageUrl = "~/resources/cards_png/" + game.getFlowerStack(i).Peek().getImageFile(); } if (Session["selected"] == null) { img.BorderWidth = 0; } } if (game.getBeehive().Count() > 0) { beehiveStack.ImageUrl = "~/resources/cards_png/" + game.getBeehive().Peek().getImageFile(); } else { beehiveStack.ImageUrl = "~/resources/cards_png/blank.png"; } if (game.getWorkingPile().Count() > 0) { workingStack.ImageUrl = "~/resources/cards_png/" + game.getWorkingPile().Peek().getImageFile(); } else { workingStack.Visible = false; } if (game.getWorkingPile().Count() < 3) { hide1.Visible = false; } if (game.getWorkingPile().Count() < 2) { hide2.Visible = false; } if (game.getDeck().Count() < 1) { deck.ImageUrl = "~/resources/cards_png/blank.png"; } else { deck.ImageUrl = "~/resources/cards_png/b1fv.png"; } timeLabel.Text = "" + (DateTime.Now.ToFileTime() - game.startTime) / 10000000.0; // System.Diagnostics.Debug.WriteLine(game.printGameState()); }
protected void nameSubmit_Click(object sender, EventArgs e) { if (game.playerWon()) { scores.Add(new Score(nameInput.Text, game.totalTime)); scores = scores.OrderBy(o => o.time).ToList(); while (scores.Count() > 10) { scores.RemoveAt(scores.Count() - 1); } string scoresXML = SerializationUtils.SerializeObject(scores); System.IO.File.WriteAllText(Server.MapPath("~") + "/scores.xml", scoresXML); game = new BeehiveGame(); Session["gamedata"] = game; Response.Redirect(Request.RawUrl); } else { System.Diagnostics.Debug.WriteLine("Error: User clicked name submit button but didnt win first"); } }