Esempio n. 1
0
        protected override void LoadContent()
        {
            Delay = Program.Rand.Next(300, 3000);

            graphics.PreferredBackBufferHeight = Bounds.Height;
            graphics.PreferredBackBufferWidth  = Bounds.Width;
            graphics.ApplyChanges();
            User32.SetWindowPos((uint)this.Window.Handle, 0, Bounds.X, Bounds.Y, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            if (ID == 0)
            {
                Program.MasterMaze = new Maze();
                Program.MasterMaze.Generate();

                MasterMode = "Generate";

                Program.MasterMaze.GenerateGroundPrimatives(GraphicsDevice);
            }

            MovableCamera = new FreeCamera(new Vector3(1375, 3750, 1375), 0, MathHelper.ToRadians(-90), GraphicsDevice);
            MovableCamera.Update();

            MazeEffect  = Content.Load <Effect>("MazeEffect");
            MazeTexture = Content.Load <Texture2D>("Alex1");

            BEffect = new BasicEffect(GraphicsDevice);
            BEffect.VertexColorEnabled = true;
            BEffect.LightingEnabled    = false;
        }
Esempio n. 2
0
        protected override void LoadContent()
        {
            graphics.PreferredBackBufferHeight = Bounds.Height;
            graphics.PreferredBackBufferWidth  = Bounds.Width;
            graphics.ApplyChanges();
            User32.SetWindowPos((uint)this.Window.Handle, 0, Bounds.X, Bounds.Y, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            PanInEffect  = Content.Load <Effect>("PanIn");
            PanOutEffect = Content.Load <Effect>("PanOut");

            FadeInEffect  = Content.Load <Effect>("FadeIn");
            FadeOutEffect = Content.Load <Effect>("FadeOut");

            SpiralInEffect  = Content.Load <Effect>("SpiralIn");
            SpiralOutEffect = Content.Load <Effect>("SpiralOut");

            if (IsLeft)
            {
                Images.Add(Content.Load <Texture2D>("Alex1"));
                Images.Add(Content.Load <Texture2D>("F22"));
                Images.Add(Content.Load <Texture2D>("Tim1"));
                Images.Add(Content.Load <Texture2D>("CPU1"));
            }

            else
            {
                Images.Add(Content.Load <Texture2D>("Megaman1"));
                Images.Add(Content.Load <Texture2D>("Megaman2"));
                Images.Add(Content.Load <Texture2D>("Megaman3"));
                Images.Add(Content.Load <Texture2D>("Megaman4"));
                Images.Add(Content.Load <Texture2D>("Megaman5"));
            }

            Mode = RandomMode();
            GeneratePrimatives(Program.Rand.Next(10, 25), Images[0]);

            FixedCamera = new TargetCamera(new Vector3(100, 50, 300), new Vector3(100, 50, 0), GraphicsDevice);
            FixedCamera.Update();

            MovableCamera = new FreeCamera(new Vector3(250, 225, 750), 0, 0, GraphicsDevice);
            MovableCamera.Update();
        }
Esempio n. 3
0
        protected override void LoadContent()
        {
            if (Handler.ToInt32() != 0)
            {

                User32.SetWindowPos((uint)this.Window.Handle, 0, 0, 0, 0, 0, 0);

                System.Drawing.Rectangle ParentRect;
                User32.GetClientRect(Handler, out ParentRect);

                User32.SetParent(this.Window.Handle, Handler);
                User32.SetWindowLong(this.Window.Handle, -16, new IntPtr(User32.GetWindowLong(this.Window.Handle, -16) | 0x40000000));

                PresentationParameters PP = GraphicsDevice.PresentationParameters;

                PP.DeviceWindowHandle = Handler;

                GraphicsDevice.Reset(PP);

                //graphics.PreferredBackBufferHeight = ParentRect.Height;
                //graphics.PreferredBackBufferWidth = ParentRect.Width;
                //graphics.ApplyChanges();

            }

            else
            {

                graphics.PreferredBackBufferHeight = Bounds.Height;
                graphics.PreferredBackBufferWidth = Bounds.Width;
                graphics.ApplyChanges();
                User32.SetWindowPos((uint)this.Window.Handle, 0, Bounds.X, Bounds.Y, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);

            }

            spriteBatch = new SpriteBatch(GraphicsDevice);

            BE = new BasicEffect(GraphicsDevice);

            PanInEffect = Content.Load<Effect>("PanIn");
            PanOutEffect = Content.Load<Effect>("PanOut");

            FadeInEffect = Content.Load<Effect>("FadeIn");
            FadeOutEffect = Content.Load<Effect>("FadeOut");

            SpiralInEffect = Content.Load<Effect>("SpiralIn");
            SpiralOutEffect = Content.Load<Effect>("SpiralOut");

            String[] Files = Directory.Exists(Location) ? Directory.GetFiles(Location) : new string[0];

            foreach (String Picture in Files)
            {

                if (Picture.Contains(".png") || Picture.Contains(".PNG") || Picture.Contains(".jpg") || Picture.Contains(".JPG"))
                {
                    FileStream FS = new FileStream(Picture, FileMode.Open);
                    Images.Add(Texture2D.FromStream(GraphicsDevice, FS));
                    FS.Close();

                }

            }

            if (Images.Count == 0)
            {

                Images.Add(Content.Load<Texture2D>("Cell"));
                Images.Add(Content.Load<Texture2D>("Japan"));
                Images.Add(Content.Load<Texture2D>("Galaxy"));
                Images.Add(Content.Load<Texture2D>("AbstractBars"));

            }

            if (TransitionMode == "Random")
                Mode = RandomMode();
            else
                Mode = TransitionMode;

            if (Order == "Random")
                ImageIndex = new Random().Next(0, Images.Count);
            else
                ImageIndex = 0;

            int Primatives = TileType == "Random" ? Program.Rand.Next(MinTiles, MaxTiles) : FixedTiles;
            GeneratePrimatives(Primatives, Images[ImageIndex]);

            MovableCamera = new FreeCamera(new Vector3(Bounds.Width / 2, Bounds.Height / 2, 10), 0, 0, GraphicsDevice, false);
            MovableCamera.Update();
        }
Esempio n. 4
0
        protected override void LoadContent()
        {
            Delay = Program.Rand.Next(300, 3000);

            graphics.PreferredBackBufferHeight = Bounds.Height;
            graphics.PreferredBackBufferWidth = Bounds.Width;
            graphics.ApplyChanges();
            User32.SetWindowPos((uint)this.Window.Handle, 0, Bounds.X, Bounds.Y, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            if (ID == 0)
            {

                Program.MasterMaze = new Maze();
                Program.MasterMaze.Generate();

                MasterMode = "Generate";

                Program.MasterMaze.GenerateGroundPrimatives(GraphicsDevice);

            }

            MovableCamera = new FreeCamera(new Vector3(1375, 3750, 1375), 0, MathHelper.ToRadians(-90), GraphicsDevice);
            MovableCamera.Update();

            MazeEffect = Content.Load<Effect>("MazeEffect");
            MazeTexture = Content.Load<Texture2D>("Floor");
            WallTiling = Content.Load<Texture2D>("Walls");

            BEffect = new BasicEffect(GraphicsDevice);
            BEffect.VertexColorEnabled = true;
            BEffect.LightingEnabled = false;
        }
Esempio n. 5
0
        protected override void Update(GameTime gameTime)
        {
            if (MasterMode != Program.MasterMaze.State)
            {
                MasterMode = Program.MasterMaze.State;
            }

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            #region Free Camera

            KeyboardState keyState   = Keyboard.GetState();
            MouseState    mouseState = Mouse.GetState();

            if (keyState.IsKeyDown(Keys.Space))
            {
                // Determine how much the camera should turn
                float deltaX = (float)lastMouseState.X - (float)mouseState.X;
                float deltaY = (float)lastMouseState.Y - (float)mouseState.Y;

                // Rotate the camera
                MovableCamera.Rotate(deltaX * .005f, deltaY * .005f);
            }

            Vector3 translation = Vector3.Zero;

            // Determine in which direction to move the camera
            if (keyState.IsKeyDown(Keys.W))
            {
                translation += Vector3.Forward;
            }
            if (keyState.IsKeyDown(Keys.S))
            {
                translation += Vector3.Backward;
            }
            if (keyState.IsKeyDown(Keys.A))
            {
                translation += Vector3.Left;
            }
            if (keyState.IsKeyDown(Keys.D))
            {
                translation += Vector3.Right;
            }
            if (keyState.IsKeyDown(Keys.F12))
            {
                this.Exit();
            }

            // Move 4 units per millisecond, independent of frame rate
            translation *= (float)(0.5 * gameTime.ElapsedGameTime.TotalMilliseconds) * (Keyboard.GetState().IsKeyDown(Keys.LeftControl) ? 2.5f : 1f) * (Keyboard.GetState().IsKeyDown(Keys.LeftShift) ? 10f : 1f);

            // Move the camera
            MovableCamera.Move(translation);
            MovableCamera.Update();

            lastMouseState = mouseState;

            #endregion

            #region Maze Stuff
            switch (MasterMode)
            {
            case "Generate":

                ReRender--;

                if (ID == 0)
                {
                    Program.MasterMaze.GenerateNext(ReRender < 0 ? true : false);
                }

                else
                {
                    WallVerticesBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), Program.MasterMaze.WallVertices.Length, BufferUsage.WriteOnly);
                    WallIndicesBuffer  = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, Program.MasterMaze.WallIndices.Length, BufferUsage.WriteOnly);

                    WallVerticesBuffer.SetData <VertexPositionColor>(Program.MasterMaze.WallVertices);
                    WallIndicesBuffer.SetData <int>(Program.MasterMaze.WallIndices);
                }

                if (ReRender < 0)
                {
                    ReRender += Stagger;
                }

                break;

            case "Ready":

                #region Maze Stuff

                if (SelfMode == "Ready")
                {
                }

                #region Transition
                else if (SelfMode == "Transition")
                {
                    if (SmallTimer > 0)
                    {
                        if (ID == 0)
                        {
                            MovableCamera = new FreeCamera(new Vector3(1375 - (180 - SmallTimer) * 1320 / 180f,
                                                                       3750 - (180 - SmallTimer) * 3695 / 180f,
                                                                       1375 - (180 - SmallTimer) * 1320 / 180f),
                                                           MathHelper.ToRadians(-(180 - SmallTimer)),
                                                           MathHelper.ToRadians(-90 + (180 - SmallTimer) * .5f), GraphicsDevice);
                        }

                        else
                        {
                            MovableCamera = new FreeCamera(new Vector3(1375 - (180 - SmallTimer) * 1320 / 180f,
                                                                       3750 - (180 - SmallTimer) * 3695 / 180f,
                                                                       1375 + (180 - SmallTimer) * 1320 / 180f),
                                                           MathHelper.ToRadians(0),
                                                           MathHelper.ToRadians(-90 + (180 - SmallTimer) * .5f), GraphicsDevice);
                        }

                        MovableCamera.Update();

                        SmallTimer--;
                    }

                    else
                    {
                        SelfMode = "Guess";

                        PathStack = new Stack <Cell>();

                        if (ID == 0)
                        {
                            PathStack.Push(Program.MasterMaze.Cells[0, 0]);
                        }
                        else
                        {
                            PathStack.Push(Program.MasterMaze.Cells[0, (int)Program.MasterMaze.Dimensions.Y - 1]);
                        }

                        Current = PathStack.Peek();

                        CurrentDirection = ID == 0 ? "Down" : "Up";
                        MovableCamera    = new FreeCamera(new Vector3(Current.Location.X * 110 + 55, 55, Current.Location.Y * 110 + 55), MovableCamera.Yaw, 0, GraphicsDevice);
                    }
                }
                #endregion

                #region Guess
                else if (SelfMode == "Guess")
                {
                    Next = Program.MasterMaze.Guess(PathStack, ID, Next);

                    Vector3 Difference = new Vector3(Current.Location.X * 110 + 55, 55, Current.Location.Y * 110 + 55) - MovableCamera.Position;

                    ShouldMove = new Vector2(Difference.X + 110, Difference.Z + 110);
                    HasMoved   = new Vector2(110) - ShouldMove;
                    Start      = MovableCamera.Position;
                    Start.Y    = 55;

                    RotateBy = NeedsRotate();

                    if (RotateBy == 0)
                    {
                        //No rotation needed go to moving immediately
                        SelfMode   = "Move";
                        SmallTimer = 0;
                    }

                    else
                    {
                        SelfMode   = "Rotate";
                        SmallTimer = Math.Abs(RotateBy / 90) * 30;

                        if (RotateBy > 90)
                        {
                        }
                    }
                }
                #endregion

                #region Move and Rotate
                else if (SelfMode == "Move")
                {
                    if (HasMoved.X < 110 && HasMoved.Y < 110)
                    {
                        MovableCamera.Position += (new Vector3(Next.Location.X * 110 + 55, 55, Next.Location.Y * 110 + 55) - Start) / 30f;
                        HasMoved += new Vector2(Math.Abs(Vector3.Forward.X * 110 / 30f), Math.Abs(Vector3.Forward.Z * 110 / 30f));
                    }

                    else
                    {
                        SelfMode = "Guess";
                        Current  = Next;
                    }
                }

                else if (SelfMode == "Rotate")
                {
                    if (SmallTimer > 0)
                    {
                        MovableCamera.Rotate(MathHelper.ToRadians(RotateBy) / (Math.Abs(RotateBy / 90) * 30), 0);
                        SmallTimer--;
                    }

                    else
                    {
                        SelfMode   = "Move";
                        SmallTimer = 0;
                        SetDirection();
                    }
                }
                #endregion

                else
                {
                    SmallTimer = 180;
                    SelfMode   = "Transition";
                }

                #endregion

                #region Overview

                if (Delay <= 0)
                {
                    if (CameraState == "Waiting")
                    {
                        CameraState = "Up";
                        Delay       = 60;
                    }

                    else if (CameraState == "Up")
                    {
                        CameraState = "Observe";
                        Delay       = 600;
                    }

                    else if (CameraState == "Observe")
                    {
                        CameraState = "Down";
                        Delay       = 60;
                    }

                    else if (CameraState == "Down")
                    {
                        CameraState = "Waiting";
                        Delay       = Program.Rand.Next(1500, 3000);
                    }
                }

                else
                {
                    if (CameraState == "Up")
                    {
                        MovableCamera.Rotate(0, -MathHelper.ToRadians(90) / 60);
                        MovableCamera.Position += new Vector3(0, 500 / 60, 0);
                    }

                    else if (CameraState == "Down")
                    {
                        MovableCamera.Rotate(0, MathHelper.ToRadians(90) / 60);
                        MovableCamera.Position -= new Vector3(0, 500 / 60, 0);
                    }

                    Delay--;
                }

                #endregion

                break;
            }

            #endregion

            base.Update(gameTime);
        }
Esempio n. 6
0
        protected override void LoadContent()
        {
            graphics.PreferredBackBufferHeight = Bounds.Height;
            graphics.PreferredBackBufferWidth = Bounds.Width;
            graphics.ApplyChanges();
            User32.SetWindowPos((uint)this.Window.Handle, 0, Bounds.X, Bounds.Y, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);

            spriteBatch = new SpriteBatch(GraphicsDevice);

            PanInEffect = Content.Load<Effect>("PanIn");
            PanOutEffect = Content.Load<Effect>("PanOut");

            FadeInEffect = Content.Load<Effect>("FadeIn");
            FadeOutEffect = Content.Load<Effect>("FadeOut");

            SpiralInEffect = Content.Load<Effect>("SpiralIn");
            SpiralOutEffect = Content.Load<Effect>("SpiralOut");

            if (IsLeft)
            {

                Images.Add(Content.Load<Texture2D>("Alex1"));
                Images.Add(Content.Load<Texture2D>("F22"));
                Images.Add(Content.Load<Texture2D>("Tim1"));
                Images.Add(Content.Load<Texture2D>("CPU1"));

            }

            else
            {

                Images.Add(Content.Load<Texture2D>("Megaman1"));
                Images.Add(Content.Load<Texture2D>("Megaman2"));
                Images.Add(Content.Load<Texture2D>("Megaman3"));
                Images.Add(Content.Load<Texture2D>("Megaman4"));
                Images.Add(Content.Load<Texture2D>("Megaman5"));

            }

            Mode = RandomMode();
            GeneratePrimatives(Program.Rand.Next(10, 25), Images[0]);

            FixedCamera = new TargetCamera(new Vector3(100, 50, 300), new Vector3(100, 50, 0), GraphicsDevice);
            FixedCamera.Update();

            MovableCamera = new FreeCamera(new Vector3(250, 225, 750), 0, 0, GraphicsDevice);
            MovableCamera.Update();
        }
Esempio n. 7
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            KeyboardState keyState    = Keyboard.GetState();
            Vector3       translation = Vector3.Zero;

            // Determine in which direction to move the camera
            if (keyState.IsKeyDown(Keys.W))
            {
                translation += Vector3.Up;
            }
            if (keyState.IsKeyDown(Keys.S))
            {
                translation += Vector3.Down;
            }
            if (keyState.IsKeyDown(Keys.A))
            {
                translation += Vector3.Left;
            }
            if (keyState.IsKeyDown(Keys.D))
            {
                translation += Vector3.Right;
            }
            if (keyState.IsKeyDown(Keys.F12))
            {
                this.Exit();
            }

            // Move 4 units per millisecond, independent of frame rate
            translation *= (float)(0.5 * gameTime.ElapsedGameTime.TotalMilliseconds);

            // Move the camera
            MovableCamera.Move(translation);
            MovableCamera.Update();

            Time++;

            if (Time > TransitionInTime)
            {
                if (TransitionIn)
                {
                    TransitionIn = false;
                    Time         = 0;

                    if (Mode == "Pan")
                    {
                        TransitionInTime -= 480;
                    }
                    else if (Mode == "Fade")
                    {
                        TransitionInTime = TransitionOutTime;
                    }
                    else
                    {
                        TransitionInTime = TransitionOutTime;
                    }
                }

                else
                {
                    ImageIndex++;

                    if (ImageIndex >= Images.Count)
                    {
                        ImageIndex = 0;
                    }

                    Mode = RandomMode();
                    GeneratePrimatives(Program.Rand.Next(10, 25), Images[ImageIndex]);
                    Time         = 0;
                    TransitionIn = true;
                }
            }

            base.Update(gameTime);
        }
Esempio n. 8
0
        protected override void LoadContent()
        {
            if (Handler.ToInt32() != 0)
            {
                User32.SetWindowPos((uint)this.Window.Handle, 0, 0, 0, 0, 0, 0);

                System.Drawing.Rectangle ParentRect;
                User32.GetClientRect(Handler, out ParentRect);

                User32.SetParent(this.Window.Handle, Handler);
                User32.SetWindowLong(this.Window.Handle, -16, new IntPtr(User32.GetWindowLong(this.Window.Handle, -16) | 0x40000000));

                PresentationParameters PP = GraphicsDevice.PresentationParameters;

                PP.DeviceWindowHandle = Handler;

                GraphicsDevice.Reset(PP);

                //graphics.PreferredBackBufferHeight = ParentRect.Height;
                //graphics.PreferredBackBufferWidth = ParentRect.Width;
                //graphics.ApplyChanges();
            }

            else
            {
                graphics.PreferredBackBufferHeight = Bounds.Height;
                graphics.PreferredBackBufferWidth  = Bounds.Width;
                graphics.ApplyChanges();
                User32.SetWindowPos((uint)this.Window.Handle, 0, Bounds.X, Bounds.Y, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);
            }



            spriteBatch = new SpriteBatch(GraphicsDevice);

            BE = new BasicEffect(GraphicsDevice);

            PanInEffect  = Content.Load <Effect>("PanIn");
            PanOutEffect = Content.Load <Effect>("PanOut");

            FadeInEffect  = Content.Load <Effect>("FadeIn");
            FadeOutEffect = Content.Load <Effect>("FadeOut");

            SpiralInEffect  = Content.Load <Effect>("SpiralIn");
            SpiralOutEffect = Content.Load <Effect>("SpiralOut");

            String[] Files = Directory.Exists(Location) ? Directory.GetFiles(Location) : new string[0];

            foreach (String Picture in Files)
            {
                if (Picture.Contains(".png") || Picture.Contains(".PNG") || Picture.Contains(".jpg") || Picture.Contains(".JPG"))
                {
                    FileStream FS = new FileStream(Picture, FileMode.Open);
                    Images.Add(Texture2D.FromStream(GraphicsDevice, FS));
                    FS.Close();
                }
            }

            if (Images.Count == 0)
            {
                Images.Add(Content.Load <Texture2D>("Cell"));
                Images.Add(Content.Load <Texture2D>("Japan"));
                Images.Add(Content.Load <Texture2D>("Galaxy"));
                Images.Add(Content.Load <Texture2D>("AbstractBars"));
            }

            if (TransitionMode == "Random")
            {
                Mode = RandomMode();
            }
            else
            {
                Mode = TransitionMode;
            }

            if (Order == "Random")
            {
                ImageIndex = new Random().Next(0, Images.Count);
            }
            else
            {
                ImageIndex = 0;
            }

            int Primatives = TileType == "Random" ? Program.Rand.Next(MinTiles, MaxTiles) : FixedTiles;

            GeneratePrimatives(Primatives, Images[ImageIndex]);

            MovableCamera = new FreeCamera(new Vector3(Bounds.Width / 2, Bounds.Height / 2, 10), 0, 0, GraphicsDevice, false);
            MovableCamera.Update();
        }