示例#1
0
 public Selection()
 {
     objects = new List<RtsObject>();
     mostPopulousType = null;
     activeType = null;
     ActiveCommandCard = null;
 }
示例#2
0
文件: Game1.cs 项目: bagnalla/RTS
        protected override void Initialize()
        {
            Graphics.PreferredBackBufferWidth  = 1024;
            Graphics.PreferredBackBufferHeight = 740;
            Graphics.ApplyChanges();

            Direction.Init();
            CommandCard.Init();

            fpsCounter = new FpsCounter(Game);
            Components.Add(fpsCounter);
            fpsCounter.DrawOrder = 0;
            //fpsCounter.Enabled = true;

            SoundEffectManager = new SoundEffectManager(Game);
            Components.Add(SoundEffectManager);
            SoundEffectManager.DrawOrder = 1;
            //soundEffectManager.DrawDebugInfo = true;

            DebugMonitor = new DebugMonitor(Game);
            Components.Add(DebugMonitor);
            DebugMonitor.Enabled  = true;
            DebugMonitor.DrawBox  = true;
            DebugMonitor.Position = Direction.SouthEast;

            ColorTexture.Initialize(GraphicsDevice);

            currentGameState = new Rts(RtsEventHandler);

            base.Initialize();
        }
示例#3
0
文件: Selection.cs 项目: bagnalla/RTS
 public Selection()
 {
     objects           = new List <RtsObject>();
     mostPopulousType  = null;
     activeType        = null;
     ActiveCommandCard = null;
 }
示例#4
0
        static CommandCard()
        {
            DefaultCommandCard = new CommandCard(new CommandButton[3, 4]);
            DefaultCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);

            TestCommandCard = new CommandCard(new CommandButton[3, 4]);
            TestCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            TestCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.Move);
        }
示例#5
0
        protected override void Initialize()
        {
            //Graphics.PreferredBackBufferWidth = 1024;
            //Graphics.PreferredBackBufferHeight = 740;
            //Graphics.PreferredBackBufferWidth = 1280;
            //Graphics.PreferredBackBufferHeight = 720;

            Graphics.PreferredBackBufferWidth  = 1024;
            Graphics.PreferredBackBufferHeight = 576;
            //Graphics.IsFullScreen = true;
            Graphics.ApplyChanges();

            Window.Title = "";

            IsMouseVisible = true;

            Direction.Init();
            CommandCard.Init();
            UnitType.Init();
            StructureType.Init();

            fpsCounter = new FpsCounter(Game);
            Components.Add(fpsCounter);
            fpsCounter.DrawOrder = 0;
            //fpsCounter.Enabled = true;

            SoundEffectManager = new SoundEffectManager(Game);
            Components.Add(SoundEffectManager);
            SoundEffectManager.DrawOrder = 1;
            //soundEffectManager.DrawDebugInfo = true;

            DebugMonitor = new DebugMonitor(Game);
            Components.Add(DebugMonitor);
            DebugMonitor.Enabled  = true;
            DebugMonitor.DrawBox  = true;
            DebugMonitor.Position = Direction.SouthEast;

            ColorTexture.Initialize(GraphicsDevice);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            //CurrentGameState = new Rts(RtsEventHandler);
            CurrentGameState = new StartMenu(StartMenuEventHandler);

            base.Initialize();
        }
示例#6
0
        static CommandCard()
        {
            BlankCommandCard = new CommandCard(new CommandButton[3, 4]);

            DefaultCommandCard = new CommandCard(new CommandButton[3, 4]);
            DefaultCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            DefaultCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.HoldPosition);
            DefaultCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Stop);

            TestCommandCard = new CommandCard(new CommandButton[3, 4]);
            TestCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            TestCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.HoldPosition);
            TestCommandCard.Buttons[0, 2] = new CommandButton(CommandButtonType.Move);

            WorkerCommandCard = new CommandCard(new CommandButton[3, 4]);
            WorkerCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            WorkerCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.HoldPosition);
            //WorkerCommandCard.Buttons[1, 0] = new CommandButton(CommandButtonType.Harvest);
            WorkerCommandCard.Buttons[1, 1] = new CommandButton(CommandButtonType.ReturnCargo);
            WorkerCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Stop);
            WorkerCommandCard.Buttons[2, 0] = new CommandButton(CommandButtonType.Build);

            BuildMenuCommandCard = new CommandCard(new CommandButton[3, 4]);
            BuildMenuCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.BuildTownHall);
            BuildMenuCommandCard.Buttons[1, 0] = new CommandButton(CommandButtonType.BuildBarracks);
            BuildMenuCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.BuildFarm);
            BuildMenuCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            UnderConstructionCommandCard = new CommandCard(new CommandButton[3, 4]);
            UnderConstructionCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            BarracksCommandCard = new CommandCard(new CommandButton[3, 4]);
            BarracksCommandCard.Buttons[2, 0] = new CommandButton(CommandButtonType.RallyPoint);
            BarracksCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.BuildMeleeNublet);
            BarracksCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.BuildRangedNublet);
            BarracksCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            TownHallCommandCard = new CommandCard(new CommandButton[3, 4]);
            TownHallCommandCard.Buttons[2, 0] = new CommandButton(CommandButtonType.RallyPoint);
            TownHallCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.BuildWorkerNublet);
            TownHallCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            UnitType.SetCommandCards();
            StructureType.SetCommandCards();
        }
示例#7
0
文件: Rts UI.cs 项目: nubington/rts
        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);
        }
示例#8
0
文件: Rts UI.cs 项目: bagnalla/RTS
        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();
        }
示例#9
0
        public CommandButton[,] Buttons; // = new CommandButton[4, 4];

        #endregion Fields

        #region Constructors

        static CommandCard()
        {
            BlankCommandCard = new CommandCard(new CommandButton[3, 4]);

            DefaultCommandCard = new CommandCard(new CommandButton[3, 4]);
            DefaultCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            DefaultCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.HoldPosition);
            DefaultCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Stop);

            TestCommandCard = new CommandCard(new CommandButton[3, 4]);
            TestCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            TestCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.HoldPosition);
            TestCommandCard.Buttons[0, 2] = new CommandButton(CommandButtonType.Move);

            WorkerCommandCard = new CommandCard(new CommandButton[3, 4]);
            WorkerCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            WorkerCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.HoldPosition);
            //WorkerCommandCard.Buttons[1, 0] = new CommandButton(CommandButtonType.Harvest);
            WorkerCommandCard.Buttons[1, 1] = new CommandButton(CommandButtonType.ReturnCargo);
            WorkerCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Stop);
            WorkerCommandCard.Buttons[2, 0] = new CommandButton(CommandButtonType.Build);

            BuildMenuCommandCard = new CommandCard(new CommandButton[3, 4]);
            BuildMenuCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.BuildTownHall);
            BuildMenuCommandCard.Buttons[1, 0] = new CommandButton(CommandButtonType.BuildBarracks);
            BuildMenuCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.BuildFarm);
            BuildMenuCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            UnderConstructionCommandCard = new CommandCard(new CommandButton[3, 4]);
            UnderConstructionCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            BarracksCommandCard = new CommandCard(new CommandButton[3, 4]);
            BarracksCommandCard.Buttons[2, 0] = new CommandButton(CommandButtonType.RallyPoint);
            BarracksCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.BuildMeleeNublet);
            BarracksCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.BuildRangedNublet);
            BarracksCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            TownHallCommandCard = new CommandCard(new CommandButton[3, 4]);
            TownHallCommandCard.Buttons[2, 0] = new CommandButton(CommandButtonType.RallyPoint);
            TownHallCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.BuildWorkerNublet);
            TownHallCommandCard.Buttons[2, 2] = new CommandButton(CommandButtonType.Cancel);

            UnitType.SetCommandCards();
            StructureType.SetCommandCards();
        }
示例#10
0
        public CommandButton[,] Buttons; // = new CommandButton[4, 4];

        #endregion Fields

        #region Constructors

        static CommandCard()
        {
            DefaultCommandCard = new CommandCard(new CommandButton[3, 4]);
            DefaultCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);

            TestCommandCard = new CommandCard(new CommandButton[3, 4]);
            TestCommandCard.Buttons[0, 0] = new CommandButton(CommandButtonType.Attack);
            TestCommandCard.Buttons[0, 1] = new CommandButton(CommandButtonType.Move);
        }