예제 #1
0
        /// <summary>
        /// Allows the app to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            IsMouseVisible = true; // easier for debugging not to "lose" mouse
            SetWindowOnSurface();
            InitializeSurfaceInput();

            // Set the application's orientation based on the orientation at launch
            currentOrientation = ApplicationServices.InitialOrientation;

            // Subscribe to surface window availability events
            ApplicationServices.WindowInteractive += OnWindowInteractive;
            ApplicationServices.WindowNoninteractive += OnWindowNoninteractive;
            ApplicationServices.WindowUnavailable += OnWindowUnavailable;

            // Setup the UI to transform if the UI is rotated.
            // Create a rotation matrix to orient the screen so it is viewed correctly
            // when the user orientation is 180 degress different.
            Matrix inverted = Matrix.CreateRotationZ(MathHelper.ToRadians(180)) *
                        Matrix.CreateTranslation(graphics.GraphicsDevice.Viewport.Width,
                                                    graphics.GraphicsDevice.Viewport.Height,
                                                    0);

            if (currentOrientation == UserOrientation.Top)
            {
                screenTransform = inverted;
            }

            screenWidth = Program.WindowSize.Width;
            screenHeight = Program.WindowSize.Height;

            manager = new Manager();
            manager.Initialize(this, touchTarget, Manager.SelectionMode.MONO);
            manager.Behaviour = new BehaviourPlane(screenWidth, screenHeight, _serverIP);

            aircraftCarrier = new Sprite("aircraftCarrier", "aircraftCarrier");
            aircraftCarrier.Initialize(touchTarget);
            aircraftCarrier.Touchable = false;
            manager.Register(aircraftCarrier);

            plane1 = new enib.pa.Plane("plane1");
            plane1.Initialize(touchTarget);
            plane1.Scale = 0.13f;
            plane1.Weight = 1;
            plane1.Rotation = -(float)0;
            plane1.ShowBoundingRect = true;
            plane1.Dragable = false;
            manager.Register(plane1);

            plane2 = new enib.pa.Plane("plane2");
            plane2.Initialize(touchTarget);
            plane2.Scale = 0.13f;
            plane2.Weight = 1;
            plane2.Rotation = (float)Math.PI /2;
            plane2.ShowBoundingRect = true;
            plane2.Dragable = false;
            manager.Register(plane2);

            plane3 = new enib.pa.Plane("plane3");
            plane3.Initialize(touchTarget);
            plane3.Scale = 0.13f;
            plane3.Weight = 1;
            plane3.Rotation = (float)Math.PI;
            plane3.ShowBoundingRect = true;
            plane3.Dragable = false;
            manager.Register(plane3);

            plane4 = new enib.pa.Plane("plane4");
            plane4.Initialize(touchTarget);
            plane4.Scale = 0.13f;
            plane4.Weight = 1;
            plane4.Rotation = -(float)Math.PI / 2;
            plane4.ShowBoundingRect = true;
            plane4.Dragable = false;
            manager.Register(plane4);

            menu_pt1 = new Plane_Menu_Elevator("ascenseur1");
            menu_pt1.setPlaneur(plane1);

            menu_pt2 = new Plane_Menu_Catapulte1("catapulte1");
            menu_pt2.setPlaneur(plane1);

            menu_pt3 = new Plane_Menu_Catapulte2("catapulte2");
            menu_pt3.setPlaneur(plane1);

            menu = new Enib.SurfaceLib.Menu(manager, plane1);
            menu.Initialize(touchTarget);
            menu.addMenuEntry(menu_pt1);
            menu.addMenuEntry(menu_pt2);
            menu.addMenuEntry(menu_pt3);
            menu.Hide();

            base.Initialize();
        }
예제 #2
0
        /// <summary>
        /// Allows the app to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            IsMouseVisible = true; // easier for debugging not to "lose" mouse
            SetWindowOnSurface();
            InitializeSurfaceInput();

            // Set the application's orientation based on the orientation at launch
            currentOrientation = ApplicationServices.InitialOrientation;

            // Subscribe to surface window availability events
            ApplicationServices.WindowInteractive    += OnWindowInteractive;
            ApplicationServices.WindowNoninteractive += OnWindowNoninteractive;
            ApplicationServices.WindowUnavailable    += OnWindowUnavailable;

            // Setup the UI to transform if the UI is rotated.
            // Create a rotation matrix to orient the screen so it is viewed correctly
            // when the user orientation is 180 degress different.
            Matrix inverted = Matrix.CreateRotationZ(MathHelper.ToRadians(180)) *
                              Matrix.CreateTranslation(graphics.GraphicsDevice.Viewport.Width,
                                                       graphics.GraphicsDevice.Viewport.Height,
                                                       0);

            if (currentOrientation == UserOrientation.Top)
            {
                screenTransform = inverted;
            }

            screenWidth  = Program.WindowSize.Width;
            screenHeight = Program.WindowSize.Height;

            manager = new Manager();
            manager.Initialize(this, touchTarget, Manager.SelectionMode.MONO);
            manager.Behaviour = new BehaviourPlane(screenWidth, screenHeight, _serverIP);

            aircraftCarrier = new Sprite("aircraftCarrier", "aircraftCarrier");
            aircraftCarrier.Initialize(touchTarget);
            aircraftCarrier.Touchable = false;
            manager.Register(aircraftCarrier);

            plane1 = new enib.pa.Plane("plane1");
            plane1.Initialize(touchTarget);
            plane1.Scale            = 0.13f;
            plane1.Weight           = 1;
            plane1.Rotation         = -(float)0;
            plane1.ShowBoundingRect = true;
            plane1.Dragable         = false;
            manager.Register(plane1);

            plane2 = new enib.pa.Plane("plane2");
            plane2.Initialize(touchTarget);
            plane2.Scale            = 0.13f;
            plane2.Weight           = 1;
            plane2.Rotation         = (float)Math.PI / 2;
            plane2.ShowBoundingRect = true;
            plane2.Dragable         = false;
            manager.Register(plane2);

            plane3 = new enib.pa.Plane("plane3");
            plane3.Initialize(touchTarget);
            plane3.Scale            = 0.13f;
            plane3.Weight           = 1;
            plane3.Rotation         = (float)Math.PI;
            plane3.ShowBoundingRect = true;
            plane3.Dragable         = false;
            manager.Register(plane3);

            plane4 = new enib.pa.Plane("plane4");
            plane4.Initialize(touchTarget);
            plane4.Scale            = 0.13f;
            plane4.Weight           = 1;
            plane4.Rotation         = -(float)Math.PI / 2;
            plane4.ShowBoundingRect = true;
            plane4.Dragable         = false;
            manager.Register(plane4);

            menu_pt1 = new Plane_Menu_Elevator("ascenseur1");
            menu_pt1.setPlaneur(plane1);

            menu_pt2 = new Plane_Menu_Catapulte1("catapulte1");
            menu_pt2.setPlaneur(plane1);

            menu_pt3 = new Plane_Menu_Catapulte2("catapulte2");
            menu_pt3.setPlaneur(plane1);

            menu = new Enib.SurfaceLib.Menu(manager, plane1);
            menu.Initialize(touchTarget);
            menu.addMenuEntry(menu_pt1);
            menu.addMenuEntry(menu_pt2);
            menu.addMenuEntry(menu_pt3);
            menu.Hide();

            base.Initialize();
        }