Пример #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            uc = new UserControl();
            LuaInterfacer li = new LuaInterfacer();
            li.SetGlobal("UserControl", uc);
            li.DoFile("./Content/init.lua");
            scn = li.CreateStage(spriteBatch, "main");
            mainTheatre.AddStage(scn);
            scn.CalibrateCollisions();
            scn.Reindex();
            //ResourceLoader rsldr = new ResourceLoader("./Content/init.lua");
            mainHero = li.actorList["Hero"];
            //scn = rsldr.CreateStage(spriteBatch,"main");

            uc.onKeydown += keyDowned;
            uc.onMouseLeftDown += mouseMoved;

            IsMouseVisible = true;

            mainHero.onCollision += onCollision;
            mainHero.onMove += onActorMoved;
            mainHero.speed = 0.5f;
            mainHero.RotateSpeed = 100;
            scn.onMapOut += onSomebodyMapout;
            mainHero.Rotate((float)(Math.PI*2/3));
            //makeMoveTest(mainHero);
            systemFont = Content.Load<SpriteFont>("Courier New");
            Text t1 = new Text("main hero");
            t1.position.Y = -50;
            t1.position.X = -50;
            mainHero.AddText(t1);

            int middleDisplay = GraphicsDevice.Viewport.Width/2;
            menu = new Stage(this.spriteBatch, 1024, 768, new Rectangle(0,0,400, 400));

            Button newGameButton = new Button("New game", GraphicsDevice, spriteBatch);
            newGameButton.BackgroundImage = "Plit.png";
            newGameButton.onClick += NewGameFunc;

            Button exitButton = new Button("Exit", GraphicsDevice, spriteBatch);
            exitButton.BackgroundImage = "Plit.png";
            exitButton.onClick += ExitFunc;

            Panel p = new Panel(GraphicsDevice.Viewport.Width,GraphicsDevice.Viewport.Height);
            p.position.Y = 10;
            p.AddControl(newGameButton);
            p.AddControl(exitButton);

            menu.AddControl(p);

            mainTheatre.AddStage(menu);

            mainTheatre.Disable(scn);
            //mainTheatre.Disable(menu);
        }
Пример #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            uc          = new UserControl();
            LuaInterfacer li = new LuaInterfacer();

            li.SetGlobal("UserControl", uc);
            li.DoFile("./Content/init.lua");
            scn = li.CreateStage(spriteBatch, "main");
            mainTheatre.AddStage(scn);
            scn.CalibrateCollisions();
            scn.Reindex();
            //ResourceLoader rsldr = new ResourceLoader("./Content/init.lua");
            mainHero = li.actorList["Hero"];
            //scn = rsldr.CreateStage(spriteBatch,"main");


            uc.onKeydown       += keyDowned;
            uc.onMouseLeftDown += mouseMoved;

            IsMouseVisible = true;

            mainHero.onCollision += onCollision;
            mainHero.onMove      += onActorMoved;
            mainHero.speed        = 0.5f;
            mainHero.RotateSpeed  = 100;
            scn.onMapOut         += onSomebodyMapout;
            mainHero.Rotate((float)(Math.PI * 2 / 3));
            //makeMoveTest(mainHero);
            systemFont = Content.Load <SpriteFont>("Courier New");
            Text t1 = new Text("main hero");

            t1.position.Y = -50;
            t1.position.X = -50;
            mainHero.AddText(t1);

            int middleDisplay = GraphicsDevice.Viewport.Width / 2;

            menu = new Stage(this.spriteBatch, 1024, 768, new Rectangle(0, 0, 400, 400));

            Button newGameButton = new Button("New game", GraphicsDevice, spriteBatch);

            newGameButton.BackgroundImage = "Plit.png";
            newGameButton.onClick        += NewGameFunc;

            Button exitButton = new Button("Exit", GraphicsDevice, spriteBatch);

            exitButton.BackgroundImage = "Plit.png";
            exitButton.onClick        += ExitFunc;

            Panel p = new Panel(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            p.position.Y = 10;
            p.AddControl(newGameButton);
            p.AddControl(exitButton);

            menu.AddControl(p);

            mainTheatre.AddStage(menu);

            mainTheatre.Disable(scn);
            //mainTheatre.Disable(menu);
        }