Esempio n. 1
0
        void PlaceTree(ProgressBar bar)
        {
            bar.Reset();
            bar.SetText("Spawn Tree and cactus");
            bar.SetMaxValue(_vectree.Count);
            foreach (Vector2 vec in _vectree)
            {
                if (ReferenceEquals(MapBiomes[(int)vec.X], ArrayResource.Desrt))
                {
                    var height = Rand.Next(2, 5);
                    for (var i = 0; i < height; i++)
                    {
                        SetTexture((int)vec.X, (int)vec.Y - i, 28);
                    }

                    SetTexture((int)vec.X, (int)vec.Y - height, 28, 1);
                }
                else
                {
                    AddTree((int)vec.X, (int)vec.Y);
                }

                bar.Add(1);
            }

            if (Program.Game.CurrentDimension != 1)
            {
                StructuresList.Add(new Home(0, MapHeight[5], true));
            }
        }
Esempio n. 2
0
        void GeneratorCaves(int i)
        {
            for (var j = SizeGeneratior.RockLayer; j < SizeGeneratior.WorldHeight; j++)
            {
                var airspawn = Rand.Next(0, 800);

                if (airspawn == 0 && Program.Game.CurrentDimension != 1)
                {
                    StructuresList.Add(new Caves(i, j));
                }
            }
        }
Esempio n. 3
0
        private void SelfParse()
        {
            string comment = "";

            for (int index = 0; index < TextData.Count; index++)
            {
                var line = TextData[index];
                if (line.TrimStart().StartsWith("///"))
                {
                    comment += line;
                    continue;
                }
                var match = RegexHelpers.MethodRegex.Match(line);
                if (match.Success) // method found
                {
                    int brackets = line.Count(x => x == '{') - line.Count(x => x == '}');
                    int j        = index + 1;
                    do
                    {
                        line      = TextData[j];
                        brackets += line.Count(x => x == '{');
                        brackets -= line.Count(x => x == '}');
                        j++;
                    } while (j < TextData.Count && brackets > 0);
                    index = j;
                    var data = new MethodData(match.Value, comment, header.FullName);
                    StructuresList.Add(data);
                    comment = "";
                }
                match = RegexHelpers.PropertyRegex.Match(line);
                if (match.Success)
                {
                    int brackets = line.Count(x => x == '{') - line.Count(x => x == '}'); int j = index + 1;
                    do
                    {
                        line      = TextData[j];
                        brackets += line.Count(x => x == '{');
                        brackets -= line.Count(x => x == '}');
                        j++;
                    } while (j < TextData.Count && brackets > 0);
                    index = j;
                    var data = new PropertyData(match.Value, comment);
                    StructuresList.Add(data);
                    comment = "";
                }
            }
            TextData = null;
        }
Esempio n. 4
0
        void GeneratorHomeAndFactory(ProgressBar bar, int i)
        {
            if (i + 9 >= SizeGeneratior.WorldWidth || MapHeight[i] != MapHeight[i + 9])
            {
                return;
            }

            if (Rand.Next(0, 20) == 0 && ReferenceEquals(MapBiomes[i], ArrayResource.Grass) ||
                Rand.Next(0, 60) == 0 && ReferenceEquals(MapBiomes[i], ArrayResource.Desrt)
                )
            {
                if (StructuresList.Count >= 1)
                {
                    var test = false;
                    for (var structureId = StructuresList.Count - 1; structureId > 0; structureId--)
                    {
                        if (!(StructuresList[structureId] is Home home))
                        {
                            continue;
                        }

                        test = true;
                        if (i > home.X + 15)
                        {
                            StructuresList.Add(new Home(i, MapHeight[i]));
                        }
                        break;
                    }

                    if (!test)
                    {
                        StructuresList.Add(new Home(i, MapHeight[i]));
                    }
                }
                else if (i > 15)
                {
                    StructuresList.Add(new Home(i, MapHeight[i]));
                }
            }
            else if (Program.Game.CurrentDimension == 0 && Rand.NextDouble() <= 0.5f)
            {
                if (_factory == null && i >= 40 && i < SizeGeneratior.WorldWidth - 40)
                {
                    _factory = new Factory(i, MapHeight[i]);
                }
            }
        }