Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public MainPage()
        {
            TARY_Library_Silverlight.ProdKey.Register(101);//產品序號


            InitializeComponent();
            tDBHandler = new DBHandler(DBHandler.DBConnection);
            if (tDBHandler.DatabaseExists() == false)
            {
                tDBHandler.CreateDatabase();

                Contacts A = new Contacts();
                A.CNAME = "HERO";
                A.XML   = null;
                tDBHandler.Contacts.InsertOnSubmit(A);
                tDBHandler.SubmitChanges();
            }

            isload();
        }
Ejemplo n.º 3
0
        //判斷是否可以讀資料
        bool isload()
        {
            tDBHandler = new DBHandler(DBHandler.DBConnection);
            var tContacts = from Contacts in tDBHandler.Contacts
                            where Contacts.XML != null && Contacts.CNAME == "HERO"
                            select Contacts;

            if (tContacts.Count() == 0)
            {
                //無紀錄
                btn_load.Foreground = new SolidColorBrush(Color.FromArgb(255, 39, 33, 33));
                return(false);
            }
            else
            {
                //有紀錄
                btn_load.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
                return(true);
            }
        }
Ejemplo n.º 4
0
        /// <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;
                }
            }
        }