コード例 #1
0
        private void CreateHotbar()
        {
            // Assign Images
            string[] spellImages = new string[20];
            string[] spells      = new string[20] {
                "", "", "", "", "", "", "", "", "", "Increase_Mana_Regen", "Burn", "Storm",
                "Dust_Cloud", "Turn_Enemy", "Heal", "Conjure_Wall", "Summon_Warrior",
                "Summon_Archer", "Summon_Mage", "Increase_Max_Mana"
            };
            string[] spellNames = new string[20] {
                "Upgrade Burn", "Upgrade Storm", "Upgrade Dust Cloud", "Upgrade Turn Enemy", "Upgrade Heal",
                "Upgrade Conjure Wall", "Upgrade Summon Warrior", "Upgrade Summon Archer",
                "Upgrade Summon Mage", "Increase Mana Regen", "Burn", "Storm", "Dust Cloud", "Turn Enemy",
                "Heal", "Conjure Wall", "Summon Warrior", "Summon Archer", "Summon Mage", "Increase Max Mana"
            };

            string spellpaths = @"images\Spells\";

            for (byte i = 0; i <= 8; i++)
            {
                spells[i] = "Upgrade_Spell";
            }
            for (byte i = 0; i < spells.Length; i++)
            {
                spellImages[i] = spellpaths + spells[i];
            }

            // Assign Spells
            for (int i = 0; i <= 8; i++)
            {
                SpellAssignments[i] = new Spell.UpgradeSpell(this);
            }

            SpellAssignments[9]  = new Spell.IncreaseManaRegen(this);
            SpellAssignments[10] = new Spell.Burn(this);
            SpellAssignments[11] = new Spell.Storm(this);
            SpellAssignments[12] = new Spell.DustCloud(this);
            SpellAssignments[13] = new Spell.TurnEnemy(this);
            SpellAssignments[14] = new Spell.Heal(this);
            SpellAssignments[15] = new Spell.ConjureWall(this);
            SpellAssignments[16] = new Spell.SummonWarrior(this);
            SpellAssignments[17] = new Spell.SummonArcher(this);
            SpellAssignments[18] = new Spell.SummonMage(this);
            SpellAssignments[19] = new Spell.IncreaseMaxMana(this);


            // Create Buttons
            foreach (SpellButton sb in SpellButtons)
            {
                GameObjects.Remove(sb);
            }

            for (int i = 1; i <= 2; i++)
            {
                for (int j = 0; j <= 9; j++)
                {
                    int listSelection = j + ((i - 1) * 9) + (i - 1);
                    SpellButtons[listSelection] =
                        new SpellButton(this, spellNames[listSelection],
                                        ((GameArea.Width / 10) * j) + ((TotalWindowArea.Width / 2) - (GameArea.Width / 2)),
                                        (GameArea.Height - (GameArea.Width / 10) * i) + ((TotalWindowArea.Height / 2) - ((GameArea.Height / 2))),
                                        new List <string>()
                    {
                        spellImages[listSelection] + ".jpg"
                    }, spellImages[listSelection] + "_Selected.jpg",
                                        hotkeys[listSelection],
                                        SpellAssignments[listSelection]);
                }
            }

            // If a spell cost is more than the current MaxMana, hide that spell's button
            foreach (SpellButton sb in this.SpellButtons)
            {
                if (sb.Spell.GetManaCost() > this.maxMana)
                {
                    sb.Hide();
                }
            }
        }
コード例 #2
0
        private void CreateHotbar()
        {
            // Assign Images
            string[] spellImages = new string[20];
            string[] spells = new string[20] { "", "", "", "", "", "", "", "", "", "Increase_Mana_Regen", "Burn", "Storm",
                                               "Dust_Cloud", "Turn_Enemy", "Heal", "Conjure_Wall", "Summon_Warrior",
                                               "Summon_Archer", "Summon_Mage", "Increase_Max_Mana" };
            string[] spellNames = new string[20] {"Upgrade Burn", "Upgrade Storm", "Upgrade Dust Cloud", "Upgrade Turn Enemy", "Upgrade Heal",
                                                  "Upgrade Conjure Wall", "Upgrade Summon Warrior", "Upgrade Summon Archer",
                                                  "Upgrade Summon Mage", "Increase Mana Regen", "Burn", "Storm", "Dust Cloud", "Turn Enemy",
                                                  "Heal", "Conjure Wall", "Summon Warrior", "Summon Archer", "Summon Mage", "Increase Max Mana"};

            string spellpaths = @"images\Spells\";
            for (byte i = 0; i <= 8; i++)
                spells[i] = "Upgrade_Spell";
            for (byte i = 0; i < spells.Length; i++)
                spellImages[i] = spellpaths + spells[i];

            // Assign Spells
            for (int i = 0; i <= 8; i++)
                SpellAssignments[i] = new Spell.UpgradeSpell(this);

            SpellAssignments[9] = new Spell.IncreaseManaRegen(this);
            SpellAssignments[10] = new Spell.Burn(this);
            SpellAssignments[11] = new Spell.Storm(this);
            SpellAssignments[12] = new Spell.DustCloud(this);
            SpellAssignments[13] = new Spell.TurnEnemy(this);
            SpellAssignments[14] = new Spell.Heal(this);
            SpellAssignments[15] = new Spell.ConjureWall(this);
            SpellAssignments[16] = new Spell.SummonWarrior(this);
            SpellAssignments[17] = new Spell.SummonArcher(this);
            SpellAssignments[18] = new Spell.SummonMage(this);
            SpellAssignments[19] = new Spell.IncreaseMaxMana(this);

            // Create Buttons
            foreach (SpellButton sb in SpellButtons)
                GameObjects.Remove(sb);

            for (int i = 1; i <= 2; i++)
            {
                for (int j = 0; j <= 9; j++)
                {
                    int listSelection = j + ((i - 1) * 9) + (i - 1);
                    SpellButtons[listSelection] =
                    new SpellButton(this, spellNames[listSelection],
                                    ((GameArea.Width / 10) * j)+((TotalWindowArea.Width/2)-(GameArea.Width/2)),
                                    (GameArea.Height - (GameArea.Width / 10) * i) + ((TotalWindowArea.Height/2)-((GameArea.Height/2))),
                                    new List<string>(){spellImages[listSelection] + ".jpg"}, spellImages[listSelection] + "_Selected.jpg",
                                    hotkeys[listSelection],
                                    SpellAssignments[listSelection]);
                }
            }

            // If a spell cost is more than the current MaxMana, hide that spell's button
            foreach (SpellButton sb in this.SpellButtons)
                if (sb.Spell.GetManaCost() > this.maxMana)
                    sb.Hide();
        }