Beispiel #1
0
        public game(int playersH, int playersAI, int widthIN, int heightIN, bool[][] customGrid = null)
        {
            bool isCustom = customGrid != null;

            width  = widthIN;
            height = heightIN;

            boxes = MatrixOps.CreateMatrix <box>(width, height);
            for (int a = 0; a < height; a++)
            {
                for (int b = 0; b < width; b++)
                {
                    box bx = boxes[a][b];
                    bx.x      = b;
                    bx.y      = a;
                    bx.parent = this;

                    if (isCustom == false)
                    {
                        initAreas(bx, true);
                    }
                    else
                    {
                        initAreas(bx, customGrid[a][b]);
                    }
                }
            }

            addPlayer(playersH, false);
            addPlayer(playersAI, true);
            games.Add(this);
        }
Beispiel #2
0
        public void initAreas(box bx, bool isUsed)
        {
            bx.thisBox = new area(bx)
            {
                isAreaUsedInGame = isUsed
            };

            if ((bx.x - 1) >= 0)
            {
                bx.lineleft = boxes[bx.y][bx.x - 1].lineright;
                bx.lineleft.parents.Add(bx);
            }
            else
            {
                bx.lineleft = new area(bx);
            }


            bx.lineright = new area(bx);

            if ((bx.y - 1) >= 0)
            {
                bx.lineup = boxes[bx.y - 1][bx.x].linedown;
                bx.lineup.parents.Add(bx);
            }
            else
            {
                bx.lineup = new area(bx);
            }

            bx.linedown = new area(bx);

            if (bx.lineleft.isAreaUsedInGame == false)
            {
                bx.lineleft.isAreaUsedInGame = isUsed;
            }
            if (bx.lineright.isAreaUsedInGame == false)
            {
                bx.lineright.isAreaUsedInGame = isUsed;
            }
            if (bx.lineup.isAreaUsedInGame == false)
            {
                bx.lineup.isAreaUsedInGame = isUsed;
            }
            if (bx.linedown.isAreaUsedInGame == false)
            {
                bx.linedown.isAreaUsedInGame = isUsed;
            }
        }
Beispiel #3
0
        private static bool checkAndSetFilledBox(box b, game g)
        {
            //dont check is set so we can change later on if required via abilities or whatever
            if (b.thisBox.isAreaUsedInGame == false)
            {
                return(false);
            }

            if (b.lineup.isSet && b.lineleft.isSet &&
                b.lineright.isSet && b.linedown.isSet)
            {
                b.thisBox.refpanel.BackColor = g.players[0].colour;
                b.thisBox.isSet = true;
                g.players[0].score++;
                return(true);
            }
            return(false);
        }
Beispiel #4
0
 public area(box parentIN)
 {
     parents.Add(parentIN);
     isSet = false;
     isAreaUsedInGame = false;
 }
Beispiel #5
0
        public void initAreas(box bx, bool isUsed)
        {
            bx.thisBox = new area(bx) { isAreaUsedInGame = isUsed };

            if ((bx.x - 1) >= 0)
            {
                bx.lineleft = boxes[bx.y][bx.x - 1].lineright;
                bx.lineleft.parents.Add(bx);
            }
            else
                bx.lineleft = new area(bx);

            bx.lineright = new area(bx);

            if ((bx.y - 1) >= 0)
            {
                bx.lineup = boxes[bx.y - 1][bx.x].linedown;
                bx.lineup.parents.Add(bx);
            }
            else
                bx.lineup = new area(bx);

            bx.linedown = new area(bx);

            if (bx.lineleft.isAreaUsedInGame == false)
                bx.lineleft.isAreaUsedInGame = isUsed;
            if (bx.lineright.isAreaUsedInGame == false)
                bx.lineright.isAreaUsedInGame = isUsed;
            if (bx.lineup.isAreaUsedInGame == false)
                bx.lineup.isAreaUsedInGame = isUsed;
            if (bx.linedown.isAreaUsedInGame == false)
                bx.linedown.isAreaUsedInGame = isUsed;
        }
Beispiel #6
0
        private static bool checkAndSetFilledBox(box b, game g)
        {
            //dont check is set so we can change later on if required via abilities or whatever
            if (b.thisBox.isAreaUsedInGame == false)
                return false;

            if (b.lineup.isSet && b.lineleft.isSet &&
                b.lineright.isSet && b.linedown.isSet)
            {
                b.thisBox.refpanel.BackColor = g.players[0].colour;
                b.thisBox.isSet = true;
                g.players[0].score++;
                return true;
            }
            return false;
        }
Beispiel #7
0
 public area(box parentIN)
 {
     parents.Add(parentIN);
     isSet            = false;
     isAreaUsedInGame = false;
 }