Пример #1
0
        private void dlgTerrainGen_Load(object sender, EventArgs e)
        {
            MapGenerators.Init();
            cmbMapGenSel.Items.Clear();
            Dictionary <string, string> items = MapGenerators.GetList();

            foreach (KeyValuePair <string, string> k in items)
            {
                cmbMapGenSel.Items.Add(k);
            }
        }
Пример #2
0
 private void cmbMapGenSel_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbMapGenSel.SelectedItem != null)
     {
         pgMapGen.SelectedObject = MapGenerators.Get(((KeyValuePair <string, string>)cmbMapGenSel.SelectedItem).Key, mh.RandomSeed, mMaterials);
         LockCheckboxes(false);
     }
     else
     {
         LockCheckboxes(true);
     }
     ResetEverything();
 }
Пример #3
0
    private void Start()
    {
        _bitMap  = MapGenerators.Circle(Width, Height, 15, new Vector2(Width / 4, Height / 2));
        _bitMap  = MapGenerators.Circle(Width, Height, 15, new Vector2(Width * 3 / 4, Height / 2), _bitMap);
        _dirtMap = new GameObject[Width, Height];

        //Set the bitmap to true, would load some pre config or generate in practice.

        /*
         * for (int i = 0; i < Width; i++)
         * {
         *  for (int j = 0; j < Height; j++)
         *  {
         *      _bitMap[i,j] = true;
         *  }
         * }*/

        // Draw the squares based on the bitmap.
        for (int i = 0; i < Width; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                _dirtMap[i, j] = Instantiate(DirtPrefab, this.transform);
                _dirtMap[i, j].transform.localPosition =
                    new Vector2(i * PixelWidth, -j * PixelHeight);
                _dirtMap[i, j].transform.localScale =
                    new Vector3(PixelWidth, PixelHeight, 0);
                var dirt = _dirtMap[i, j].GetComponent <Dirt>();
                dirt.Map       = this;
                dirt.MapIndexA = i;
                dirt.MapIndexB = j;
                _dirtMap[i, j].GetComponent <SpriteRenderer>().sprite =
                    DirtSprites[Random.Range(0, DirtSprites.Length)];
            }
        }

        for (int i = 0; i < Width; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                if (!_bitMap[i, j])
                {
                    RemoveDirt(i, j);
                }
            }
        }
    }