Beispiel #1
0
    //Perhaps we add a list of the players on the map.

    public Grid(int rows, int columns)
    {
        if (rows < 3 || columns < 3)
        {
            Debug.LogError("Dimensions for the grid are too small");
            return;
        }
        numCols = columns;
        numRows = rows;
        grid    = new SyncListStruct <Cell>();
        for (int i = 0; i < rows; i++)   //Floor everywhere else
        {
            for (int j = 0; j < columns; j++)
            {
                if (i == 0 || j == 0 || i == rows - 1 || j == columns - 1)
                {
                    grid.Add(new Cell(true));
                }
                else
                {
                    grid.Add(new  Cell(false));
                }
            }
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        if (isServer)
        {
            MinMaxCubeWidth  = SanitizeMinMax(MinMaxCubeWidth);
            MinMaxCubeHeight = SanitizeMinMax(MinMaxCubeHeight);

            for (int n = 0; n < NumberOfCubes; n++)
            {
                //get together all our variables used to place the cubes
                float l     = Random.Range(-length / 2, length / 2);
                float phi   = Random.Range(0, 180);
                float theta = phi % 60 + Mathf.Floor(phi / 60) * 120;
                theta += Offset;
                Vector3 scale  = new Vector3(Random.Range(MinMaxCubeWidth.x, MinMaxCubeWidth.y), Random.Range(MinMaxCubeHeight.x, MinMaxCubeHeight.y), Random.Range(MinMaxCubeWidth.x, MinMaxCubeWidth.y));
                Vector3 coords = RadialToCartesian(l, theta, radius, scale.y);


                //network instantiate
                GameObject g = (GameObject)Instantiate(TerrainCube, coords, Quaternion.Euler(theta, 0, 0));
                g.transform.localScale = scale;
                g.transform.parent     = transform;
                //NetworkServer.Spawn(g);

                RandomCube cube = new RandomCube();
                cube.obj = g;
                CubeList.Add(cube);
                Debug.Log(n);
            }
        }
        //Network.Instantiate(TerrainCube, transform.position, Quaternion.Euler(0, 0, 0), 0);
    }
Beispiel #3
0
 public static void _Add <T>(this SyncListStruct <T> sl, string key, object obj)
     where T : struct
 {
     sl.Add(CreateInstance <T>(key, obj));
 }