Exemple #1
0
        public void update(GameTime gameTime)
        {
            MouseState    curMouseState    = Mouse.GetState();
            KeyboardState curKeyboardState = Keyboard.GetState();
            Vector2       mousePos         = new Vector2(curMouseState.X, curMouseState.Y);

            UIElement        curElement = UIManager.The.Root.getElementAt(mousePos);
            ActiveGameObject curObject  = null;

            if (UIManager.The.Root is Frame_Game)
            {
                Frame_Game f = (Frame_Game)UIManager.The.Root;
                curObject = f.getObjectAt(mousePos);
            }

            setHover(curElement, curObject);

            // left click
            if (curMouseState.LeftButton.Equals(ButtonState.Pressed))
            {
                leftClick = ButtonState.Pressed;
            }
            else if (leftClick.Equals(ButtonState.Pressed))
            {
                // Left click detected
                leftClick = ButtonState.Released;

                if (curElement != null)
                {
                    curElement.LeftClickEvent.click(curElement);
                }
                else if (curObject != null)
                {
                    _selected = curObject;
                }
            }

            // right click
            if (curMouseState.RightButton.Equals(ButtonState.Pressed))
            {
                rightClick = ButtonState.Pressed;
            }

            else if (rightClick.Equals(ButtonState.Pressed))
            {
                // Right click detected
                rightClick = ButtonState.Released;
                if (curElement != null)
                {
                    curElement.RightClickEvent.click(curElement);
                }
                else if (curObject != null)
                {
                    if (_selected != null)
                    {
                        //move logic
                    }
                }
            }
        }
        private static Frame initGame(ContentManager Content)
        {
            SpriteFont  font  = Content.Load <SpriteFont>("Kootenay");
            Frame       fgame = new Frame_Game(800, 500);
            Sprite_Text add   = SpriteBin.The.AddTextSprite(font, "Add", "add");
            Button      eAdd  = new Button("add", add, 400, 400);

            fgame.addElement(eAdd);
            return(fgame);
        }
        public void Initialize(String XMLFile, bool isHost, Frame_Game frame, Monirator m, GameSimulator s, NetworkManager n, CommandRequester r)
        {
            TileMap map = new TileMap();
            RuleBook rulebook = new RuleBook();
            rulebook.LoadXMLData(XMLFile);

            monirator = m;
            simulator = s;
            NetworkController = n;
            CmdRequester = r;

            simulator.Initialize(map);
            monirator.Initialize(map, rulebook);
            HostSession = isHost;

            frame.AddUnitEvent +=new EventHandler(CmdRequester.AddButtonHandler);
        }
        public static Frame_Game BuildGameFrame(ContentManager Content)
        {
            SpriteFont  font  = Content.Load <SpriteFont>("Kootenay");
            Frame_Game  fgame = new Frame_Game(800, 500);
            Sprite_Text add0  = SpriteBin.The.AddTextSprite(font, "Tower 1", "add0");
            Sprite_Text add1  = SpriteBin.The.AddTextSprite(font, "Tower 2", "add1");
            Sprite_Text add2  = SpriteBin.The.AddTextSprite(font, "Tower 3", "add2");
            Sprite_Text add3  = SpriteBin.The.AddTextSprite(font, "Tower 4", "add3");
            Sprite_Text add4  = SpriteBin.The.AddTextSprite(font, "Tower 5", "add4");
            Sprite_Text add5  = SpriteBin.The.AddTextSprite(font, "Tower 6", "add5");
            Sprite_Text add6  = SpriteBin.The.AddTextSprite(font, "Unit 1", "add6");
            Sprite_Text add7  = SpriteBin.The.AddTextSprite(font, "Unit 2", "add7");
            Sprite_Text add8  = SpriteBin.The.AddTextSprite(font, "Unit 3", "add8");


            Button eAdd0 = new AddButton("add", add0, 200, 400, TOWERTYPE[0]);
            Button eAdd1 = new AddButton("add", add1, 300, 400, TOWERTYPE[1]);
            Button eAdd2 = new AddButton("add", add2, 400, 400, TOWERTYPE[2]);
            Button eAdd3 = new AddButton("add", add3, 200, 450, TOWERTYPE[3]);
            Button eAdd4 = new AddButton("add", add4, 300, 450, TOWERTYPE[4]);
            Button eAdd5 = new AddButton("add", add5, 400, 450, TOWERTYPE[5]);

            Button eAdd6 = new AddButton("add", add6, 0, 400, TOWERTYPE[0]);
            Button eAdd7 = new AddButton("add", add7, 100, 400, TOWERTYPE[1]);
            Button eAdd8 = new AddButton("add", add8, 0, 450, TOWERTYPE[2]);

            fgame.addElement(eAdd0);
            fgame.addElement(eAdd1);
            fgame.addElement(eAdd2);
            fgame.addElement(eAdd3);
            fgame.addElement(eAdd4);
            fgame.addElement(eAdd5);
            fgame.addElement(eAdd6);
            fgame.addElement(eAdd7);
            fgame.addElement(eAdd8);


            return(fgame);
        }
        public static Frame_Game BuildReplayFrame(ContentManager Content)
        {
            Frame_Game frame = new Frame_Game(800, 500);

            return(frame);
        }
 private static Frame initGame(ContentManager Content)
 {
     SpriteFont font = Content.Load<SpriteFont>("Kootenay");
     Frame fgame = new Frame_Game(800, 500);
     Sprite_Text add = SpriteBin.The.AddTextSprite(font, "Add", "add");
     Button eAdd = new Button("add", add, 400, 400);
     fgame.addElement(eAdd);
     return fgame;
 }
 public static Frame_Game BuildReplayFrame(ContentManager Content)
 {
     Frame_Game frame = new Frame_Game(800, 500);
     return frame;
 }
        public static Frame_Game BuildGameFrame(ContentManager Content)
        {
            SpriteFont font = Content.Load<SpriteFont>("Kootenay");
            Frame_Game fgame = new Frame_Game(800, 500);
            Sprite_Text add0 = SpriteBin.The.AddTextSprite(font, "Tower 1", "add0");
            Sprite_Text add1 = SpriteBin.The.AddTextSprite(font, "Tower 2", "add1");
            Sprite_Text add2 = SpriteBin.The.AddTextSprite(font, "Tower 3", "add2");
            Sprite_Text add3 = SpriteBin.The.AddTextSprite(font, "Tower 4", "add3");
            Sprite_Text add4 = SpriteBin.The.AddTextSprite(font, "Tower 5", "add4");
            Sprite_Text add5 = SpriteBin.The.AddTextSprite(font, "Tower 6", "add5");
            Sprite_Text add6 = SpriteBin.The.AddTextSprite(font, "Unit 1", "add6");
            Sprite_Text add7 = SpriteBin.The.AddTextSprite(font, "Unit 2", "add7");
            Sprite_Text add8 = SpriteBin.The.AddTextSprite(font, "Unit 3", "add8");

            Button eAdd0 = new AddButton("add", add0, 200, 400, TOWERTYPE[0]);
            Button eAdd1 = new AddButton("add", add1, 300, 400, TOWERTYPE[1]);
            Button eAdd2 = new AddButton("add", add2, 400, 400, TOWERTYPE[2]);
            Button eAdd3 = new AddButton("add", add3, 200, 450, TOWERTYPE[3]);
            Button eAdd4 = new AddButton("add", add4, 300, 450, TOWERTYPE[4]);
            Button eAdd5 = new AddButton("add", add5, 400, 450, TOWERTYPE[5]);

            Button eAdd6 = new AddButton("add", add6, 0, 400, TOWERTYPE[0]);
            Button eAdd7 = new AddButton("add", add7, 100, 400, TOWERTYPE[1]);
            Button eAdd8 = new AddButton("add", add8, 0, 450, TOWERTYPE[2]);

            fgame.addElement(eAdd0);
            fgame.addElement(eAdd1);
            fgame.addElement(eAdd2);
            fgame.addElement(eAdd3);
            fgame.addElement(eAdd4);
            fgame.addElement(eAdd5);
            fgame.addElement(eAdd6);
            fgame.addElement(eAdd7);
            fgame.addElement(eAdd8);

            return fgame;
        }
Exemple #9
0
 public void LoadContent(Microsoft.Xna.Framework.Content.ContentManager Content)
 {
     _frame = WindowDefinitions.BuildGameFrame(Content);
 }