Пример #1
0
        public MainPage()
        {
            this.InitializeComponent();

            ResourceCandidate rc =
                ResourceManager.Current.MainResourceMap.GetValue("Resources/txtDiff/Text",
                                                                 ResourceContext.GetForCurrentView());
            string foreground = rc.ValueAsString;

            try
            {
                //try to set the user name from local settings
                ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
                if (localSettings.Values["usrName"] != null)
                {
                    App.usrName = (String)localSettings.Values["usrName"];
                }
                //if not saved, user name defaults to User Name
                else
                {
                    App.usrName = "User Name";
                    localSettings.Values["usrName"] = App.usrName;
                }
                //same as above, but with difficulty setting
                if (localSettings.Values["difficulty"] != null)
                {
                    App.gmDifficulty = (int)localSettings.Values["difficulty"];
                }
                //if not saved, user name defaults to User Name
                else
                {
                    App.gmDifficulty = 4;
                    localSettings.Values["difficulty"] = App.gmDifficulty;
                }
            }
            catch (Exception settingNotFound)
            {
                //user name defaults to "User Name"
                string errMsg = settingNotFound.Message;
                App.usrName      = "User Name";
                App.gmDifficulty = 4;
            }
            //loading the sources of the card images into memory
            App.posCard  = new BitmapImage(new Uri(base.BaseUri, "/Resources/CardPos.png"));
            App.negCard  = new BitmapImage(new Uri(base.BaseUri, "/Resources/CardNeg.png"));
            App.deckCard = new BitmapImage(new Uri(base.BaseUri, "/Resources/DeckCard.png"));

            //populate the card pool
            Card[] pool = createCardPool();

            //create new AI and user objects
            en = new SkyNet(pool, "AI");
            pl = new User(pool, App.usrName);
        }
Пример #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //arrays containing various controls created at design time
            //helps to greatly improve efficiency when searching for control values
            usrImgs = new Image[9] {
                usrCrdImg1, usrCrdImg2, usrCrdImg3, usrCrdImg4, usrCrdImg5, usrCrdImg6, usrCrdImg7, usrCrdImg8, usrCrdImg9
            };
            enImgs = new Image[9] {
                enCrdImg1, enCrdImg2, enCrdImg3, enCrdImg4, enCrdImg5, enCrdImg6, enCrdImg7, enCrdImg8, enCrdImg9
            };
            enTxtBlks = new TextBlock[9] {
                enCrd1, enCrd2, enCrd3, enCrd4, enCrd5, enCrd6, enCrd7, enCrd8, enCrd9
            };
            usrTxtBlks = new TextBlock[9] {
                usrCrd1, usrCrd2, usrCrd3, usrCrd4, usrCrd5, usrCrd6, usrCrd7, usrCrd8, usrCrd9
            };
            enHndImgs = new Image[4] {
                enHnd1, enHnd2, enHnd3, enHnd4
            };
            enTbHnds = new TextBlock[4] {
                tbEnHnd1, tbEnHnd2, tbEnHnd3, tbEnHnd4
            };

            //boolean values control access to buttons in game
            endTurnTapped = false;
            standTapped   = false;
            usedCard      = false;
            //take in a parameter of the two player objects created in the previous page.
            //I chose to take parameters to display my knowledge of multiple ways to pass data between pages
            Player[] arr = e.Parameter as Player[];
            if (arr != null)
            {
                //setting the players
                en = (SkyNet)arr[0];
                pl = (User)arr[1];

                usrScrSwch();
                enScrSwch();
                //display name of object on screen
                enBlk.Text  = en.Name;
                usrBlk.Text = pl.Name;
                //make hands for the user and en
                popHndCrds();
                //initialize the hand images
                initHands();
                //create an actual deck of cards
                mkDeck();
                //initially gives user a card
                pl.deckCall(false, usrScr, this, deck);
                //animates the user's deck card on screen
                await srchGrid(pl);
            }
        }
Пример #3
0
        public MainPage()
        {
            this.InitializeComponent();

            ResourceCandidate rc = 
                ResourceManager.Current.MainResourceMap.GetValue("Resources/txtDiff/Text",
                ResourceContext.GetForCurrentView());
            string foreground = rc  .ValueAsString;
            try
            {
                //try to set the user name from local settings
                ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
                if (localSettings.Values["usrName"] != null)
                {
                    App.usrName = (String)localSettings.Values["usrName"];
                }
                //if not saved, user name defaults to User Name
                else
                {
                    App.usrName = "User Name";
                    localSettings.Values["usrName"] = App.usrName;
                }
                //same as above, but with difficulty setting
                if (localSettings.Values["difficulty"] != null)
                {
                    App.gmDifficulty = (int)localSettings.Values["difficulty"];
                }
                //if not saved, user name defaults to User Name
                else
                {
                    App.gmDifficulty = 4;
                    localSettings.Values["difficulty"] = App.gmDifficulty;
                }
            }
            catch (Exception settingNotFound)
            {
                //user name defaults to "User Name"
                string errMsg = settingNotFound.Message;
                App.usrName = "User Name";
                App.gmDifficulty = 4;
            }
            //loading the sources of the card images into memory
            App.posCard = new BitmapImage(new Uri(base.BaseUri, "/Resources/CardPos.png"));
            App.negCard = new BitmapImage(new Uri(base.BaseUri, "/Resources/CardNeg.png"));
            App.deckCard = new BitmapImage(new Uri(base.BaseUri, "/Resources/DeckCard.png"));

            //populate the card pool
            Card[] pool = createCardPool();

            //create new AI and user objects
            en = new SkyNet(pool, "AI");
            pl = new User(pool, App.usrName);
        }
Пример #4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //arrays containing various controls created at design time
            //helps to greatly improve efficiency when searching for control values 
            usrImgs = new Image[9] { usrCrdImg1, usrCrdImg2, usrCrdImg3, usrCrdImg4, usrCrdImg5, usrCrdImg6, usrCrdImg7, usrCrdImg8, usrCrdImg9 };
            enImgs = new Image[9] { enCrdImg1, enCrdImg2, enCrdImg3, enCrdImg4, enCrdImg5, enCrdImg6, enCrdImg7, enCrdImg8, enCrdImg9 };
            enTxtBlks = new TextBlock[9] { enCrd1, enCrd2, enCrd3, enCrd4, enCrd5, enCrd6, enCrd7, enCrd8, enCrd9 };
            usrTxtBlks = new TextBlock[9] { usrCrd1, usrCrd2, usrCrd3, usrCrd4, usrCrd5, usrCrd6, usrCrd7, usrCrd8, usrCrd9 };
            enHndImgs = new Image[4] { enHnd1, enHnd2, enHnd3, enHnd4 };
            enTbHnds = new TextBlock[4] { tbEnHnd1, tbEnHnd2, tbEnHnd3, tbEnHnd4 };

            //boolean values control access to buttons in game
            endTurnTapped = false;
            standTapped = false;
            usedCard = false;
            //take in a parameter of the two player objects created in the previous page.
            //I chose to take parameters to display my knowledge of multiple ways to pass data between pages
            Player[] arr = e.Parameter as Player[];
            if (arr != null)
            {
                //setting the players 
                en = (SkyNet)arr[0];
                pl = (User)arr[1];

                usrScrSwch();
                enScrSwch();
                //display name of object on screen
                enBlk.Text = en.Name;
                usrBlk.Text = pl.Name;
                //make hands for the user and en
                popHndCrds();
                //initialize the hand images
                initHands();
                //create an actual deck of cards
                mkDeck();
                //initially gives user a card
                pl.deckCall(false, usrScr, this, deck);
                //animates the user's deck card on screen
                await srchGrid(pl);
            }
        }