コード例 #1
0
 public void Clear()
 {
     for (int i = 0; i < mapElementPlacesParent.childCount; i++)
     {
         CreateMapElementOnIt cme = mapElementPlacesParent.GetChild(i).GetComponent <CreateMapElementOnIt>();
         cme.ElementOnIt = false;
     }
 }
コード例 #2
0
    void Start()
    {
        map = new CreateMapElementOnIt[RowCount, ColumnCount];

        for (int i = 0; i < RowCount + 1; i++)
        {
            GameObject   webLine         = Instantiate(line.gameObject, linesParent);
            LineRenderer webLineRenderer = webLine.GetComponent <LineRenderer>();
            webLineRenderer.positionCount = 2;
            Vector3 start = StartPosition + new Vector3(0, 0, -i * SharedData.widhtUnit);
            Vector3 end   = StartPosition + new Vector3(ColumnCount * SharedData.widhtUnit, 0, -i * SharedData.widhtUnit);
            webLineRenderer.SetPosition(0, start);
            webLineRenderer.SetPosition(1, end);
        }
        for (int i = 0; i < ColumnCount + 1; i++)
        {
            GameObject   webLine         = Instantiate(line.gameObject, linesParent);
            LineRenderer webLineRenderer = webLine.GetComponent <LineRenderer>();
            webLineRenderer.positionCount = 2;
            Vector3 start = StartPosition + new Vector3(i * SharedData.widhtUnit, 0, 0);
            Vector3 end   = StartPosition + new Vector3(i * SharedData.widhtUnit, 0, -RowCount * SharedData.widhtUnit);
            webLineRenderer.SetPosition(0, start);
            webLineRenderer.SetPosition(1, end);
        }
        for (int i = 0; i < RowCount; i++)
        {
            for (int j = 0; j < ColumnCount; j++)
            {
                Vector3              location         = StartPosition + new Vector3(j * SharedData.widhtUnit + SharedData.widhtUnit / 2, 0, -i * SharedData.widhtUnit - SharedData.widhtUnit / 2);
                GameObject           mapElement       = Instantiate(MapElementPlace.gameObject, location, Quaternion.identity, mapElementPlacesParent);
                CreateMapElementOnIt mapElementScript = mapElement.GetComponent <CreateMapElementOnIt>();
                map[i, j]               = mapElementScript;
                mapElementScript.Row    = i;
                mapElementScript.Column = j;
                if (i == 0 || i == RowCount - 1)
                {
                    mapElementScript.edgeMapElementPlace = true;
                }
            }
        }
    }