Beispiel #1
0
        public void SetLevel(LevelDescription desc)
        {
            GtkHelpers.FlushAllDeferredEvents();

            Destroyed += LevelAnalysisLayout_Destroyed;

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

            LevelDesc = desc;
            LoadAndValidateLevelDesc();

            Solution = LevelManager.ReadLevelSolution(desc.Name);
            if (null == Solution)
            {
                Solution = new LevelSolution();
                Solution.AssumedHandMissileFrequency    = HandMissileFreqency;
                Solution.AssumedHandMissileAvgDamagePct = HandMissileDamantPctAverage;
            }

            TurretSelections = new Dictionary <int, int>();
            RecalculateAllStats();

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

            HBox field = GtkHelpers.ReadOnlyTextField("Level Name", desc.Name);

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

            field = GtkHelpers.ReadOnlyTextField("Lives", desc.Lives.ToString());
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.ReadOnlyTextField("Starting Coins", desc.StartingCoins.ToString());
            Layout.PackStart(field, false, false, 0);
            field.Show();


            field = GtkHelpers.TextEntryField("Hand Missile Frequency (sec)", HandMissileFreqency.ToString(), AssumedFireRatePerSecChanged_Changed, true, GtkHelpers.ValueType.Float);
            Layout.PackStart(field, false, false, 0);
            field.Show();


            field = GtkHelpers.TextEntryField("Hand Missile Average Accuracy Handicap", HandMissileDamantPctAverage.ToString(), AssumedHandMissileAccuracyHandicap_Changed, true, GtkHelpers.ValueType.Float);
            Layout.PackStart(field, false, false, 0);
            field.Show();


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

            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 singleEnemyColumn   = new TreeViewColumn();
            TreeViewColumn maxHPPSColumn       = new TreeViewColumn();
            TreeViewColumn maxDPSColumn        = new TreeViewColumn();
            TreeViewColumn simColumn           = new TreeViewColumn();
            TreeViewColumn turretCostVsMaxCoin = new TreeViewColumn();
            TreeViewColumn issuesColumn        = new TreeViewColumn();


            CellRendererText textCellRenderer = new CellRendererText();

            textCellRenderer.Editable = false;

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

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

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

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

            singleEnemyColumn.PackStart(textCellRenderer, true);
            singleEnemyColumn.Title = "Single Enemy Damage";
            singleEnemyColumn.AddAttribute(textCellRenderer, "text", 4);
            WavesTree.AppendColumn(singleEnemyColumn);

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

            maxHPPSColumn.PackStart(textCellRenderer, true);
            maxHPPSColumn.Title = "Max Hitpoints/s";
            maxHPPSColumn.AddAttribute(textCellRenderer, "text", 5);
            WavesTree.AppendColumn(maxHPPSColumn);

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

            maxDPSColumn.PackStart(textCellRenderer, true);
            maxDPSColumn.Title = "Max DPS overall";
            maxDPSColumn.AddAttribute(textCellRenderer, "text", 6);
            WavesTree.AppendColumn(maxDPSColumn);


            //
            // Add column: Simulated damage / kills
            //

            simColumn.PackStart(textCellRenderer, true);
            simColumn.Title = "Sim damage/kills";
            simColumn.AddAttribute(textCellRenderer, "text", 7);
            WavesTree.AppendColumn(simColumn);


            //
            // Add column: Max coin earned by start of wave
            //


            turretCostVsMaxCoin.PackStart(textCellRenderer, true);
            turretCostVsMaxCoin.Title = "Coin Need/Avail";
            turretCostVsMaxCoin.AddAttribute(textCellRenderer, "text", 8);
            WavesTree.AppendColumn(turretCostVsMaxCoin);

            //
            // Solution save/load
            //


            SaveSolutionColumn = new TreeViewColumn();
            LoadSolutionColumn = new TreeViewColumn();;

            SaveSolutionColumn.PackStart(textCellRenderer, true);
            SaveSolutionColumn.Title = "Save Solution";
            SaveSolutionColumn.AddAttribute(textCellRenderer, "text", 9);
            WavesTree.AppendColumn(SaveSolutionColumn);


            LoadSolutionColumn.PackStart(textCellRenderer, true);
            LoadSolutionColumn.Title = "Load Solution";
            LoadSolutionColumn.AddAttribute(textCellRenderer, "text", 10);
            WavesTree.AppendColumn(LoadSolutionColumn);


            //
            // Add column: Issues
            //


            issuesColumn.PackStart(textCellRenderer, true);
            issuesColumn.Title = "Issues";
            issuesColumn.AddAttribute(textCellRenderer, "markup", 11);
            WavesTree.AppendColumn(issuesColumn);

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


            PopulateTreeWithWaves(desc);


            Table map = GetFieldTable(desc);

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


            //
            // Allowed turrets
            //

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

            AllowedTurretTree = new TreeView();

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


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

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

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

            PopulateTurretTrees(desc);


            Show();
            ShowAll();
        }
Beispiel #2
0
 public static void WriteLevelSolution(string level, LevelSolution solutions)
 {
     WriteObjectToFile <LevelSolution>(LevelToSolutionPath(level), solutions);
 }