Example #1
0
        public void UpdateAchievements()
        {
            AchievementMonitor achievements    = AchievementMonitor.GetInstance();
            List <Achievement> achievementList = achievements.GetAchievements();

            flowPnlAchievements.Controls.Clear();

            for (int i = achievementList.Count - 1; i >= 0; i--)
            {
                //Create new icon
                PictureBox icon = new PictureBox();

                //Set icon properties
                icon.Tag      = i;
                icon.Image    = achievementList[i].GetIcon();
                icon.Width    = 38;
                icon.Height   = 34;
                icon.SizeMode = PictureBoxSizeMode.StretchImage;

                //Set tooltip
                icon.MouseHover += (s, exp) =>
                {
                    int index = (int)icon.Tag;
                    MakeToolTip(icon, achievementList[index].GetName() +
                                "\n\r" + achievementList[index].GetDescription() +
                                "\n\r Date Earned: " + achievementList[index].GetReadableTime());
                };

                flowPnlAchievements.Controls.Add(icon);
            }
        }
Example #2
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
         return;
     }
     else
     {
         instance = this;
     }
 }
Example #3
0
        private void ParseUpdate(String[] update_array)
        {
            if (update_array[0].Equals(StupidServer.UPDATE_GAME_CONNECTION_BROKEN))
            {
                Program.CloseStupidConnector();
                this.Close();
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_DEALER_DRAW))
            {
                Card cardToDraw = Card.Parse(update_array[1]);
                dealer.giveCard(cardToDraw);
                deck.RemoveCard(cardToDraw);
                lblDealerCards.Text += cardToDraw.GetUnicode() + "  ";
                lblDealerScore.Text  = dealer.Score.ToString();
                //lblDealerCards.Enabled = true;
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_DEALER_SETUP))
            {
                Card card1 = deck.dealCard();
                Card card2 = deck.dealCard();
                /// dealer.giveCard(card1);
                /// dealer.giveCard(card2);
                ParseUpdate(Program.GetConnector().NotifyDealerDraw(card1, this.id));
                ParseUpdate(Program.GetConnector().NotifyDealerDraw(card2, this.id));
                ParseUpdate(Program.GetConnector().NotifyDealerSetupFinished(this.id));
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_DEALER_STAND))
            {
                turnCount++; //Keeps track of the number of times this method has been called
                int   array_size      = nPlayers + 1;
                int[] scoresToCompare = new int[array_size];
                for (int i = 0; i < array_size - 1; i++)
                {
                    scoresToCompare[i] = players[i].Score;
                }
                scoresToCompare[myindex]        = 0;
                scoresToCompare[array_size - 1] = dealer.Score;

                if (players[myindex].Score > 21)
                {
                    System.Windows.Forms.MessageBox.Show("You busted, loser!", "Hey Player" + myindex.ToString());
                }
                else if (players[myindex].Score > dealer.Score || dealer.Score > 21)
                {
                    System.Windows.Forms.MessageBox.Show("You won!", "Hey Player" + myindex.ToString());
                    AchievementMonitor.GetInstance().AddWin();
                    if (isOnline)
                    {
                        AchievementMonitor.GetInstance().AddOnlineWinAchievement();
                    }
                    if (turnCount == 1)
                    {
                        AchievementMonitor.GetInstance().AddInstantWinAchievement();
                    }
                    frmTitle.getInstance().UpdateAchievements();
                }
                else if (players[myindex].Score == dealer.Score)
                {
                    System.Windows.Forms.MessageBox.Show("You tied!", "Hey Player" + myindex.ToString());
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("You took the L!", "Hey Player" + myindex.ToString());
                }
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_DEALER_TURN))
            {
                dealer.MakeTurn(id);
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_PLAYER_CONNECTION_BROKEN))
            {
                int playerindex = Int32.Parse(update_array[1]);
                players[playerindex].SetStatus("Left game");
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_PLAYER_JOINED))
            {
                // ignore, game already started
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_PLAYER_DRAW))
            {
                int playerindex = Int32.Parse(update_array[1]);
                if (myindex != playerindex)
                {
                    Card cardToDraw = Card.Parse(update_array[2]);
                    players[playerindex].giveCard(cardToDraw);
                    deck.RemoveCard(cardToDraw);
                    players[playerindex].SetStatus("Drew: " + cardToDraw.ToString());
                }
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_PLAYER_STAND))
            {
                int playerindex = Int32.Parse(update_array[1]);
                players[playerindex].SetStatus("Stood");
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_YOUR_SETUP))
            {
                Card card1 = deck.dealCard();
                Card card2 = deck.dealCard();
                players[myindex].giveCard(card1);
                players[myindex].giveCard(card2);
                this.ParseUpdate(Program.GetConnector().NotifyCardDrawn(card1, this.id));
                this.ParseUpdate(Program.GetConnector().NotifyCardDrawn(card2, this.id));
                this.ParseUpdate(Program.GetConnector().NotifySetupFinished(this.id));
            }
            else if (update_array[0].Equals(StupidServer.UPDATE_YOUR_TURN))
            {
                isMyTurn = true;
                System.Windows.Forms.MessageBox.Show("It's your turn!", "Hey Player" + myindex.ToString());
                btnHit.Enabled   = true;
                btnStand.Enabled = true;
            }
            else
            {
                // unrecognized update, probably leftover RESPONSE_SUCCESS
            }
        }