Beispiel #1
0
        public void setImage(enmUnitType unitType)
        {
            switch (unitType)
            {
            case enmUnitType.LightInfantry:
                imgUnit.Source = new BitmapImage(new Uri("UnitImages/Unit_LI.png", UriKind.RelativeOrAbsolute));
                break;

            case enmUnitType.HeavyInfantry:
                imgUnit.Source = new BitmapImage(new Uri("UnitImages/Unit_HI.png", UriKind.RelativeOrAbsolute));
                break;

            case enmUnitType.LightCavalry:
                imgUnit.Source = new BitmapImage(new Uri("UnitImages/Unit_LC.png", UriKind.RelativeOrAbsolute));
                break;

            case enmUnitType.HeavyCavalry:
                imgUnit.Source = new BitmapImage(new Uri("UnitImages/Unit_HC.png", UriKind.RelativeOrAbsolute));
                break;

            case enmUnitType.Archers:
                imgUnit.Source = new BitmapImage(new Uri("UnitImages/Unit_Ar.png", UriKind.RelativeOrAbsolute));
                break;

            case enmUnitType.Musketeers:
                imgUnit.Source = new BitmapImage(new Uri("UnitImages/Unit_Mu.png", UriKind.RelativeOrAbsolute));
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds one unit to the army
        /// </summary>
        /// <param name="unit">Type of the unit that is being added</param>
        public void addUnit(enmUnitType unit)
        {
            switch (unit)
            {
            case enmUnitType.Archers:
                army.Archers++;
                break;

            case enmUnitType.Musketeers:
                army.Musketeers++;
                break;

            case enmUnitType.LightInfantry:
                army.LightInfantry++;
                break;

            case enmUnitType.HeavyInfantry:
                army.HeavyInfantry++;
                break;

            case enmUnitType.LightCavalry:
                army.LightCavalry++;
                break;

            case enmUnitType.HeavyCavalry:
                army.HeavyCavalry++;
                break;
            }
        }
        private void removeUnit(enmUnitType unitType, bool resetInterface)
        {
            App    app          = (App)Application.Current;
            Player ActivePlayer = app.Recruitment_player;

            bool removeArmy   = false;
            Army armyToRemove = new Army();  //placeholder

            foreach (Army army in ActivePlayer.Armies)
            {
                if (string.Equals(army.location, app.Recruitment_node))
                {
                    switch (unitType)
                    {
                    case enmUnitType.Archers:
                        army.Archers--;
                        break;

                    case enmUnitType.HeavyCavalry:
                        army.HeavyCavalry--;
                        break;

                    case enmUnitType.LightCavalry:
                        army.LightCavalry--;
                        break;

                    case enmUnitType.HeavyInfantry:
                        army.HeavyInfantry--;
                        break;

                    case enmUnitType.LightInfantry:
                        army.LightInfantry--;
                        break;

                    case enmUnitType.Musketeers:
                        army.Musketeers--;
                        break;
                    } //switch

                    if (army.isEmpty())
                    {
                        removeArmy   = true;
                        armyToRemove = army;
                    }
                    break;
                } //if
            }     //foreach

            if (removeArmy)
            {
                ActivePlayer.Armies.Remove(armyToRemove);
            }

            if (resetInterface)
            {
                setInterface();
            }
        }
        private void moveDown(enmUnitType unitType)
        {
            removeUnit(unitType, false);

            App app = (App)Application.Current;

            foreach (Commander commander in app.Recruitment_player.Commanders)
            {
                if (string.Equals(commander.location, app.Recruitment_node))
                {
                    commander.addUnit(unitType);
                    break;
                }
            }
            setInterface();
        }
Beispiel #5
0
        /// <summary>
        /// Removes a unit from the army
        /// </summary>
        /// <param name="unit">Type of the unit that is being removed</param>
        public void removeUnit(enmUnitType unit)
        {
            switch (unit)
            {
            case enmUnitType.Archers:
                if (army.Archers != 0)
                {
                    army.Archers--;
                }
                break;

            case enmUnitType.Musketeers:
                if (army.Musketeers != 0)
                {
                    army.Musketeers--;
                }
                break;

            case enmUnitType.LightInfantry:
                if (army.LightInfantry != 0)
                {
                    army.LightInfantry--;
                }
                break;

            case enmUnitType.HeavyInfantry:
                if (army.HeavyInfantry != 0)
                {
                    army.HeavyInfantry--;
                }
                break;

            case enmUnitType.LightCavalry:
                if (army.LightCavalry != 0)
                {
                    army.LightCavalry--;
                }
                break;

            case enmUnitType.HeavyCavalry:
                if (army.HeavyCavalry != 0)
                {
                    army.HeavyCavalry--;
                }
                break;
            }
        }
        private void addUnit(enmUnitType unitType, bool hiring)
        {
            App    app          = (App)Application.Current;
            Player ActivePlayer = app.Recruitment_player;

            if (!garrisonArmyExists)
            {
                Army newArmy = new Army();
                newArmy.location = app.Recruitment_node;
                ActivePlayer.Armies.Add(newArmy);
                garrisonArmyExists = true;
            }

            foreach (Army army in ActivePlayer.Armies)
            {
                if (string.Equals(army.location, app.Recruitment_node))
                {
                    switch (unitType)
                    {
                    case enmUnitType.Archers:
                        army.Archers++;
                        if (hiring)
                        {
                            ActivePlayer.Gold -= Constants.GoldCostBowmen;
                        }
                        break;

                    case enmUnitType.HeavyCavalry:
                        army.HeavyCavalry++;
                        if (hiring)
                        {
                            ActivePlayer.Gold -= Constants.GoldCostCavalryHeavy;
                        }
                        break;

                    case enmUnitType.LightCavalry:
                        army.LightCavalry++;
                        if (hiring)
                        {
                            ActivePlayer.Gold -= Constants.GoldCostCavalryLight;
                        }
                        break;

                    case enmUnitType.HeavyInfantry:
                        army.HeavyInfantry++;
                        if (hiring)
                        {
                            ActivePlayer.Gold -= Constants.GoldCostInfantryHeavy;
                        }
                        break;

                    case enmUnitType.LightInfantry:
                        army.LightInfantry++;
                        if (hiring)
                        {
                            ActivePlayer.Gold -= Constants.GoldCostInfantryLight;
                        }
                        break;

                    case enmUnitType.Musketeers:
                        army.Musketeers++;
                        if (hiring)
                        {
                            ActivePlayer.Gold -= Constants.GoldCostMusketeer;
                        }
                        break;
                    } //switch
                    break;
                }     //if
            }         //foreach

            if (hiring)
            {
                setInterface();
            }
        }