示例#1
0
    /// <summary>
    /// Create a new board size WxH
    /// </summary>
    /// <param name="w">The width.</param>
    /// <param name="h">The height.</param>
    public void NewBoard(int w, int h)
    {
        hexPoints.Clear();

        width  = w;
        height = h;

        hexPoints = new List <HexPoint>(width * height);

        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                HexPoint point = Instantiate(hexPointModel.gameObject).GetComponent <HexPoint>();

                point.SetParentBoard(this);
                point.SetPoint(j, i);

                hexPoints.Add(point);
            }
        }

        hexPoints.TrimExcess();
    }