Ejemplo n.º 1
0
        private void InitializePlayers()
        {
            int playersPerSide = (int)Math.Ceiling(Players.Count / 4d);

            BomberGuy[,] playerArray = new BomberGuy[4, playersPerSide];
            int side        = 0;
            int playerCount = 0;

            foreach (BomberGuy p in Players)
            {
                playerArray[side, playerCount] = p;
                if (++side > 3)
                {
                    side = 0;
                    playerCount++;
                }
            }

            CellCoordinates direction = new CellCoordinates(1, 0);
            int             distance  = (int)Math.Floor((double)(_fieldSize - 2) / playersPerSide);
            CellCoordinates currPos   = new CellCoordinates(1, 1);

            for (int i = 0; i < 4; i++)
            {
                if (i == 1)
                {
                    currPos = new CellCoordinates(_fieldSize - 2, 1);
                }
                if (i == 2)
                {
                    currPos = new CellCoordinates(_fieldSize - 2, _fieldSize - 2);
                }
                if (i == 3)
                {
                    currPos = new CellCoordinates(1, _fieldSize - 2);
                }

                for (int j = 0; j < playersPerSide; j++)
                {
                    var p = playerArray[i, j];
                    if (p == null)
                    {
                        continue;
                    }
                    p.Size = new Vector(_pixelsPerUnit * Constants.BomberGuy.REL_SIZE, _pixelsPerUnit * Constants.BomberGuy.REL_SIZE);

                    MakeSpaceAroundPlayer(currPos);

                    p.Position = GetScreenCoordinates(currPos);
                    currPos   += direction * distance;
                }

                direction = direction.RotatedRight;
            }
        }
Ejemplo n.º 2
0
        private void MakeSpaceAroundPlayer(CellCoordinates cellCoordinates)
        {
            var cellContent = this[cellCoordinates];

            if (cellContent != null && cellContent.Destroyable)
            {
                cellContent.Destroy();
            }

            var directionVector = new CellCoordinates(1, 0);

            for (int i = 0; i < 4; i++)
            {
                cellContent = this[cellCoordinates + directionVector];
                if (cellContent != null && cellContent.Destroyable)
                {
                    cellContent.Destroy();
                }
                directionVector = directionVector.RotatedRight;
            }
        }
Ejemplo n.º 3
0
 public Vector GetScreenCoordinates(CellCoordinates cellCoordinates)
 {
     return(new Vector(_widthOffset + cellCoordinates.Column * _pixelsPerUnit, cellCoordinates.Row * _pixelsPerUnit));
 }
Ejemplo n.º 4
0
 public RectbombularThing this[CellCoordinates c]
 {
     get { return(this[c.Row, c.Column]); }
     set { this[c.Row, c.Column] = value; }
 }