Exemplo n.º 1
0
        void switchToBuildMenuCommandCard()
        {
            SimpleButton.RemoveButtons(CommandCardButtons);
            CommandCardButtons.Clear();

            int       buttonSize = commandCardArea.Width / 4;
            int       spacing    = 2;
            Rectangle box        = new Rectangle(commandCardArea.X, commandCardArea.Y, buttonSize, buttonSize);

            for (int x = 0; x < CommandCard.BuildMenuCommandCard.Buttons.GetLength(0); x++)
            {
                for (int y = 0; y < CommandCard.BuildMenuCommandCard.Buttons.GetLength(1); y++)
                {
                    if ((Object)(CommandCard.BuildMenuCommandCard.Buttons[x, y]) != null)
                    {
                        //spriteBatch.Draw(commandCard.Buttons[x, y].Texture, button, Color.White);

                        //CommandCardButtons.Add(new SimpleButton(box, SelectedUnits.ActiveCommandCard.Buttons[x, y].Texture, null, null));

                        CommandCard.BuildMenuCommandCard.Buttons[x, y].Rectangle = box;
                        CommandCardButtons.Add(CommandCard.BuildMenuCommandCard.Buttons[x, y]);
                    }
                    box.X += buttonSize + spacing;
                }
                box.X  = commandCardArea.X;
                box.Y += buttonSize + spacing;
            }

            SimpleButton.AddButtons(CommandCardButtons);

            SimpleButton.Reset();
        }
Exemplo n.º 2
0
        void resetCommandCard()
        {
            SimpleButton.RemoveButtons(CommandCardButtons);
            CommandCardButtons.Clear();

            activeCommandCard = SelectedUnits.ActiveCommandCard;

            bool allSelectedUnitsAreUnderConstruction = true;

            //int unitsUnderConstruction = 0, unitsNotUnderConstruction = 0;
            foreach (RtsObject o in SelectedUnits)
            {
                Structure s = o as Structure;
                if (s != null && s.UnderConstruction)
                {
                    //unitsUnderConstruction++;
                    continue;
                }
                allSelectedUnitsAreUnderConstruction = false;
                break;
                //else
                //    unitsNotUnderConstruction++;
            }
            if (allSelectedUnitsAreUnderConstruction)
            {
                //if (unitsUnderConstruction > unitsNotUnderConstruction)
                activeCommandCard = CommandCard.UnderConstructionCommandCard;
            }

            /*if (SelectedUnits.Count == 1)
             * {
             *  Structure s = SelectedUnits[0] as Structure;
             *  if (s != null && s.UnderConstruction)
             *  {
             *      commandCard = CommandCard.UnderConstructionCommandCard;
             *  }
             * }*/

            if (activeCommandCard == null)
            {
                return;
            }

            int       buttonSize = commandCardArea.Width / 4;
            int       spacing    = 2;
            Rectangle box        = new Rectangle(commandCardArea.X, commandCardArea.Y, buttonSize, buttonSize);

            for (int x = 0; x < activeCommandCard.Buttons.GetLength(0); x++)
            {
                for (int y = 0; y < activeCommandCard.Buttons.GetLength(1); y++)
                {
                    if ((Object)(activeCommandCard.Buttons[x, y]) != null)
                    {
                        activeCommandCard.Buttons[x, y].Rectangle = box;
                        CommandCardButtons.Add(activeCommandCard.Buttons[x, y]);
                    }
                    box.X += buttonSize + spacing;
                }
                box.X  = commandCardArea.X;
                box.Y += buttonSize + spacing;
            }

            SimpleButton.AddButtons(CommandCardButtons);

            SimpleButton.Reset();
        }