Example #1
0
 private void shopOptionButtonClick(object sender, EventArgs e)
 {
     btnClickSoundAction();
     if (posInBuyingOptions == 0)
     {
         if (coinsAndHeartsManager.curr.bronzeCoins < 100)
         {
             notEnoghMoneyWarning();
         }
         else
         {
             coinsAndHeartsManager.Update(new CoinsAndHearts(0, 7, -100, 0));
             CoinsAndHeartsManager.Save(coinsAndHeartsManager);
         }
     }
     else if (posInBuyingOptions == 1)
     {
         if (coinsAndHeartsManager.curr.silverCoins < 83)
         {
             notEnoghMoneyWarning();
         }
         else
         {
             coinsAndHeartsManager.Update(new CoinsAndHearts(3, -83, 0, 0));
             CoinsAndHeartsManager.Save(coinsAndHeartsManager);
         }
     }
     else if (posInBuyingOptions == 2)
     {
         if (coinsAndHeartsManager.curr.silverCoins < 10)
         {
             notEnoghMoneyWarning();
         }
         else
         {
             coinsAndHeartsManager.Update(new CoinsAndHearts(0, -10, 0, 0));
             CoinsAndHeartsManager.Save(coinsAndHeartsManager);
             DateTime d = SlotMachineState.Load();
             d = new DateTime(d.Year - 1, d.Month, d.Day);
             SlotMachineState.Save(d);
             _game.ChangeState(new LoadingState(_game, _graphicsDevice, _content, graphics, _soundsDict,
                                                new SlotMachineState(_game, _graphicsDevice, _content, graphics, _soundsDict), 2f));
         }
     }
     else if (posInBuyingOptions == 3)
     {
         if (coinsAndHeartsManager.curr.goldCoins < 2)
         {
             notEnoghMoneyWarning();
         }
         else
         {
             coinsAndHeartsManager.Update(new CoinsAndHearts(-2, 0, 0, 1));
             CoinsAndHeartsManager.Save(coinsAndHeartsManager);
         }
     }
 }
Example #2
0
        public PrizesState(Game1 game, GraphicsDevice graphicsDevice, ContentManager content, GraphicsDeviceManager graphics_, Dictionary <string, Song> sounds, CoinsAndHearts coins, int seconds, string level) :
            base(game, graphicsDevice, content, graphics_, sounds)
        {
            //load backgroound
            background = _content.Load <Texture2D>("Backgrounds/PrizesBackground");

            //font for the text (i dont use it because i dont write text on the button)
            SpriteFont btnTextFont = _content.Load <SpriteFont>("Fonts/font");

            font = btnTextFont;

            //handle backButton button
            var backButton = new Button(_content.Load <Texture2D>("Buttons/backBtn"), new Vector2(5, 5),
                                        Color.Black, Color.White, btnTextFont, "", 15);

            backButton.Click += backButtonClick;

            //create the list
            _components = new List <Button>()
            {
                backButton
            };

            // data of coins and level
            txt  = "Level: ";
            txt += level;
            txt += "\nTime: ";
            txt += seconds.ToString();
            txt += " sec\nGold: ";
            txt += coins.goldCoins.ToString();
            txt += "\nSilver: ";
            txt += coins.silverCoins.ToString();
            txt += "\nBronze: ";
            txt += coins.bronzeCoins.ToString();

            CoinsAndHeartsManager cahm = CoinsAndHeartsManager.Load();

            cahm.Update(coins);
            CoinsAndHeartsManager.Save(cahm);

            ScoreManager s;

            try
            {
                s = ScoreManager.Load();
            }
            catch
            {
                s = new ScoreManager(new List <Score>());
            }

            s.scores.Add(new Score(DateTime.UtcNow, coins, seconds, level));
            ScoreManager.Save(s);
        }
Example #3
0
        public override void Update(GameTime gametime)
        {
            Save(ctflist);

            string ch = "";
            var    kb = Keyboard.GetState();

            Keys[] lkb = kb.GetPressedKeys();
            if (lkb.Length > 0)
            {
                ch = lkb[0].ToString();
            }

            if (ctfInsertNum == 1 && ctflist[0].isDone == false)
            {
                if (kb.IsKeyDown(Keys.Enter))
                {
                    if (findThePassCtfButtonStr == ">-{You_Got_My_Pass_Greate_job!_U_R_The_GOAT!}-<")
                    {
                        coinsAndHeartsManager.Update(new CoinsAndHearts(5, 37, 11, 0));
                        CoinsAndHeartsManager.Save(coinsAndHeartsManager);

                        ctflist[0].isDone       = true;
                        ctflist[0].date         = DateTime.UtcNow;
                        findThePassCtfButtonStr = "done in \n mm/dd/yyyy: \n" + DateTime.UtcNow.ToString("dd/MM/yyyy");
                        _components[2].changeTexture(findThePassCtfButtonTexture2);
                    }
                    else
                    {
                        ctflist[0].isDone       = false;
                        findThePassCtfButtonStr = "Wrong Answer.... Try Again!";
                    }
                }
                else if (findThePassCtfButtonStr.Count() < 50)
                {
                    findThePassCtfButtonStr += ch;
                    Console.WriteLine(findThePassCtfButtonStr);
                }
            }
            else if (ctfInsertNum == 2 && ctflist[1].isDone == false)
            {
                if (kb.IsKeyDown(Keys.Enter))
                {
                    if (otherCtfButtonStr == "PSS")
                    {
                        coinsAndHeartsManager.Update(new CoinsAndHearts(0, 0, 1, 0));
                        CoinsAndHeartsManager.Save(coinsAndHeartsManager);

                        ctflist[1].isDone = true;
                        ctflist[1].date   = DateTime.UtcNow;
                        otherCtfButtonStr = "done in \n mm/dd/yyyy: \n" + DateTime.UtcNow.ToString("dd/MM/yyyy");
                        _components[3].changeTexture(otherCtfButtonTexture2);
                    }
                    else
                    {
                        ctflist[0].isDone = false;
                        otherCtfButtonStr = "Wrong Answer.... Try Again!";
                    }
                }
                else if (otherCtfButtonStr.Count() < 50)
                {
                    otherCtfButtonStr += ch;
                }
            }
            try
            {
                Save(ctflist);
            }
            catch
            { }
            foreach (var component in _components)
            {
                component.Update(gametime);
            }
        }
Example #4
0
        public override void Draw(GameTime gametime, SpriteBatch spritebatch)
        {
            //if the animation of the slot machine is off
            spritebatch.Begin();
            spritebatch.Draw(background, new Vector2(0, 0), Color.White);
            spritebatch.Draw(smTexture, new Vector2(300, 200), Color.White);
            spritebatch.Draw(txtr3[0], new Vector2(320, 240), Color.White);
            spritebatch.Draw(txtr3[1], new Vector2(420, 240), Color.White);
            spritebatch.Draw(txtr3[2], new Vector2(520, 240), Color.White);
            spritebatch.Draw(insTexture, new Vector2(15, 100), Color.White);
            foreach (var component in components)
            {
                component.Draw(spritebatch);
            }
            coinsAndHeartsManager.Draw(spritebatch, _content);

            spritebatch.End();

            //handle animation
            if (isAnimation == true)
            {
                DateTime date = Load();
                DateTime curr = DateTime.UtcNow;
                Random   rand = new Random();

                if (date.Day == curr.Day && date.Month == curr.Month && date.Year == curr.Year)
                {
                    if (numOfChanges == 0)
                    {
                        handleErrorMsg(spritebatch, gametime);
                    }
                    else
                    {
                        Thread.Sleep(4000);//sleep
                        isAnimation = false;
                    }
                }
                else
                {
                    if (numOfChanges == 0)
                    {
                        txtr3 = new List <Texture2D> {
                            smTextures[0], smTextures[0], smTextures[0]
                        }
                    }
                    ;

                    if (numOfChanges < 20)
                    {
                        Thread.Sleep(200);//sleep
                        int num1 = rand.Next(0, 8);
                        int num2 = rand.Next(0, 8);
                        int num3 = rand.Next(0, 8);
                        txtr3 = new List <Texture2D> {
                            smTextures[num1], smTextures[num2], smTextures[num3]
                        };
                    }
                    else if (numOfChanges == 20)
                    {
                        //update prize
                        if (txtr3[0] == txtr3[1] && txtr3[0] == txtr3[2])
                        {
                            coinsAndHeartsManager.Update(new CoinsAndHearts(1, 0, 0, 0));
                            CoinsAndHeartsManager.Save(coinsAndHeartsManager);
                            spritebatch.Begin();
                            spritebatch.Draw(wonMsgs[0], new Vector2(270, 50), Color.White);
                            spritebatch.End();
                        }
                        else if (txtr3[0] == txtr3[1] || txtr3[0] == txtr3[2] || txtr3[2] == txtr3[1])
                        {
                            coinsAndHeartsManager.Update(new CoinsAndHearts(0, 5, 0, 0));
                            CoinsAndHeartsManager.Save(coinsAndHeartsManager);
                            spritebatch.Begin();
                            spritebatch.Draw(wonMsgs[1], new Vector2(270, 50), Color.White);
                            spritebatch.End();
                        }
                        else
                        {
                            coinsAndHeartsManager.Update(new CoinsAndHearts(0, 0, 10, 0));
                            CoinsAndHeartsManager.Save(coinsAndHeartsManager);
                            spritebatch.Begin();
                            spritebatch.Draw(wonMsgs[2], new Vector2(270, 50), Color.White);
                            spritebatch.End();
                        }
                    }
                    else
                    {
                        Thread.Sleep(4000);//sleep
                        Save(curr);
                        isAnimation = false;
                    }
                }
                numOfChanges++;
            }
        }