Ejemplo n.º 1
0
        private void buttonGenerateWorld_Click(object sender, EventArgs e)
        {
            int x = Int32.Parse(textBoxWorldX.Text);
            int y = Int32.Parse(textBoxWorldY.Text);

            WorldGen = WorldsGenerator.GetDefault(y, x);

            var world = WorldGen.GetWorld();

            SetWorld(world);
            _render.UpdateBackgroundImage(world);

            SetPaused(true);
        }
        public MainForm()
        {
            InitializeComponent();

            WorldGen           = WorldsGenerator.GetDefault(64, 64);
            textBoxWorldX.Text = "64";
            textBoxWorldY.Text = "64";

            SetWorld(WorldGen.GetWorld());

            _gfx = Graphics.FromImage(image);

            UpdateDrawMode();
        }
Ejemplo n.º 3
0
        public MainForm()
        {
            InitializeComponent();

            WorldGen           = WorldsGenerator.GetDefault(64, 64);
            textBoxWorldX.Text = "64";
            textBoxWorldY.Text = "64";

            SetWorld(WorldGen.GetWorld());


            _render.UpdateBackgroundImage(World);
            UpdateDrawMode();
            pictureBox1.Image = _render.GetImage();
        }
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.PrepareView);
     _somethingButton      = FindViewById <Button>(Resource.Id.doSomethingButton);
     _rowsSeekBar          = FindViewById <SeekBar>(Resource.Id.rowsSeekBar);
     _rankSeekBar          = FindViewById <SeekBar>(Resource.Id.rankSeekBar);
     _totalUnitsEditText   = FindViewById <TextView>(Resource.Id.totalUnits);
     _totalInSquadEditText = FindViewById <TextView>(Resource.Id.totalInSquad);
     _rowText     = FindViewById <TextView>(Resource.Id.rowText);
     _rankText    = FindViewById <TextView>(Resource.Id.rankText);
     _topLayout   = FindViewById <LinearLayout>(Resource.Id.topLayout);
     _cocosLayout = FindViewById <LinearLayout>(Resource.Id.cocosLayout);
     _spinner     = FindViewById <Spinner>(Resource.Id.squadTypeSpinner);
     _view        = new MyView(_cocosLayout.Context);
     _cocosLayout.AddView(_view);
     _rowsSeekBar.Max              = 15;
     _rankSeekBar.Max              = 15;
     _rowsSeekBar.ProgressChanged += _rankSeekBar_ProgressChanged;
     _rankSeekBar.ProgressChanged += _rankSeekBar_ProgressChanged;
     _somethingButton.Click       += _somethingButton_Click;
     _totalInSquadEditText.Text    = (_rankSeekBar.Progress * _rowsSeekBar.Progress).ToString();
     _totalUnitsEditText.Text      = _view.Army.Size.ToString();
     Forms.Init(this, savedInstanceState);
     if (Intent.GetBooleanExtra("ISLOAD", false))
     {
         WorldGen = WorldsGenerator.GetDefault(MyView.SIZE * 3 / 2, MyView.SIZE);
         if (WorldGen.GetWorld().Width != MyView.SIZE)
         {
             WorldGen = null;
         }
         else
         {
             try
             {
                 WorldGen.LoadUnitsFromFile("units.units", true);
             }
             catch
             {
                 WorldGen = null;
             }
         }
     }
     _view.Touch += _view_Touch;
 }
        public static WorldsGenerator LoadTerrainFromFile(string fname, bool android = false)
        {
            if (android)
            {
                var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                fname = Path.Combine(path, fname);
            }

            var lines = System.IO.File.ReadAllLines(fname, Encoding.Unicode);

            var width  = lines[0].Length;
            var height = lines.Length;

            var WorldGen = WorldsGenerator.GetDefault(height, width);
            var World    = WorldGen.GetWorld();

            int x = 0;

            foreach (var line in lines)
            {
                int y = 0;
                if (x >= World.Width)
                {
                    break;
                }

                foreach (var c in line)
                {
                    if (y >= World.Length)
                    {
                        break;
                    }

                    if (c == 'm')
                    {
                        World.Terrain[x, y] = 1;
                    }
                    y++;
                }
                x++;
            }

            return(WorldGen);
        }
Ejemplo n.º 6
0
        public IWorld GenerateWorld()
        {
            var generator = WorldsGenerator.GetDefault(MyView.SIZE * 3 / 2, MyView.SIZE);

            foreach (var s in _squads)
            {
                for (var x = s.MinX; x < s.MaxX; x++)
                {
                    for (var y = s.MinY; y < s.MaxY; y++)
                    {
                        generator.CreateUnit(s.Type, s.Team, y + MyView.SIZE / 2, x);
                    }
                }
            }

            GenerateEnemies(generator);

            return(generator.GetWorld());
        }
        private void buttonGenerateWorld_Click(object sender, EventArgs e)
        {
            int x = Int32.Parse(textBoxWorldX.Text);
            int y = Int32.Parse(textBoxWorldY.Text);

            if (comboBoxPreset.SelectedIndex == -1)
            {
                WorldGen = WorldsGenerator.GetDefault(y, x);
            }
            else
            {
                WorldGen = WorldsGenerator.CreatePreset(y, x);
            }

            var world = WorldGen.GetWorld();

            SetWorld(world);
            SetPaused(true);
        }