示例#1
0
    private void UpdatePositionMapForNewPiecesPosition(int lineLimit, int playerId)
    {
        for (int i = 0; i < this.PlayersPositionMap[playerId].GetLength(0); i++)
        {
            if (i < lineLimit)
            {
                continue;
            }

            for (int j = 0; j < this.PlayersPositionMap[playerId].GetLength(1); j++)
            {
                PositionMapElement currentElement = this.PlayersPositionMap[playerId][i, j];

                if (currentElement.IsOccupied && currentElement.CurrentMapElement != null)
                {
                    //Update the below element
                    this.PlayersPositionMap[playerId][i - 1, j].CurrentMapElement = currentElement.CurrentMapElement;
                    this.PlayersPositionMap[playerId][i - 1, j].IsOccupied        = true;

                    //initialise current element
                    currentElement.IsOccupied        = false;
                    currentElement.CurrentMapElement = null;
                }
            }
        }
    }
示例#2
0
 private void UpdateSuppressedLinesInPositionMap(int lineLimit, int playerId)
 {
     //for every column in the map
     for (int j = 0; j < this.PlayersPositionMap[playerId].GetLength(1); j++)
     {
         PositionMapElement currentElement = this.PlayersPositionMap[playerId][lineLimit, j];
         //initialise current element
         currentElement.IsOccupied        = false;
         currentElement.CurrentMapElement = null;
     }
 }
示例#3
0
    public static void WriteMapContentOnConsole(PositionMapElement[,] positionMap)
    {
        String line = "";

        for (int k = positionMap.GetLength(0) - 1; k >= 0; k--)
        {
            String lineNumber = "";

            if (k.ToString().Length == 1)
            {
                lineNumber = 0 + k.ToString() + ",";
            }
            else
            {
                lineNumber = k.ToString() + ",";
            }

            line += lineNumber;

            for (int l = 0; l < positionMap.GetLength(1); l++)
            {
                PositionMapElement currentElement = positionMap[k, l];

                if (currentElement.IsOccupied)
                {
                    line += "O";
                }
                else
                {
                    line += "X";
                }

                if (l == positionMap.GetLength(1) - 1)
                {
                    line += (";" + Environment.NewLine);
                }
                else
                {
                    line += ",";
                }
            }
        }

        Debug.Log(line);
    }