Beispiel #1
0
        public PlayPiece[] createLudoPieces()
        {
            PlayPiece[] pPiece = new PlayPiece[16];

            //Point[] startPoint = { new Point(1, 4), new Point(2, 4), new Point(1, 5), new Point(2, 5), new Point(9, 1), new Point(9, 2), new Point(10, 1), new Point(10, 2), new Point(12, 9), new Point(13, 9), new Point(12, 10), new Point(13, 10), new Point(4, 12), new Point(5, 12), new Point(4, 13), new Point(5, 13) };
            string[] state = new string[3];

            for (int i = 0; i <= pPiece.Length; i++)
            {
                if (i < 4)
                {
                    pPiece[i] = new PlayPiece(LudoHelper.color.green, 1, LudoHelper.state.ude, false, "g" + (i + 1));
                }
                else if (i > 3 && i < 8)
                {
                    pPiece[i] = new PlayPiece(LudoHelper.color.blue, 14, LudoHelper.state.ude, false, "b" + (i - 3));
                }
                else if (i > 7 && i < 12)
                {
                    pPiece[i] = new PlayPiece(LudoHelper.color.yellow, 27, LudoHelper.state.ude, false, "y" + (i - 7));
                }
                else if (i > 11 && i < 16)
                {
                    pPiece[i] = new PlayPiece(LudoHelper.color.red, 40, LudoHelper.state.ude, false, "r" + (i - 11));
                }
            }

            return(pPiece);
        }
Beispiel #2
0
        // Funktion der kontrollere at du er kommet til stjernen ved din zone og beregner hvor meget du har til overerst
        public int enterZone(int where, string brikNr, int dice, PlayPiece piece)
        {
            string color   = brikNr.Substring(0, 1).ToLower();
            int    before  = where - dice;
            int    howMuch = 0;

            if (color == "b" && before <= 12 && where > 12)
            {
                piece.state = LudoHelper.state.zone;
                howMuch     = where - 12;
            }
            else if (color == "y" && before <= 25 && where > 25)
            {
                piece.state = LudoHelper.state.zone;
                howMuch     = where - 25;
            }
            else if (color == "r" && before <= 38 && where > 38)
            {
                piece.state = LudoHelper.state.zone;
                howMuch     = where - 38;
            }
            else if (color == "g" && before <= 51 && where > 51)
            {
                piece.state = LudoHelper.state.zone;
                howMuch     = where - 51;
            }

            return(howMuch);
        }
Beispiel #3
0
        //Den funktion der opretter spillere og tildeler dem en farve og hvem der er først
        public string startgame(int antalSP)
        {
            Random  rand = new Random();
            Control ctrl = new Control();

            LudoBoardField[] ludoBoard = new LudoBoardField[52];
            PlayPiece[]      pieces    = new PlayPiece[16];
            player      = new Player[antalSP];
            ludoBoard   = this.ludoBoard.makeBoard();
            userMessage = "";

            pieces = this.ludoBoard.createLudoPieces();
            LudoHelper.color[] ludoHelp = new LudoHelper.color[4];
            ludoHelp[0] = LudoHelper.color.red;
            ludoHelp[1] = LudoHelper.color.yellow;
            ludoHelp[2] = LudoHelper.color.blue;
            ludoHelp[3] = LudoHelper.color.green;
            Dice ludoDice = new Dice(6);

            int[] rNumber = ludoDice.getRandomNR(0, antalSP);

            ludoHelp = ctrl.unsortArray(ludoHelp);

            int tal = 0;

            for (int i = 0; i <= antalSP - 1; i++)
            {
                tal       = rNumber[i];
                player[i] = new Player(false, ludoHelp[tal], true, tal + 1);
            }

            player = ctrl.sortArray(player);

            for (int i = 0; i < player.Length; i++)
            {
                userMessage += "Spiller nr " + player[i].playerNr + " har fået farve " + player[i].colorChoise.ToString() + " \r\n";
            }
            if (antalSP < 3)
            {
                tal          = rand.Next(0, 1);
                userMessage += "Det er spiller nr " + (tal + 1) + " der starter med " + player[tal].colorChoise.ToString() + " farve";
            }
            else
            {
                tal          = rand.Next(0, 4);
                userMessage += "Det er spiller nr " + (tal + 1) + " der starter med " + player[tal].colorChoise.ToString() + " farve";
            }


            //moveControl(player[tal].colorChoise, pieces);
            return(userMessage);
        }