private void NEWGame_btn_Click(object sender, RoutedEventArgs e) { myHERO myDATA; if (radioButton0.IsChecked == true) { myDATA = new myHERO(); myDATA.newGameRead("輕鬆"); } else if (radioButton1.IsChecked == true) { //已過試用期 - 判定app是否已購買 if (TARY_Library_Silverlight.ProdKey.ProdPass()) { myDATA = new myHERO(); myDATA.newGameRead("正常"); } else { TARY_Library_Silverlight.ProdKey.ShowAppMarketplace(); return; } } else { //已過試用期 - 判定app是否已購買 if (TARY_Library_Silverlight.ProdKey.ProdPass()) { myDATA = new myHERO(); myDATA.newGameRead("困難"); } else { TARY_Library_Silverlight.ProdKey.ShowAppMarketplace(); return; } } tR_MENU = true; LOCAL = "選單"; PANEL_NEWGAME.Visibility = System.Windows.Visibility.Collapsed; }
private void LOADGAME(object sender, RoutedEventArgs e) { if (!isload()) { return; } tDBHandler = new DBHandler(DBHandler.DBConnection); var tContacts = from Contacts in tDBHandler.Contacts where Contacts.CNAME == "HERO" select Contacts; Contacts DATA = tContacts.First(); //----------------------------------------- Byte[] by = DATA.XML; /* * string str1=""; * for (int i = 0; i < by.Count();i++ ) * { * str1 += (char)by[i]; * } * * MessageBox.Show(by.Count().ToString()); * MessageBox.Show(str1); * * return; */ MemoryStream ms = new MemoryStream(); ms.Write(by, 0, by.Count()); ms.Position = 0; myHERO S = (myHERO)Deserialize(ms, typeof(myHERO)); ms.Close(); S.Read(); GamePage.tR_MENU = true; GamePage.LOCAL = "選單"; NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative)); }
/// <summary> /// 允許頁面執行邏輯,例如更新環境、 /// 檢查衝突、收集輸入和播放音訊。 /// </summary> private void OnUpdate(object sender, GameTimerEventArgs e) { touchState = TouchPanel.GetState(); // TODO: 在此處加入更新邏輯 if (LOCAL == "遊戲") { if (PANEL_STOP.Visibility == System.Windows.Visibility.Visible) { PANEL_STOP.Visibility = System.Windows.Visibility.Collapsed; } if (PANEL_MENU.Visibility == System.Windows.Visibility.Visible) { PANEL_MENU.Visibility = System.Windows.Visibility.Collapsed; } if (R_LV == null) { R_LV = new LV(HERO_LV); } R_LV.update(); //關卡怪物 R_HERO.update(); //畫英雄 R_MFired.update(); //怪物攻擊球 R_BAR.update(); R_MonsterThg.update(); //寶物 R_BG.update(); //背景 } else if (LOCAL == "遊戲暫停") { if (PANEL_MENU.Visibility == System.Windows.Visibility.Visible) { PANEL_MENU.Visibility = System.Windows.Visibility.Collapsed; } if (PANEL_STOP.Visibility == System.Windows.Visibility.Collapsed) { PANEL_STOP.Visibility = System.Windows.Visibility.Visible; } } else if (LOCAL == "選單") { if (PANEL_STOP.Visibility == System.Windows.Visibility.Visible) { PANEL_STOP.Visibility = System.Windows.Visibility.Collapsed; } if (PANEL_MENU.Visibility == System.Windows.Visibility.Collapsed) { PANEL_MENU.Visibility = System.Windows.Visibility.Visible; } if (tR_MENU) { R_MENU.Update();//重新撈取 英雄資料 tR_MENU = false; } MENU_UPDATE();//不斷一直抓取資料 } else if (LOCAL == "死亡") { R_MENU_DEAD.update(); } else if (LOCAL == "離開遊戲") { myHERO SaveGame = new myHERO(); SaveGame.Save(); //將所有要存檔的資料彙整 MemoryStream ms = new MemoryStream(); Serialize(ms, SaveGame); ms.Position = 0; ms.Close(); byte[] by = ms.ToArray(); //------------------------------- DBHandler tDBHandler = new DBHandler(DBHandler.DBConnection); var tContacts = from Contacts in tDBHandler.Contacts where Contacts.CNAME == "HERO" select Contacts; Contacts A = tContacts.First(); A.XML = by; tDBHandler.SubmitChanges(); GamePage.R_BAR.PowerLv = 0;//將英雄能源清除 if (NavigationService.CanGoBack) { NavigationService.GoBack(); } } else if (LOCAL == "死亡離開遊戲") { GamePage.R_BAR.PowerLv = 0;//將英雄能源清除 if (NavigationService.CanGoBack) { NavigationService.GoBack(); } } else if (LOCAL == "破關") { R_GAME_END.update(); } else if (LOCAL == "新遊戲") { if (PANEL_NEWGAME.Visibility == System.Windows.Visibility.Collapsed) { PANEL_NEWGAME.Visibility = System.Windows.Visibility.Visible; } if (PANEL_STOP.Visibility == System.Windows.Visibility.Visible) { PANEL_STOP.Visibility = System.Windows.Visibility.Collapsed; } if (PANEL_MENU.Visibility == System.Windows.Visibility.Visible) { PANEL_MENU.Visibility = System.Windows.Visibility.Collapsed; } } }