Exemplo n.º 1
0
        public void DetermineNextPosition(ToyCard Card, List <IPlayer> Players)
        {
            // the positions of the toy cards are hardcoded
            if (Card.ImageName == "basketball")
            {
                this._nextPosition = 24;
            }
            else if (Card.ImageName == "car")
            {
                this._nextPosition = 24 + 28;
            }
            else if (Card.ImageName == "keyboard")
            {
                this._nextPosition = 24 + 28 * 2;
            }
            else if (Card.ImageName == "dinosaur")
            {
                this._nextPosition = 24 + 28 * 3;
            }
            else if (Card.ImageName == "teddybear")
            {
                this._nextPosition = 24 + 28 * 4;
            }
            else if (Card.ImageName == "tricycle")
            {
                this._nextPosition = 24 + 28 * 5;
            }
            else if (Card.ImageName == "blocks")
            {
                this._nextPosition = 24 + 28 * 6;
            }
            //else if (Card.ImageName == "drum") this._nextPosition = 24 + 28 * 8;
            this._nextPosition += this._offset;

            /*
             * // make sure the position isn't already occupied
             * foreach (IPlayer p in Players)
             * {
             *  if (p.Position == this._nextPosition)
             *  {
             *      this._offset += 1;
             *      this._nextPosition += 1;
             *  }
             * }*/
        }
Exemplo n.º 2
0
        private void DrawCard()
        {
            if (Card.Text != "")
            {
                // they've clicked to draw a card!
                // figure out who the player is
                IPlayer thisPlayer = Players[_whoseTurn];

                // should it be a toy card or a color card?
                int colorOrToy = rnd.Next(0, 10);
                if (colorOrToy == 0) //  should be (colorOrToy == 0)
                {
                    // toy card!
                    Bitmap[] toys = { Properties.Resources.basketball, Properties.Resources.car,       Properties.Resources.keyboard,
                                      Properties.Resources.dinosaur,   Properties.Resources.teddybear, Properties.Resources.tricycle,
                                      Properties.Resources.blocks };
                    string[] imageNames = { "basketball", "car", "keyboard", "dinosaur", "teddybear", "tricycle", "blocks" };

                    // there are 7 toys on the board?
                    int    imgNum      = rnd.Next(0, 7); // to do: should be 0, 7
                    Bitmap chosenImage = toys[imgNum];
                    // make sure this card is still available to be drawn, because toys can only be drawns once eacyh per game

                    /* to do: uncomment this?
                     * if (toysAlreadyDrawn.Contains(imageNames[imgNum]))
                     * {
                     *  // draw a different card
                     *  this.Card_Click(sender, e);
                     *  return;
                     * }*/

                    toysAlreadyDrawn.Add(imageNames[imgNum]);
                    ToyCard drawnCard = new ToyCard(chosenImage, imageNames[imgNum]);
                    synth.SpeakAsync("Go to the " + imageNames[imgNum]);
                    CardColor3.BackgroundImage = drawnCard.Image;
                    CardColor3.BackColor       = Color.Empty;
                    CardColor3.Visible         = true;

                    // the player needs to know where the target is on the trail
                    thisPlayer.DetermineNextPosition(drawnCard, this.Players);
                    this.debug.Text = "next: " + thisPlayer.NextPosition.ToString();
                }
                else
                {
                    // color card!
                    ColorCard drawnCard = new ColorCard(rnd);
                    if (drawnCard.NumSquares == 1)
                    {
                        CardColor3.BackColor = drawnCard.Color;
                        CardColor3.Visible   = true;
                        synth.SpeakAsync("Move one " + this.ColorNameOnly(drawnCard.Color) + " square");
                    }
                    else
                    {
                        CardColor1.BackColor = drawnCard.Color;
                        CardColor2.BackColor = drawnCard.Color;
                        CardColor1.Visible   = true;
                        CardColor2.Visible   = true;
                        synth.SpeakAsync("Move two " + this.ColorNameOnly(drawnCard.Color) + " squares");
                    }
                    // the player needs to know where the target is on the trail
                    thisPlayer.DetermineNextPosition(drawnCard, this.Players);
                    //this.debug.Text = thisPlayer.NextPosition.ToString();
                }
                Card.Text         = "";
                Card.Visible      = false;
                this.cardWasDrawn = true;
            }
        }