コード例 #1
0
        public void Update(GameTime gameTime, float currentPhase /*, Vector3 headPos*/, float shipAngle)
        {
            Vector2 offset = Tunnel.GetTunnelOffset(currentPhase);

            this.position = Vector3.Transform(this.up * distanceFromCentre, Matrix.CreateRotationZ(shipAngle)) + new Vector3(-offset.X, offset.Y, 0.0f);
            Matrix cameraRotation = Matrix.CreateRotationZ(shipAngle + (float)Math.PI);

            this.rotatedUp = Vector3.Transform(this.up, cameraRotation);
            Vector3 direction = Tunnel.GetTunnelDirection(currentPhase);

            direction.X = -direction.X;

            //Matrix headRotationMatrix = Matrix.CreateFromAxisAngle(this.up, (float)Math.Atan(headPos.X));
            //Vector3 newHeadPos = new Vector3(-1.0f * headPos.X, -1.0f * headPos.Y, 1.0f * headPos.Z);
            //newHeadPos = Vector3.Transform(newHeadPos, headRotationMatrix * cameraRotation);
            //newHeadPos.X *= headMovementScaleFactor.X;
            //newHeadPos.Y *= headMovementScaleFactor.Y;
            //newHeadPos.Z *= headMovementScaleFactor.Z;

            //projects to a point far in the distance
            Vector3 down = new Vector3(0.0f, -(lookAheadDistance * (float)Math.Tan(lookDownAngleDegrees * (float)Math.PI / 180.0f)), 0.0f);

            this.cameraLookAt = position + (direction * lookAheadDistance) + Vector3.Transform(down, cameraRotation);

            //this.cameraLookAt = Vector3.Transform(this.cameraLookAt, cameraRotation * Matrix.CreateRotationX(lookDownAngleDegrees * (float)(Math.PI / 180)));
            View = Matrix.CreateLookAt(this.position /*+ newHeadPos*/, this.cameraLookAt, this.rotatedUp);
        }
コード例 #2
0
        public static Vector3 GetTunnelDirection(float Phase)
        {
            float   deltaPhase      = 0.01f;
            Vector3 currentPosition = new Vector3(Tunnel.GetTunnelOffset(Phase), Phase);
            Vector3 newPosition     = new Vector3(Tunnel.GetTunnelOffset(Phase + deltaPhase), Phase + deltaPhase);

            return(Vector3.Normalize(newPosition - currentPosition));
            //return new Vector3(0.0f, 0.0f, 1.0f);
        }
コード例 #3
0
        public ElementManager(ContentRepository repo, SceneInterface si,
#if WPF
                              MonoGameControl.
#else
                              Microsoft.Xna.Framework.
#endif
                              Game game,
                              ICamera camera, Tunnel tunnel, Player player, MusicPlayer music)
        {
            ExplosionParticles = new ParticleSystem(game, game.Content, GetExplosionSettings());
            ExplosionParticles.Initialize();
            FireParticles = new ParticleSystem(game, game.Content, GetFireSettings());
            FireParticles.Initialize();
            SmokeParticles = new ParticleSystem(game, game.Content, GetSmokeSettings());
            SmokeParticles.Initialize();
            StarsParticles = new ParticleSystem(game, game.Content, GetStarsSettings());
            StarsParticles.Initialize();

            BombFactory = new ElementFactory <Bomb>(50, repo, game, camera, (ContentRepository r,
#if WPF
                                                                             MonoGameControl.
#else
                                                                             Microsoft.Xna.Framework.
#endif
                                                                             Game g, ICamera c) => new Bomb(r, g, c), this);
            StarFactory = new ElementFactory <Star>(50, repo, game, camera, (ContentRepository r,
#if WPF
                                                                             MonoGameControl.
#else
                                                                             Microsoft.Xna.Framework.
#endif
                                                                             Game g, ICamera c) => new Star(r, g, c), this);
            Music = music;
            Scene = new Scene();
            Scene.Submit(player);
            _sceneInterface = si;
            _sceneInterface.Submit(Scene);

            _repo = repo;
            _game = game;

            _camera = camera;
            _tunnel = tunnel;
            _player = player;

            _tunnel.TunnelSectionCreated    += TunnelSectionCreated;
            _tunnel.TunnelSectionSetZCalled += TunnelSectionSetZCalled;

            StarFactory.ObjectRemoved += (o, i) => {
                var data = LoopGame.Instance.GameObjects.GetValue("Objects");
                LoopGame.Instance.GameObjects.TryUpdate("Objects", new Vector3(i.Angle, data.Y, data.Z));
            };
            BombFactory.ObjectRemoved += (o, i) => {
                var data = LoopGame.Instance.GameObjects.GetValue("Objects");
                LoopGame.Instance.GameObjects.TryUpdate("Objects", new Vector3(data.X, i.Angle, data.Z));
            };
        }
コード例 #4
0
        public void ConstructCurves()
        {
            Vector2 offset;

            for (int i = 0; i <= vertices.GetUpperBound(0); i++)
            {
                offset = Tunnel.GetTunnelOffset(this.PhaseAtStart - vertices[i].Position.Z + this.ZAtStart);
                vertices[i].Position.X += offset.X;
                vertices[i].Position.Y += offset.Y;
            }
        }
コード例 #5
0
        public ElementManager(ContentRepository repo, SceneInterface si,
#if WPF
                              MonoGameControl.
#else
                              Microsoft.Xna.Framework.
#endif
                              Game game,
                              ICamera camera, Tunnel tunnel, Player player, MusicPlayer music)
        {
            ExplosionParticles = new ParticleSystem(game, game.Content, GetExplosionSettings());
            ExplosionParticles.Initialize();
            FireParticles = new ParticleSystem(game, game.Content, GetFireSettings());
            FireParticles.Initialize();
            SmokeParticles = new ParticleSystem(game, game.Content, GetSmokeSettings());
            SmokeParticles.Initialize();
            StarsParticles = new ParticleSystem(game, game.Content, GetStarsSettings());
            StarsParticles.Initialize();

            BombFactory = new ElementFactory <Bomb>(50, repo, game, camera, (ContentRepository r,
#if WPF
                                                                             MonoGameControl.
#else
                                                                             Microsoft.Xna.Framework.
#endif
                                                                             Game g, ICamera c) => new Bomb(r, g, c), this);
            StarFactory = new ElementFactory <Star>(50, repo, game, camera, (ContentRepository r,
#if WPF
                                                                             MonoGameControl.
#else
                                                                             Microsoft.Xna.Framework.
#endif
                                                                             Game g, ICamera c) => new Star(r, g, c), this);
            Music = music;
            Scene = new Scene();
            Scene.Submit(player);
            _sceneInterface = si;
            _sceneInterface.Submit(Scene);

            _repo = repo;
            _game = game;

            _camera = camera;
            _tunnel = tunnel;
            _player = player;

            _tunnel.TunnelSectionCreated    += TunnelSectionCreated;
            _tunnel.TunnelSectionSetZCalled += TunnelSectionSetZCalled;
        }
コード例 #6
0
        public void Update(GameTime gameTime, float change, float tiltAngle)
        {
            _tiltRotation = tiltAngle;

            Angle += change;

            Vector3 direction = Tunnel.GetTunnelDirection(_tunnel.CurrentPhase + _zDistance);

            _position = new Vector3(0.0f, _distanceFromCenter, _zDistance);
            _position = Vector3.Transform(_position, Matrix.CreateRotationZ(Angle));
            Matrix m = _world * Matrix.CreateRotationZ(Angle - _tiltRotation);

            m.Translation  = _position + _tunnel.GetTunnelCentrePos(_zDistance);
            World          = m;
            _tiltRotation *= 0.9f;
            // update position
            base.Update(gameTime);
        }
コード例 #7
0
ファイル: Player.cs プロジェクト: EduardoAntequera/OpenFeasyo
        public void Update(GameTime gameTime, float change, float tiltAngle)
        {
            _tiltRotation = tiltAngle;

            Angle += change;
            Vector3 direction = Tunnel.GetTunnelDirection(_tunnel.CurrentPhase + _zDistance);

            //Matrix orientation = Matrix.CreateFromYawPitchRoll((float)Math.Atan(direction.X), (float)Math.Atan(-direction.Y), 0/*(Angle /*+ (float)Math.PI - this.rollAngle*/);

            _position = new Vector3(0.0f, _distanceFromCenter, _zDistance);
            _position = Vector3.Transform(_position, Matrix.CreateRotationZ(Angle));
            Matrix m = _world * Matrix.CreateRotationZ(Angle - _tiltRotation);

            m.Translation  = _position + _tunnel.GetTunnelCentrePos(_zDistance);
            World          = m;
            _tiltRotation *= 0.9f;
            // update position
            base.Update(gameTime);
        }
コード例 #8
0
        public float DeltaPhase(GameTime gameTime)
        {
            Vector3 currentDirection  = Tunnel.GetTunnelDirection(this.currentPhase);
            float   distanceTravelled = (float)gameTime.ElapsedGameTime.TotalMilliseconds * this.speed / 1000.0f;
            float   deltaDistance     = distanceTravelled / (float)Tunnel.deltaResolution;

            Vector3 deltaPosition;
            Vector3 currentPosition = new Vector3(Tunnel.GetTunnelOffset(this.currentPhase), this.currentPhase);

            for (int i = 0; i < deltaResolution; i++)
            {
                deltaPosition = currentDirection * deltaDistance;
                Vector2 realXY = Tunnel.GetTunnelOffset(currentPhase + deltaPosition.Z);
                deltaPosition.X  = realXY.X;
                deltaPosition.Y  = realXY.Y;
                currentPosition += deltaPosition;
            }

            return(currentPosition.Z - currentPhase);
        }
コード例 #9
0
ファイル: Player.cs プロジェクト: EduardoAntequera/OpenFeasyo
        public Player(ContentRepository repo,
#if WPF
                      MonoGameControl.
#else
                      Microsoft.Xna.Framework.
#endif
                      Game game, Camera camera, Tunnel tunnel)
            : base(
                "Player",
                new Box(MathConverter.Convert(new Vector3(0, 0, 20)), 4f, 1f, 2.5f),
                repo.LoadModel("Models/Ship2"),
                Matrix.CreateScale(0.0025f) * Matrix.CreateRotationX((float)Math.PI),
                game, camera)
        {
            _world              = World;
            _tunnel             = tunnel;
            Angle               = 0f;
            _distanceFromCenter = 7.8f;
            _zDistance          = 6f;
            _tiltRotation       = 0f;
        }
コード例 #10
0
        public Vector3 GetTunnelCentrePos(float deltaPhase)
        {
            Vector2 offset = Tunnel.GetTunnelOffset(this.currentPhase + deltaPhase);

            return(new Vector3(-offset.X, offset.Y, deltaPhase));
        }