Beispiel #1
0
        public void Draw(DeltaTimes deltaTimes)
        {
            _camera.AspectRatio = _graphics.PreferredBackBufferWidth / (float)_graphics.PreferredBackBufferHeight;

            _graphics.GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;

            _shader.Pass(pass =>
            {
                _graphics.GraphicsDevice.BlendState = BlendState.Opaque;
                _shader.UseAlphaMask = true;

                DrawAllMeshes(pass, /*passRenderOpaque=*/ true);

                _graphics.GraphicsDevice.BlendState = AlphaBlendState;
                _shader.UseAlphaMask = false;

                DrawAllMeshes(pass, /*passRenderOpaque=*/ false);
            });
            Field.Draw();

            if (_menuState.IsMenuOpen)
            {
                _menuState.Draw(deltaTimes);
            }
        }
Beispiel #2
0
        public void Update(DeltaTimes deltaTimes)
        {
            CheckTitlLoop(layoutRendererBg);
            CheckTitlLoop(layoutRendererFg);

            if (_isInTheaterMenu)
            {
                switch (layoutRendererTheater.SelectedSequenceGroupIndex)
                {
                case 0:
                    layoutRendererTheater.FrameIndex++;
                    if (layoutRendererTheater.FrameIndex > 32)
                    {
                        layoutRendererTheater.FrameIndex = 0;
                        layoutRendererTheater.SelectedSequenceGroupIndex = 1;
                    }
                    break;

                case 1:
                    break;

                case 2:
                    layoutRendererTheater.FrameIndex++;
                    if (layoutRendererTheater.FrameIndex > 32)
                    {
                        _isInTheaterMenu = false;
                    }
                    break;
                }
            }

            if (_subMenu?.IsOpen == true)
            {
                _subMenu.Update(deltaTimes.DeltaTime);
            }
            else
            {
                if (IsIntro)
                {
                    if (InputManager.IsCross || InputManager.IsCircle)
                    {
                        SkipIntro();
                    }
                }
                else if (IsNewGameStarting)
                {
                    // block any input
                }
                else if (_isInTheaterMenu)
                {
                    ProcessInputTheaterMenu();
                }
                else
                {
                    ProcessInputMainMenu();
                }
            }
        }
Beispiel #3
0
        public void Update(DeltaTimes deltaTimes)
        {
            if (_menuState.IsMenuOpen)
            {
                _menuState.Update(deltaTimes);
                return;
            }

            if (_input.IsStart)
            {
                _menuState.OpenMenu();
            }
            else if (_enableCameraMovement)
            {
                const double Speed = 100.0;
                var          speed = (float)(deltaTimes.DeltaTime * Speed);

                if (_input.W)
                {
                    _camera.CameraPosition += Vector3.Multiply(_camera.CameraLookAtX, speed * 5);
                }
                if (_input.S)
                {
                    _camera.CameraPosition -= Vector3.Multiply(_camera.CameraLookAtX, speed * 5);
                }
                if (_input.A)
                {
                    _camera.CameraPosition -= Vector3.Multiply(_camera.CameraLookAtY, speed * 5);
                }
                if (_input.D)
                {
                    _camera.CameraPosition += Vector3.Multiply(_camera.CameraLookAtY, speed * 5);
                }

                if (_input.Up)
                {
                    _camera.CameraRotationYawPitchRoll += new Vector3(0, 0, 1 * speed);
                }
                if (_input.Down)
                {
                    _camera.CameraRotationYawPitchRoll -= new Vector3(0, 0, 1 * speed);
                }
                if (_input.Left)
                {
                    _camera.CameraRotationYawPitchRoll += new Vector3(1 * speed, 0, 0);
                }
                if (_input.Right)
                {
                    _camera.CameraRotationYawPitchRoll -= new Vector3(1 * speed, 0, 0);
                }

                foreach (var entity in _objectEntities.Where(x => x.IsMeshLoaded))
                {
                    entity.Update((float)deltaTimes.DeltaTime);
                }
            }
        }
Beispiel #4
0
        public void Update(DeltaTimes deltaTimes)
        {
            if (_menuState.IsMenuOpen)
            {
                _menuState.Update(deltaTimes);
                return;
            }

            if (_input.IsStart)
            {
                _menuState.OpenMenu();
            }
            else
            {
                const double Speed = 100.0;
                var          speed = (float)(deltaTimes.DeltaTime * Speed);

                if (Kernel.DebugMode)
                {
                    if (_input.W)
                    {
                        _camera.CameraPosition += Vector3.Multiply(_camera.CameraLookAtX, speed * 5);
                    }
                    if (_input.S)
                    {
                        _camera.CameraPosition -= Vector3.Multiply(_camera.CameraLookAtX, speed * 5);
                    }
                    if (_input.A)
                    {
                        _camera.CameraPosition += Vector3.Multiply(_camera.CameraLookAtY, speed * 5);
                    }
                    if (_input.D)
                    {
                        _camera.CameraPosition -= Vector3.Multiply(_camera.CameraLookAtY, speed * 5);
                    }

                    if (_input.Up)
                    {
                        _camera.CameraRotationYawPitchRoll += new Vector3(0, 0, 1 * speed);
                    }
                    if (_input.Down)
                    {
                        _camera.CameraRotationYawPitchRoll -= new Vector3(0, 0, 1 * speed);
                    }
                    if (_input.Left)
                    {
                        _camera.CameraRotationYawPitchRoll -= new Vector3(1 * speed, 0, 0);
                    }
                    if (_input.Right)
                    {
                        _camera.CameraRotationYawPitchRoll += new Vector3(1 * speed, 0, 0);
                    }
                }

                Field.Update(deltaTimes.DeltaTime);
            }
        }
Beispiel #5
0
        public void Draw(DeltaTimes deltaTimes)
        {
            _camera.AspectRatio = _graphics.PreferredBackBufferWidth / (float)_graphics.PreferredBackBufferHeight;


            _graphics.GraphicsDevice.RasterizerState = new RasterizerState()
            {
                CullMode = CullMode.CullClockwiseFace
            };
            _graphics.GraphicsDevice.DepthStencilState = new DepthStencilState();
            _graphics.GraphicsDevice.BlendState        = DefaultBlendState;

            _shader.Pass(pass =>
            {
                _shader.ProjectionView = _camera.Projection;
                _shader.WorldView      = _camera.World;
                _shader.ModelView      = Matrix.Identity;
                pass.Apply();

                foreach (var mesh in _models)
                {
                    if (mesh.MeshDescriptors != null)
                    {
                        RenderMeshNew(pass, mesh, true);
                        RenderMeshNew(pass, mesh, false);
                    }
                    else
                    {
                        RenderMesh(pass, mesh);
                    }
                }

                foreach (var entity in _objectEntities.Where(x => x.Mesh != null))
                {
                    _shader.ProjectionView = _camera.Projection;
                    _shader.WorldView      = _camera.World;
                    _shader.ModelView      = entity.GetMatrix();
                    pass.Apply();

                    RenderMesh(pass, entity.Mesh);
                }

                foreach (var entity in _bobEntities)
                {
                    _shader.ProjectionView = _camera.Projection;
                    _shader.WorldView      = _camera.World;
                    _shader.ModelView      = entity.GetMatrix();
                    pass.Apply();

                    RenderMesh(pass, _bobModels[entity.BobIndex]);
                }
            });
        }
Beispiel #6
0
        public void Draw(DeltaTimes deltaTimes)
        {
            _camera.AspectRatio = _graphics.PreferredBackBufferWidth / (float)_graphics.PreferredBackBufferHeight;


            _graphics.GraphicsDevice.RasterizerState = new RasterizerState()
            {
                CullMode = CullMode.CullCounterClockwiseFace
            };
            _graphics.GraphicsDevice.DepthStencilState = new DepthStencilState();
            _graphics.GraphicsDevice.BlendState        = DefaultBlendState;

            _shader.Pass(pass =>
            {
                _shader.ProjectionView = _camera.Projection;
                _shader.WorldView      = _camera.World;
                _shader.ModelView      = Matrix.Identity;
                pass.Apply();

                foreach (var mesh in _models)
                {
                    if (mesh.MeshDescriptors != null)
                    {
                        RenderMeshNew(pass, mesh, true);
                        RenderMeshNew(pass, mesh, false);
                    }
                    else
                    {
                        RenderMesh(pass, mesh);
                    }
                }

                foreach (var bobDesc in _bobDescs)
                {
                    var modelView = Matrix.CreateRotationX(bobDesc.RotationX) *
                                    Matrix.CreateRotationY(bobDesc.RotationY) *
                                    Matrix.CreateRotationZ(bobDesc.RotationZ) *
                                    Matrix.CreateScale(bobDesc.ScalingX, bobDesc.ScalingY, bobDesc.ScalingZ) *
                                    Matrix.CreateTranslation(bobDesc.PositionX, bobDesc.PositionY, bobDesc.PositionZ);

                    _shader.ProjectionView = _camera.Projection;
                    _shader.WorldView      = _camera.World;
                    _shader.ModelView      = modelView;
                    pass.Apply();

                    RenderMesh(pass, _bobModels[bobDesc.BobIndex]);
                }
            });
        }
Beispiel #7
0
        public void Draw(DeltaTimes deltaTimes)
        {
            layoutRendererBg.Draw();

            if (!(IsIntro || IsNewGameStarting))
            {
                layoutRendererFg.Draw();
            }

            if (_isInTheaterMenu)
            {
                layoutRendererTheater.Draw();
            }

            drawing.Flush();
        }
Beispiel #8
0
        public void Update(DeltaTimes deltaTimes)
        {
            if (_enableCameraMovement)
            {
                const double Speed = 100.0;
                var          speed = (float)(deltaTimes.DeltaTime * Speed);

                if (_input.W)
                {
                    _camera.CameraPosition += Vector3.Multiply(_camera.CameraLookAtX, speed * 5);
                }
                if (_input.S)
                {
                    _camera.CameraPosition -= Vector3.Multiply(_camera.CameraLookAtX, speed * 5);
                }
                if (_input.A)
                {
                    _camera.CameraPosition -= Vector3.Multiply(_camera.CameraLookAtY, speed * 5);
                }
                if (_input.D)
                {
                    _camera.CameraPosition += Vector3.Multiply(_camera.CameraLookAtY, speed * 5);
                }

                if (_input.Up)
                {
                    _camera.CameraRotationYawPitchRoll += new Vector3(0, 0, 1 * speed);
                }
                if (_input.Down)
                {
                    _camera.CameraRotationYawPitchRoll -= new Vector3(0, 0, 1 * speed);
                }
                if (_input.Left)
                {
                    _camera.CameraRotationYawPitchRoll += new Vector3(1 * speed, 0, 0);
                }
                if (_input.Right)
                {
                    _camera.CameraRotationYawPitchRoll -= new Vector3(1 * speed, 0, 0);
                }
            }
        }
Beispiel #9
0
        public void Draw(DeltaTimes deltaTimes)
        {
            layoutRendererBg.Draw();

            if (!(IsIntro || IsNewGameStarting))
            {
                layoutRendererFg.Draw();
            }

            if (_isInTheaterMenu)
            {
                layoutRendererTheater.Draw();
            }

            else if (_subMenu?.IsOpen == true)
            {
                _subMenu.Draw();
            }

            drawing.Flush();
        }
Beispiel #10
0
        public void Update(DeltaTimes deltaTimes)
        {
            if (_menuState.IsMenuOpen)
            {
                _menuState.Update(deltaTimes);
                return;
            }

            if (_input.Triggered.SpecialRight)
            {
                _menuState.OpenMenu();
            }
            else
            {
                const double Speed = 100.0;
                var          speed = (float)(deltaTimes.DeltaTime * Speed);
                _camera.CameraPosition             += Vector3.Multiply(_camera.CameraLookAtX, _input.AxisLeft.Y * speed * 5);
                _camera.CameraPosition             += Vector3.Multiply(_camera.CameraLookAtY, -_input.AxisLeft.X * speed * 5);
                _camera.CameraRotationYawPitchRoll -= new Vector3(0, 0, -_input.AxisRight.Y * speed);
                _camera.CameraRotationYawPitchRoll += new Vector3(_input.AxisRight.X * speed, 0, 0);

                Field.Update(deltaTimes.DeltaTime);
            }
        }
Beispiel #11
0
        public void Draw(DeltaTimes deltaTimes)
        {
            _camera.AspectRatio = _graphics.PreferredBackBufferWidth / (float)_graphics.PreferredBackBufferHeight;


            _graphics.GraphicsDevice.RasterizerState = new RasterizerState()
            {
                CullMode = CullMode.CullClockwiseFace
            };
            _graphics.GraphicsDevice.DepthStencilState = new DepthStencilState();

            _shader.Pass(pass =>
            {
                _shader.ProjectionView = _camera.Projection;
                _shader.WorldView      = _camera.World;
                pass.Apply();

                foreach (var mesh in _models)
                {
                    var index = 0;
                    foreach (var part in mesh.Parts)
                    {
                        if (part.Indices.Length == 0)
                        {
                            continue;
                        }

                        var textureIndex = part.TextureId & 0xffff;
                        if (textureIndex < mesh.Textures.Length)
                        {
                            var texture = mesh.Textures[textureIndex];
                            if (_shader.Texture0 != texture.Texture2D)
                            {
                                _shader.Texture0 = texture.Texture2D;
                                switch (texture.ModelTexture.TextureAddressMode.AddressU)
                                {
                                case ModelTexture.TextureWrapMode.Clamp:
                                    _shader.TextureRegionU   = KingdomShader.DefaultTextureRegion;
                                    _shader.TextureWrapModeU = TextureWrapMode.Clamp;
                                    break;

                                case ModelTexture.TextureWrapMode.Repeat:
                                    _shader.TextureRegionU   = KingdomShader.DefaultTextureRegion;
                                    _shader.TextureWrapModeU = TextureWrapMode.Repeat;
                                    break;

                                case ModelTexture.TextureWrapMode.RegionClamp:
                                    _shader.TextureRegionU   = texture.RegionU;
                                    _shader.TextureWrapModeU = TextureWrapMode.Clamp;
                                    break;

                                case ModelTexture.TextureWrapMode.RegionRepeat:
                                    _shader.TextureRegionU   = texture.RegionU;
                                    _shader.TextureWrapModeU = TextureWrapMode.Repeat;
                                    break;
                                }
                                switch (texture.ModelTexture.TextureAddressMode.AddressV)
                                {
                                case ModelTexture.TextureWrapMode.Clamp:
                                    _shader.TextureRegionV   = KingdomShader.DefaultTextureRegion;
                                    _shader.TextureWrapModeV = TextureWrapMode.Clamp;
                                    break;

                                case ModelTexture.TextureWrapMode.Repeat:
                                    _shader.TextureRegionV   = KingdomShader.DefaultTextureRegion;
                                    _shader.TextureWrapModeV = TextureWrapMode.Repeat;
                                    break;

                                case ModelTexture.TextureWrapMode.RegionClamp:
                                    _shader.TextureRegionV   = texture.RegionV;
                                    _shader.TextureWrapModeV = TextureWrapMode.Clamp;
                                    break;

                                case ModelTexture.TextureWrapMode.RegionRepeat:
                                    _shader.TextureRegionV   = texture.RegionV;
                                    _shader.TextureWrapModeV = TextureWrapMode.Repeat;
                                    break;
                                }

                                pass.Apply();
                            }
                        }

                        _graphics.GraphicsDevice.DrawUserIndexedPrimitives(
                            PrimitiveType.TriangleList,
                            mesh.Segments[index].Vertices,
                            0,
                            mesh.Segments[index].Vertices.Length,
                            part.Indices,
                            0,
                            part.Indices.Length / 3);

                        index = (index + 1) % mesh.Segments.Length;
                    }
                }
            });
        }