Пример #1
0
        private void BuyCreature(GameTime gameTime)
        {
            // buy a creature

            this.supportCreatureIndex = 0;
            this.supportButtonRow     = 0;
            this.supportCreatureLevel = StrenghtLevel.Strongest;
            this.CheckAndTakActionOnClickedButton(this.supportCreatureLevel, this.supportCreatureIndex,
                                                  this.minYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep),
                                                  this.maxYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep), gameTime);

            this.supportCreatureLevel--;
            this.supportCreatureIndex++;
            this.supportButtonRow++;
            this.CheckAndTakActionOnClickedButton(this.supportCreatureLevel, this.supportCreatureIndex,
                                                  this.minYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep),
                                                  this.maxYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep), gameTime);

            this.supportCreatureLevel--;
            this.supportCreatureIndex++;
            this.supportButtonRow++;
            this.CheckAndTakActionOnClickedButton(this.supportCreatureLevel, this.supportCreatureIndex,
                                                  this.minYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep),
                                                  this.maxYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep), gameTime);

            this.supportCreatureLevel--;
            this.supportCreatureIndex++;
            this.supportButtonRow++;
            this.CheckAndTakActionOnClickedButton(this.supportCreatureLevel, this.supportCreatureIndex,
                                                  this.minYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep),
                                                  this.maxYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep), gameTime);

            this.supportCreatureLevel--;
            this.supportCreatureIndex++;
            this.supportButtonRow++;
            this.CheckAndTakActionOnClickedButton(this.supportCreatureLevel, this.supportCreatureIndex,
                                                  this.minYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep),
                                                  this.maxYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep), gameTime);

            this.supportCreatureLevel--;
            this.supportCreatureIndex++;
            this.supportButtonRow++;
            this.CheckAndTakActionOnClickedButton(this.supportCreatureLevel, this.supportCreatureIndex,
                                                  this.minYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep),
                                                  this.maxYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep), gameTime);

            this.supportCreatureLevel--;
            this.supportCreatureIndex++;
            this.supportButtonRow++;
            this.CheckAndTakActionOnClickedButton(this.supportCreatureLevel, this.supportCreatureIndex,
                                                  this.minYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep),
                                                  this.maxYFirstButton + (this.supportButtonRow * this.buttonDifferenceStep), gameTime);
        }
Пример #2
0
 private void LoadDefaults()
 {
     this.id                              = castlesCounter++;
     this.switchCounter                   = 100;
     this.frameCounter                    = 0;
     this.naiSilnaGadinaCount             = 0;
     this.increaseYforPrintNameOfCreature = 0;
     this.buttonDifferenceStep            = 55;
     this.supportCreatureIndex            = 0;
     this.supportButtonRow                = 1;
     this.supportCreatureLevel            = 0;
     this.minYFirstButton                 = 7;
     this.maxYFirstButton                 = 57;
     this.minXMinusButton                 = 215;
     this.maxXMinusButton                 = 265;
     this.minXPlusButton                  = 300;
     this.maxXPlusButton                  = 350;
     this.minXCheckButton                 = 360;
     this.maxXCheckButton                 = 410;
 }
        private void CheckEnemyUnitsForInBattleTurn()
        {
            foreach (var unit in this.enemyUnits)
            {
                if (unit.Key.inBattleTurn && unit.Key.GetStrengthLevel == unitStreghtLevelIndex)
                {
                    return;
                }
            }

            this.playerTurn = true;

            this.PrepareUnitsForTurn();

            unitStreghtLevelIndex--;

            if (unitStreghtLevelIndex < 0)
            {
                unitStreghtLevelIndex = StrenghtLevel.Strongest;
            }
        }
Пример #4
0
        private void CheckAndTakActionOnClickedButton(StrenghtLevel strengthCreatureLevel, int index, int minY, int maxY,
                                                      GameTime gameTime)
        {
            MouseExtended.Current.GetState(gameTime);

            // if mouse over PLUS button
            if (MouseExtended.Current.CurrentState.Position.X > this.minXPlusButton &&
                MouseExtended.Current.CurrentState.Position.X < this.maxXPlusButton &&
                MouseExtended.Current.CurrentState.Position.Y > minY &&
                MouseExtended.Current.CurrentState.Position.Y < maxY)
            {
                // if click on button
                if (this.newMouseState.LeftButton == ButtonState.Pressed &&
                    this.oldMouseState.LeftButton == ButtonState.Released)
                {
                    // if there are enough creatures
                    if (this.gadini.FirstOrDefault(x => x.Key.GetStrengthLevel == strengthCreatureLevel).Value -
                        this.creatureCounter[index] >=
                        1)
                    {
                        this.creatureCounter[index]++;

                        this.SendClickRequest();
                    }
                }
            }

            //  if mouse is over check/purchase button
            if (MouseExtended.Current.CurrentState.Position.X > this.minXCheckButton &&
                MouseExtended.Current.CurrentState.Position.X < this.maxXCheckButton &&
                MouseExtended.Current.CurrentState.Position.Y > minY &&
                MouseExtended.Current.CurrentState.Position.Y < maxY)
            {
                // purchase a creature
                if (this.newMouseState.LeftButton == ButtonState.Pressed &&
                    this.oldMouseState.LeftButton == ButtonState.Released)
                {
                    int a = 0;
                    this.SendClickRequest();
                    for (int i = 0; i < this.creatureCounter[index]; i++)
                    {
                        // add creature to Player / remove creature from Castle
                        this.RemoveCreature(
                            this.gadini.FirstOrDefault(x => x.Key.GetStrengthLevel == strengthCreatureLevel).Key);
                        WarUnit unit =
                            this.gadini.FirstOrDefault(x => x.Key.GetStrengthLevel == strengthCreatureLevel).Key;
                        CharacterManager.barbarian.AddCreature(unit);
                    }
                    this.creatureCounter[index] = 0;
                }
            }

            // if mouse is over minus button
            if (MouseExtended.Current.CurrentState.Position.X > this.minXMinusButton &&
                MouseExtended.Current.CurrentState.Position.X < this.maxXMinusButton &&
                MouseExtended.Current.CurrentState.Position.Y > minY &&
                MouseExtended.Current.CurrentState.Position.Y < maxY)
            {
                if (this.newMouseState.LeftButton == ButtonState.Pressed &&
                    this.oldMouseState.LeftButton == ButtonState.Released)
                {
                    if (this.creatureCounter[index] > 0)
                    {
                        this.creatureCounter[index]--;
                        this.SendClickRequest();
                    }
                }
            }
        }