// 簡單按鈕,按一下事件處理常式,把我們帶到第二頁 private void NEWGAME(object sender, RoutedEventArgs e) { if (isload()) { MessageBoxResult m = MessageBox.Show(LanguageData.MENU_MSGC, LanguageData.MENU_MSG, MessageBoxButton.OKCancel); if (m == MessageBoxResult.OK) { MENU_DEAD.DelRecord();//將紀錄給刪除 避免有人直接關手機 然後再破一次 } else { return; } } GamePage.LOCAL = "新遊戲"; NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative)); }
protected override void OnNavigatedTo(NavigationEventArgs e) { // 設定圖形裝置的共用模式,以開啟 XNA 呈現 SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true); // 建立可用來繪製紋理的新 SpriteBatch。 spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice); //音效****************** effectgetHP = contentManager.Load <SoundEffect>("music/getHP"); effectgetPower = contentManager.Load <SoundEffect>("music/getPower"); effectgetThunder = contentManager.Load <SoundEffect>("music/getHP"); effectballM2 = contentManager.Load <SoundEffect>("music/ball_M2"); effectMonsterfired = contentManager.Load <SoundEffect>("music/mFired"); effectMonsterfires = contentManager.Load <SoundEffect>("music/mFires"); effectMonsterDead = contentManager.Load <SoundEffect>("music/mDead"); effectHerofired = contentManager.Load <SoundEffect>("music/hFired"); effectHerofires = contentManager.Load <SoundEffect>("music/hFires"); effectHeroDead = contentManager.Load <SoundEffect>("music/hFired");//與扣血相同 picOneP = new Texture2D[] { contentManager.Load <Texture2D>("oneP1"), contentManager.Load <Texture2D>("oneP2_A"), contentManager.Load <Texture2D>("oneP3") }; picOneP2 = new Texture2D[] { contentManager.Load <Texture2D>("oneP2_A"), contentManager.Load <Texture2D>("oneP2_B"), contentManager.Load <Texture2D>("oneP2_C") }; picOneP4 = new Texture2D[] { contentManager.Load <Texture2D>("oneP4_A"), contentManager.Load <Texture2D>("oneP4_B") }; picStarBar = new Texture2D[] { contentManager.Load <Texture2D>("starS1"), contentManager.Load <Texture2D>("starS2") }; picGAMEEND = contentManager.Load <Texture2D>("GAMEEND"); picSCORE = contentManager.Load <Texture2D>("SCORE"); picBOSS1 = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS1_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS1_B"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS1_C") }; picBOSS2 = contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS2"); picBOSS3 = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS3_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS3_B") }; picBOSS4 = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS4_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS4_B"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS4_C"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS4_D") }; picBOSS4_LEFT = contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS4_LEFT"); picBOSS4_RIGHT = contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS4_RIGHT"); picBOSS5 = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_B"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_C"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_D"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_E"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_F") }; picBOSS5_G = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_G1"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_G2"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS5_G3") }; picBOSS51_G = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS51_G1"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS51_G2"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS51_G3") }; picBOSS6 = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_A_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_A_B"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_A_C"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_B_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_B_B"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_B_C"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_C_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_C_B"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS6_C_C") }; picBOSS7 = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS7_A"), contentManager.Load <Texture2D>("MONSTER/BOSS/BOSS7_B") }; picMONSTER1_A = contentManager.Load <Texture2D>("MONSTER/MONSTER1/MONSTER1_A"); picMONSTER1_B = contentManager.Load <Texture2D>("MONSTER/MONSTER1/MONSTER1_B"); picMONSTER1_C = contentManager.Load <Texture2D>("MONSTER/MONSTER1/MONSTER1_C"); picMONSTER1_D = contentManager.Load <Texture2D>("MONSTER/MONSTER1/MONSTER1_D"); picMONSTER3_A = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_A_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_A_B") }; picMONSTER3_B = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_B_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_B_B") }; picMONSTER3_C = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_C_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_C_B") }; picMONSTER3_D = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_D_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_D_B") }; picMONSTER31_A = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_A_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_A_B") }; picMONSTER31_B = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_B_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_B_B") }; picMONSTER31_C = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_C_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_C_B") }; picMONSTER31_D = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_D_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER3/MONSTER3_D_B") }; picMONSTER4_A = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER4_A"); picMONSTER4_B = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER4_B"); picMONSTER4_C = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER4_C"); picMONSTER4_D = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER4_D"); picMONSTER41_A = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER41_A"); picMONSTER41_B = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER41_B"); picMONSTER41_C = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER41_C"); picMONSTER41_D = contentManager.Load <Texture2D>("MONSTER/MONSTER4/MONSTER41_D"); picMONSTER5_A = contentManager.Load <Texture2D>("MONSTER/MONSTER5/MONSTER5_A"); picMONSTER5_B = contentManager.Load <Texture2D>("MONSTER/MONSTER5/MONSTER5_B"); picMONSTER5_C = contentManager.Load <Texture2D>("MONSTER/MONSTER5/MONSTER5_C"); picMONSTER5_D = contentManager.Load <Texture2D>("MONSTER/MONSTER5/MONSTER5_D"); picMONSTER7_A = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER7/MONSTER7_A_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER7/MONSTER7_A_B") }; picMONSTER7_B = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER7/MONSTER7_B_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER7/MONSTER7_B_B") }; picMONSTER7_C = new Texture2D[] { contentManager.Load <Texture2D>("MONSTER/MONSTER7/MONSTER7_C_A"), contentManager.Load <Texture2D>("MONSTER/MONSTER7/MONSTER7_C_B") }; //英雄子彈種類 picBallA = new Texture2D[] { contentManager.Load <Texture2D>("ballA1"), contentManager.Load <Texture2D>("ballA2"), contentManager.Load <Texture2D>("ballA3") }; picBallB = new Texture2D[] { contentManager.Load <Texture2D>("ballB1"), contentManager.Load <Texture2D>("ballB2"), contentManager.Load <Texture2D>("ballB3") }; picBallC = new Texture2D[] { contentManager.Load <Texture2D>("ballC1"), contentManager.Load <Texture2D>("ballC2"), contentManager.Load <Texture2D>("ballC3") }; picBall = picBallC[2]; picBallM2 = new Texture2D[] { contentManager.Load <Texture2D>("BallM2_A"), contentManager.Load <Texture2D>("BallM2_B"), contentManager.Load <Texture2D>("BallM2_C") }; picBallM3 = new Texture2D[] { contentManager.Load <Texture2D>("BallM3_A"), contentManager.Load <Texture2D>("BallM3_B"), contentManager.Load <Texture2D>("BallM3_C") }; //----------- picHERO = contentManager.Load <Texture2D>("HERO"); picBAR = contentManager.Load <Texture2D>("BAR"); picBAR2 = contentManager.Load <Texture2D>("BAR2"); picLOVE = contentManager.Load <Texture2D>("LOVE"); picLOVE2 = contentManager.Load <Texture2D>("LOVE2"); picLOVES = contentManager.Load <Texture2D>("LOVES"); picLOVES2 = contentManager.Load <Texture2D>("LOVES2"); picLOVESS = contentManager.Load <Texture2D>("LOVESS"); picLOVESS2 = contentManager.Load <Texture2D>("LOVESS2"); picLEVEL = contentManager.Load <Texture2D>("LEVEL"); picGAMEOVER = contentManager.Load <Texture2D>("GAMEOVER"); picStar1 = contentManager.Load <Texture2D>("STAR1"); picStar2 = contentManager.Load <Texture2D>("STAR2"); picStar3 = contentManager.Load <Texture2D>("STAR3"); picStar4 = contentManager.Load <Texture2D>("STAR4"); picStar5 = contentManager.Load <Texture2D>("STAR5"); picStar6 = contentManager.Load <Texture2D>("STAR6"); picStar7 = contentManager.Load <Texture2D>("STAR7"); picStar8 = contentManager.Load <Texture2D>("STAR8"); for (int i = 0; i < picHERO_DEAD.Count(); i++) { picHERO_DEAD[i] = contentManager.Load <Texture2D>("P/p" + (i + 1).ToString()); } for (int i = 0; i < picNum.Count(); i++) { picNum[i] = contentManager.Load <Texture2D>("lib/number2/num" + i.ToString()); picNum2[i] = contentManager.Load <Texture2D>("lib/number3/num" + i.ToString()); } // TODO: 在此處使用 this.content 載入遊戲內容 //主要角色******************* if (_BG != null) { R_BG = _BG; } else { R_BG = new BG(picStar1); } if (_BAR != null) { R_BAR = _BAR; } else { R_BAR = new BAR(); } if (_HERO != null) { R_HERO = _HERO; } else { R_HERO = new HERO(HERO_LOC); } if (_LV != null) { R_LV = _LV; } if (_MENU != null) { R_MENU = _MENU; } else { R_MENU = new MENU(); PANEL_MENU.Children.Add(R_MENU); } if (_MENU_DEAD != null) { R_MENU_DEAD = _MENU_DEAD; } if (_GAME_END != null) { R_GAME_END = _GAME_END; } if (_MFired != null) { R_MFired = _MFired; } else { R_MFired = new MonsterFired(); } if (_MonsterThg != null) { R_MonsterThg = _MonsterThg; } else { R_MonsterThg = new MonsterThg(); } R_STOP = new STOP(); if (PANEL_STOP.Children.Count == 0) { PANEL_STOP.Children.Add(R_STOP); } // 啟動計時器 timer.Start(); base.OnNavigatedTo(e); }