Esempio n. 1
0
        public void SetTurret(string selectedStr)
        {
            GtkHelpers.FlushAllDeferredEvents();

            Destroyed += TurretEditLayout_Destroyed;

            if (null != Layout)
            {
                Layout.Hide();
                Layout.Destroy();
                Layout        = null;
                FireRateField = null;
                DPSfield      = null;
            }

            Turrets = LevelManager.GetTurrets();
            for (int i = 0; i < Turrets.Count; i++)
            {
                if (Turrets[i].Name == selectedStr)
                {
                    Turret = Turrets[i];
                }
            }

            Layout = new VBox(false, 0);
            AddWithViewport(Layout);

            HBox field = GtkHelpers.TextEntryField("Turret Name", Turret.Name, Name_Changed, true);

            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Asset", Turret.Asset, Asset_Changed, true);
            Layout.PackStart(field, false, false, 0);
            field.Show();


            FireRateField = GtkHelpers.TextEntryField("Fire Rate", Turret.FireRate.ToString(), FireRate_Changed, true, GtkHelpers.ValueType.Float);
            Layout.PackStart(FireRateField, false, false, 0);
            FireRateField.Show();


            field = GtkHelpers.TextEntryField("Range", Turret.Range.ToString(), Range_Changed, true, GtkHelpers.ValueType.Float);
            Layout.PackStart(field, false, false, 0);
            field.Show();


            field = GtkHelpers.TextEntryField("Cost", Turret.Cost.ToString(), Cost_Changed, true, GtkHelpers.ValueType.Float);
            Layout.PackStart(field, false, false, 0);
            field.Show();


            List <Projectile> projectiles = LevelManager.GetProjectiles();

            ProjectileNames = new List <string>();
            int currIndex = 0;

            for (int i = 0; i < projectiles.Count; i++)
            {
                ProjectileNames.Add(projectiles[i].Name);
                if (projectiles[i].Name == Turret.Projectile)
                {
                    currIndex = i;
                }
            }

            field = GtkHelpers.ComboBox("Projectile", ProjectileNames.ToArray(), currIndex, Projectile_Changed, true);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            DPSfield = GtkHelpers.TextEntryField("Damage per Sec", Turret.Cost.ToString(), DPS_Changed, true, GtkHelpers.ValueType.Float);
            Layout.PackStart(DPSfield, false, false, 0);
            DPSfield.Show();

            RecalculateDPS();

            Show();
            ShowAll();
        }
Esempio n. 2
0
        public void SetLevel(LevelDescription desc)
        {
            GtkHelpers.FlushAllDeferredEvents();

            Destroyed += LevelEditLayout_Destroyed;

            if (null != Layout)
            {
                Layout.Hide();
                Layout.Destroy();
                Layout = null;
            }

            LevelDesc = desc;

            Layout = new VBox(false, 0);
            AddWithViewport(Layout);

            HBox field = GtkHelpers.TextEntryField("Level Name", desc.Name, Name_Changed, true);

            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Lives", desc.Lives.ToString(), Lives_Changed, true, GtkHelpers.ValueType.Int);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.ComboBox("Width", LayoutOptions, (desc.FieldWidth / 5 - 1), Width_Changed, true);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.ComboBox("Depth", LayoutOptions, (desc.FieldDepth / 5 - 1), Depth_Changed, true);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Starting Coins", desc.StartingCoins.ToString(), StartingCoins_Changed, true, GtkHelpers.ValueType.Int);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Description Heading", desc.DescriptionHeading, DescriptionHeading_Changed);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Description Body", desc.DescriptionBody, DescriptionBody_Changed);
            Layout.PackStart(field, false, false, 0);
            field.Show();


            WavesTree = new TreeView();
            Layout.PackStart(WavesTree, false, false, 0);
            WavesTree.Show();

            List <EnemyDescription> enemies  = LevelManager.GetEnemies();
            ComboBoxText            comboBox = new ComboBoxText();

            foreach (EnemyDescription enemy in enemies)
            {
                comboBox.AppendText(enemy.Name);
            }
            comboBox.Active = 0;


            TreeViewColumn enemyCoumn            = new TreeViewColumn();
            TreeViewColumn countColumn           = new TreeViewColumn();
            TreeViewColumn difficultyColumn      = new TreeViewColumn();
            TreeViewColumn descriptionBodyColumn = new TreeViewColumn();

            CellRendererCombo comboCellRenderer = new CellRendererCombo();

            comboCellRenderer.Editable   = true;
            comboCellRenderer.Edited    += ComboCellRenderer_Edited;
            comboCellRenderer.TextColumn = 0;
            comboCellRenderer.HasEntry   = false;

            CellRendererText countCellRenderer = new CellRendererText();

            countCellRenderer.Editable = true;
            countCellRenderer.Edited  += CountCell_Edited;


            CellRendererText difficultyCellRenderer = new CellRendererText();

            difficultyCellRenderer.Editable = true;
            difficultyCellRenderer.Edited  += DifficultyCell_Edited;

            CellRendererText descriptionbodyRenderer = new CellRendererText();

            descriptionbodyRenderer.Editable = true;
            descriptionbodyRenderer.Edited  += DescriptionbodyRenderer_Edited;

            enemyCoumn.PackStart(comboCellRenderer, true);
            enemyCoumn.Title = "Enemy";
            enemyCoumn.AddAttribute(comboCellRenderer, "text", 1);
            WavesTree.AppendColumn(enemyCoumn);

            countColumn.PackStart(countCellRenderer, true);
            countColumn.Title = "Count";
            countColumn.AddAttribute(countCellRenderer, "text", 2);
            WavesTree.AppendColumn(countColumn);

            difficultyColumn.PackStart(difficultyCellRenderer, true);
            difficultyColumn.Title = "Difficulty Multiplier";
            difficultyColumn.AddAttribute(difficultyCellRenderer, "text", 3);
            WavesTree.AppendColumn(difficultyColumn);

            descriptionBodyColumn.PackStart(descriptionbodyRenderer, true);
            descriptionBodyColumn.Title = "Description Body";
            descriptionBodyColumn.AddAttribute(difficultyCellRenderer, "text", 4);
            WavesTree.AppendColumn(descriptionBodyColumn);

            //
            // Add column:  Max damage that can be dished to a single enemy given turret coverage + enemy speed
            //

            //
            // Add column: Max hit points of the wave
            //

            //
            // Add column: Max hit points of all the turrets combined firing at full capacity
            //

            //
            // Add column: Given all the factors, theoretical headroom of DPS
            //

            WavesModel               = new ListStore(typeof(int), typeof(string), typeof(int), typeof(float), typeof(string));
            WavesTree.Model          = WavesModel;
            WavesTree.Selection.Mode = SelectionMode.Single;

            PopulateTreeWithWaves(desc);

            field = new HBox(false, 5);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            Button b = new Button("+");

            b.Clicked += NewWave_Clicked;
            b.Show();
            field.PackStart(b, false, false, 0);

            b          = new Button("-");
            b.Clicked += RemoveWave_Clicked;
            b.Show();
            field.PackStart(b, false, false, 0);


            Table map = GetFieldTable(desc);

            Layout.PackStart(map, false, true, 0);
            map.Show();

            ErrorEntry            = new Entry();
            ErrorEntry.IsEditable = false;
            ErrorEntry.Text       = "No issues";
            Layout.PackStart(ErrorEntry, false, false, 10);
            ErrorEntry.Show();

            ValidateDescriptionAndReportIssues();

            //
            // Allowed turrets
            //

            field = new HBox(true, 10);
            Layout.PackStart(field, true, false, 0);
            field.Show();

            AvailTurretTree   = new TreeView();
            AllowedTurretTree = new TreeView();

            TreeViewColumn availCol   = new TreeViewColumn();
            TreeViewColumn allowedCol = new TreeViewColumn();

            CellRendererText availCellrenderer = new CellRendererText();

            availCellrenderer.Editable = false;

            CellRendererText allowedCellRenderer = new CellRendererText();

            allowedCellRenderer.Editable = false;

            availCol.PackStart(availCellrenderer, true);
            availCol.Title = "Not allowed turrets";
            availCol.AddAttribute(availCellrenderer, "text", 1);
            AvailTurretTree.AppendColumn(availCol);


            allowedCol.PackStart(allowedCellRenderer, true);
            allowedCol.Title = "Allowed Turrets";
            allowedCol.AddAttribute(allowedCellRenderer, "text", 1);
            AllowedTurretTree.AppendColumn(allowedCol);

            AvailTurretModel               = new ListStore(typeof(int), typeof(string));
            AvailTurretTree.Model          = AvailTurretModel;
            AvailTurretTree.Selection.Mode = SelectionMode.Multiple;

            AllowedTurretModel               = new ListStore(typeof(int), typeof(string));
            AllowedTurretTree.Model          = AllowedTurretModel;
            AllowedTurretTree.Selection.Mode = SelectionMode.Multiple;

            field.PackStart(AvailTurretTree, true, true, 0);
            AvailTurretTree.Show();

            VBox turretButtons = new VBox(true, 0);

            field.PackStart(turretButtons, true, true, 0);
            turretButtons.Show();

            b = new Button(">>");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += AddAllTurrets_Clicked;
            b.Show();

            b = new Button(">");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += AddSelectedTurrets_Clicked;
            b.Show();

            b = new Button("<");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += RemoveSelectedTurrets_Clicked;
            b.Show();

            b = new Button("<<");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += RemoveAllTurrets_Clicked;
            b.Show();

            field.PackEnd(AllowedTurretTree, true, true, 0);
            AllowedTurretTree.Show();

            PopulateTurretTrees(desc);


            Show();
            ShowAll();
        }