public void SetArmy(BaseArmy army)
 {
     if (army != null)
     {
         RegimentHandler.SetArmy(army);
     }
 }
 public void SetArmy(BaseArmy army)
 {
     if (army.soldiers.Count > 0)
     {
         this.army = army;
         CreateArmy();
         int y = 0;
         for (int p = 0; p < numbersOfSoldiersButtons.Count; p++)
         {
             numbersOfSoldiersButtons[p].mainRec.Y = (textPos + 180 + ((y / 2) * 25));
             y++;
         }
         regiment = new Regiment();
         regiment.AppointSoldier(army.soldiers[0]);
     }
 }
        public void SetRegiment(Regiment regiment)
        {
            this.regiment = regiment;
            equipmentbuttonHandler.UpdateShow(regiment.GetEquipment(), this.regiment.ReturnType());
            army = armies[regiment.GetSoldier().GetArmy()];
            typeOfUnitButtons = new List <MarkButton>();
            for (int p = 0; p < army.SizeOfArmy(); p++)
            {
                typeOfUnitButtons.Add(new MarkButton(markButton, 2, 1, 120, 100 + (20 * p), army.soldiers[p].Name(), clickSound));
                if (regiment.GetSoldier().Name() == typeOfUnitButtons[p].Text())
                {
                    typeOfUnitButtons[p].turnOn();
                }
            }
            textPos = typeOfUnitButtons[typeOfUnitButtons.Count - 1].mainRec.Y + 60;
            int y = 0;

            for (int p = 0; p < numbersOfSoldiersButtons.Count; p++)
            {
                numbersOfSoldiersButtons[p].mainRec.Y = (textPos + 180 + ((y / 2) * 25));
                y++;
            }
            pressedWeaponsButtons = new List <int>();
        }
        public RegimentHandler(Texture2D markButton, Texture2D armyButtons, Texture2D soldierRegulateButton, SpriteFont font, string loadPath, Texture2D decoration,
                               Texture2D show, SoundEffect bookSound, SoundEffect crystalSound, SoundEffect horseSound, SoundEffect clickSound, SoundEffect swordSound,
                               SoundEffect arrowSound, Texture2D lineTexture, SoundEffect hireRegiment, Vector2 screenSize, Texture2D magic, Texture2D upDown, Texture2D mark,
                               int buttonPosition, int cutoff, int yStartPosMagic, int yCuttOff, Texture2D magicSymbol, SoundEffect doot, Texture2D dootTexture, int markButtonStartPos)
        {
            this.screenSize          = screenSize;
            random                   = new Random();
            this.dootTexture         = dootTexture;
            this.dootSound           = doot;
            state                    = EquipmentState.equipment;
            scale                    = 0.75f;
            this.clickSound          = clickSound;
            this.bookSound           = bookSound;
            texthandler              = new TextHandler();
            this.font                = font;
            this.markButton          = markButton;
            armiesButtons            = new List <Button>();
            numbersOfSoldiersButtons = new List <NumberOfSoldierButton>();
            equipmentbuttonHandler   = new MarkButtonHandler(markButton, show, horseSound, clickSound, swordSound, arrowSound, screenSize, font, buttonPosition, cutoff,
                                                             (int)screenSize.X / 2 + 20, markButtonStartPos);

            spellHandler = new Spells(font, magic, magicSymbol, armyButtons, upDown, mark, clickSound, bookSound, crystalSound, (int)screenSize.X / 2 + 20, yStartPosMagic, yCuttOff);

            armies = new List <BaseArmy>();
            armies.Add(new Beastmen());
            armies.Add(new Centaur());
            armies.Add(new Creatures());
            armies.Add(new Demon());
            armies.Add(new Dryads());
            armies.Add(new Dwarf());
            armies.Add(new Elf());
            armies.Add(new Goblins());
            armies.Add(new Halfling());
            armies.Add(new Hobgoblin());
            armies.Add(new Human());
            armies.Add(new Lizardmen());
            armies.Add(new Ogre());
            armies.Add(new Orc());
            armies.Add(new Ratmen());
            armies.Add(new Barbarians());
            armies.Add(new Undead());
            pressedWeaponsButtons = new List <int>();
            itemAdder             = new ItemAdder();
            int y = 0;
            int x = 0;

            for (int i = 0; i < armies.Count; i++)
            {
                armiesButtons.Add(new Button(armyButtons, 1, 2, (int)screenSize.X / 2 + 20 + ((armyButtons.Width / 2 * x) + (5 * x)), equipmentbuttonHandler.NumberOfLines() + (armyButtons.Height * y) + (5 * y), font, armies[i].name, bookSound));
                if (armiesButtons[i].mainRec.X + (5 * (x)) + armiesButtons[i].mainRec.Width > cutoff)
                {
                    x = 0;
                    y++;
                }
                else
                {
                    x++;
                }
            }
            endTheThing       = new Button(armyButtons, 1, 2, 110, buttonPosition, font, "Add Regiment", hireRegiment);
            spellBTN          = new Button(armyButtons, 1, 2, 510, buttonPosition, font, "Spells", bookSound);
            equipmentBTN      = new Button(armyButtons, 1, 2, 510, buttonPosition, font, "Equipment", bookSound);
            regiment          = new Regiment();
            typeOfUnitButtons = new List <MarkButton>();
            army = new BaseArmy();
            Equipment equipmentinput = new Equipment();

            ChosenUnit = "";
            numbersOfSoldiersButtons.Add(new NumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 0 + 120), (25 * 1), font, 1, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;
            numbersOfSoldiersButtons.Add(new NumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 1 + 120), (25 * 1), font, 10, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;
            numbersOfSoldiersButtons.Add(new NumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 2 + 120), (25 * 1), font, 20, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;
            numbersOfSoldiersButtons.Add(new RoundUpNumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 3 + 120), (25 * 1), font, 1, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;

            numbersOfSoldiersButtons.Add(new NumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 0 + 120), (25 * 2), font, -1, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;
            numbersOfSoldiersButtons.Add(new NumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 1 + 120), (25 * 2), font, -10, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;
            numbersOfSoldiersButtons.Add(new NumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 2 + 120), (25 * 2), font, -20, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;
            numbersOfSoldiersButtons.Add(new RoundUpNumberOfSoldierButton(soldierRegulateButton, 2, 4, (25 * 3 + 120), (25 * 2), font, -1, crystalSound));
            numbersOfSoldiersButtons[numbersOfSoldiersButtons.Count - 1].currentFrame = numbersOfSoldiersButtons.Count - 1;
            equipmentbuttonHandler.CheckCanSee(regiment.ReturnType());
        }
        public void Update(MouseState mousestate, MouseState oldMosueState, string path)
        {
            if (state == EquipmentState.equipment)
            {
                if (equipmentbuttonHandler.Update(mousestate, oldMosueState, regiment.ReturnType()))
                {
                    if (equipmentbuttonHandler.RemoveItem())
                    {
                        regiment.RemoveEquipment(equipmentbuttonHandler.GetEquipment());
                    }
                    else
                    {
                        regiment.SetEquipment(equipmentbuttonHandler.GetEquipment());
                    }
                    equipmentbuttonHandler.UpdateShow(regiment.GetEquipment(), regiment.GetSoldier());
                    regiment.SetCost((regiment.ReturnType().GetCost() * regiment.GetNumberOfSoldiers()) + regiment.ReturnType().GetOneTimeCost() + regiment.ReturnType().GetArcherPlatformCost(regiment.GetNumberOfSoldiers()));
                }
                for (int i = 0; i < armiesButtons.Count; i++)
                {
                    armiesButtons[i].Update(mousestate, oldMosueState);
                    if (armiesButtons[i].pressed == true)
                    {
                        if (armies[i].soldiers.Count > 0)
                        {
                            army = armies[i];
                            CreateArmy();
                            int y = 0;
                            for (int p = 0; p < numbersOfSoldiersButtons.Count; p++)
                            {
                                if (p >= numbersOfSoldiersButtons.Count / 2)
                                {
                                    y = 1;
                                }
                                numbersOfSoldiersButtons[p].mainRec.Y = (textPos + 200 + (y * 25));
                            }
                            equipmentbuttonHandler.CheckCanSee(army.soldiers[0]);
                        }
                        else
                        {
                            army = armies[i];
                            CreateArmy();
                            int y = 0;
                            for (int p = 0; p < numbersOfSoldiersButtons.Count; p++)
                            {
                                numbersOfSoldiersButtons[p].mainRec.Y = (textPos + 190 + (y * 25));
                                if (p >= numbersOfSoldiersButtons.Count / 2)
                                {
                                    y = 1;
                                }
                            }
                            equipmentbuttonHandler.CheckCanSee(army.soldiers[0]);
                        }
                        regiment.SetCost((regiment.ReturnType().GetCost() * regiment.GetNumberOfSoldiers()) + regiment.ReturnType().GetOneTimeCost() + regiment.ReturnType().GetArcherPlatformCost(regiment.GetNumberOfSoldiers()));
                    }
                }
            }
            else if (state == EquipmentState.spells)
            {
                spellHandler.Update(mousestate, oldMosueState);
                if (spellHandler.Pressed())
                {
                    regiment.AddSpell(spellHandler.GetSpells());
                    spellHandler.reset(regiment.GetSpellList());
                }
            }
            if (regiment.ReturnType() is BaseUnit)
            {
                endTheThing.Update(mousestate, oldMosueState);
                if (state == EquipmentState.equipment)
                {
                    if (regiment.ReturnType().IsSpellcaster())
                    {
                        spellBTN.Update(mousestate, oldMosueState);
                        if (spellBTN.pressed)
                        {
                            state = EquipmentState.spells;
                        }
                    }
                }
                else if (state == EquipmentState.spells)
                {
                    equipmentBTN.Update(mousestate, oldMosueState);
                    if (equipmentBTN.pressed)
                    {
                        state = EquipmentState.equipment;
                    }
                }
            }

            UpdateButton(typeOfUnitButtons, mousestate, oldMosueState);
            for (int i = 0; i < typeOfUnitButtons.Count; i++)
            {
                if (typeOfUnitButtons[i].pressed == true)
                {
                    if (army.soldiers.Count > 0)
                    {
                        typeOfUnitButtons[i].Sound();
                        regiment.AppointSoldier(army.ChosenSoldier(i));
                        equipmentbuttonHandler.ChangeLeaderType(regiment.ReturnType());
                        //equipmentbuttonHandler.startOver(regiment.ReturnType());
                    }
                    else
                    {
                        typeOfUnitButtons[i].Sound();
                        regiment.AppointSoldier(army.ChosenSoldier(i));
                        equipmentbuttonHandler.ChangeLeaderType(regiment.ReturnType());
                        //equipmentbuttonHandler.startOver(regiment.ReturnType());
                    }
                    regiment.SetCost((regiment.ReturnType().GetCost() * regiment.GetNumberOfSoldiers()) + regiment.ReturnType().GetOneTimeCost() + regiment.ReturnType().GetArcherPlatformCost(regiment.GetNumberOfSoldiers()));
                }
            }
            if (regiment.GetSoldier() != null)
            {
                ChosenUnit = texthandler.NameText(regiment.GetSoldier(), regiment.GetNumberOfSoldiers(), font, regiment.GetEndCost());
                //regiment.SetCost(texthandler.ReturnEndpoints());
                if (!regiment.GetSoldier().loner)
                {
                    for (int i = 0; i < numbersOfSoldiersButtons.Count; i++)
                    {
                        numbersOfSoldiersButtons[i].Update(mousestate, oldMosueState, 0);
                        if (numbersOfSoldiersButtons[i].pressed)
                        {
                            if (numbersOfSoldiersButtons[i] is RoundUpNumberOfSoldierButton)
                            {
                                regiment.ChangeNumberOfSoldiers((numbersOfSoldiersButtons[i] as RoundUpNumberOfSoldierButton).Rounding(regiment.GetNumberOfSoldiers()));
                            }
                            else
                            {
                                regiment.ChangeNumberOfSoldiers(numbersOfSoldiersButtons[i].NumberOfSoldiers());
                            }
                            regiment.SetCost((regiment.ReturnType().GetCost() * regiment.GetNumberOfSoldiers()) + regiment.ReturnType().GetOneTimeCost() + regiment.ReturnType().GetArcherPlatformCost(regiment.GetNumberOfSoldiers()));
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public void Update()
        {
            mouse    = Mouse.GetState();
            keyboard = Keyboard.GetState();

            if (thing == Thing.Army)
            {
                armySupporter.Update();
                if (armySupporter.ChangeToRegiment())
                {
                    thing    = Thing.Regiment;
                    oldmouse = mouse;
                    regimentSupport.SetArmy(lastArmy);
                }
                else if (armySupporter.ChangeImportRegiment())
                {
                    thing    = Thing.Regiment;
                    oldmouse = mouse;
                    regimentSupport.SetImport();
                }
                else if (armySupporter.Edit())
                {
                    thing    = Thing.Regiment;
                    oldmouse = mouse;
                    regimentSupport.SetRegiment(armySupporter.GetRegiment());
                }
                else if (armySupporter.GoToSettings())
                {
                    thing = Thing.Settings;
                }
            }
            else if (thing == Thing.Regiment)
            {
                regimentSupport.Update();
                if (regimentSupport.TurnOff() || regimentSupport.DootEnd())
                {
                    lastArmy = regimentSupport.GetArmy();
                    if (armySupporter.Edit())
                    {
                        armySupporter.EditRegiments(regimentSupport.GetRegiment());
                    }
                    else
                    {
                        armySupporter.AddRegiment(regimentSupport.GetRegiment());
                    }
                    thing           = Thing.Army;
                    regimentSupport = new RegimentSupport(markButton, armyButtons, soldierRegulateButton, font, preFabPath, decoration, show, bookSound, crystalSound,
                                                          horseSound, clickSound, swordSound, arrowSound, lineTexture, hireRegiment, screenSize, magic, upDown, mark, regimentcancel, screenWidth,
                                                          screenHeight, edgeCutOff, yStartPosMagic, yCuttOff, magicSymbol, background, xStart, yStart, doot, dootTexture, markButtonStartPos);
                }
                else if (regimentSupport.GetCancel())
                {
                    lastArmy        = regimentSupport.GetArmy();
                    thing           = Thing.Army;
                    regimentSupport = new RegimentSupport(markButton, armyButtons, soldierRegulateButton, font, preFabPath, decoration, show, bookSound, crystalSound,
                                                          horseSound, clickSound, swordSound, arrowSound, lineTexture, hireRegiment, screenSize, magic, upDown, mark, regimentcancel, screenWidth,
                                                          screenHeight, edgeCutOff, yStartPosMagic, yCuttOff, magicSymbol, background, xStart, yStart, doot, dootTexture, markButtonStartPos);
                    if (armySupporter.Edit())
                    {
                        armySupporter.EditRegiments(armySupporter.GetEditRegiment());
                    }
                }
            }
            else if (thing == Thing.Settings)
            {
                graphicsSetting.Update(mouse);
                if (graphicsSetting.ExitButtonPressed())
                {
                    thing = Thing.Army;
                }
            }
            oldmouse = mouse;
        }