Esempio n. 1
0
        /// <summary>
        /// The update.
        /// </summary>
        /// <param name="gameTime">
        /// The game time.
        /// </param>
        public override void Update(GameTime gameTime)
        {
            this.position   = Hero.GetHeroPosition() + this.positionOffset;
            this.lookVector = Hero.GetHeroPosition() + this.lookatOffset;

            this.View = Matrix.CreateLookAt(this.position, this.lookVector, Vector3.Up);

            if (this.lastDirection != Hero.GetHeroDirection())
            {
                this.targetMultiplier *= -1.0f;
                this.lastDirection     = Hero.GetHeroDirection();
            }

            if (this.targetMultiplier != this.multiplier)
            {
                this.multiplier += 0.025f * this.targetMultiplier;

                if (this.multiplier > 1.0f)
                {
                    this.multiplier = 1.0f;
                }
                else if (this.multiplier < -1.0f)
                {
                    this.multiplier = -1.0f;
                }

                this.lookatOffset.X   = 15.0f * this.multiplier;
                this.positionOffset.X = 15.0f * this.multiplier;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterFollowCamera"/> class.
 /// </summary>
 /// <param name="game">
 /// The game.
 /// </param>
 /// <param name="position">
 /// The position.
 /// </param>
 public CharacterFollowCamera(Game game, Vector3 position)
     : base(game, position)
 {
     this.lastDirection    = ModelDirection.Right;
     this.multiplier       = 1.0f;
     this.targetMultiplier = 1.0f;
     this.lookatOffset     = new Vector3(15.0f * this.multiplier, 10.0f, 0.0f);
     this.positionOffset   = new Vector3(15.0f * this.multiplier, 15.0f, 60.0f);
 }
Esempio n. 3
0
        public LinearModel(int rows, int columns, ModelDirection direction)
        {
            m_rows      = rows;
            m_cols      = columns;
            m_direction = direction;

            m_rowLines    = new List <Line2D>();
            m_columnLines = new List <Line2D>();

            m_gridPoints = new Point[m_rows, m_cols];
            m_polygons   = new Polygon2D[m_rows - 1, m_cols - 1];
        }
Esempio n. 4
0
 public FlipDirectionAnimationState(object _thisObject, string _animationName, ModelDirection _wantedDirection)
     : base(_thisObject, _animationName)
 {
     wantedDirection = _wantedDirection;
     this.name       = _animationName + wantedDirection + "_FlipAnimationState";
 }
Esempio n. 5
0
        /// <summary>
        /// The update.
        /// </summary>
        /// <param name="gameTime">
        /// The game time.
        /// </param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            timeSinceLifeDecrease += gameTime.ElapsedGameTime.TotalSeconds;
            if (targetLife < life)
            {
                life -= 0.5f * gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
                if (targetLife > life)
                {
                    life = targetLife;
                }
            }
            else if (targetLife > life)
            {
                life += 0.5f * gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
                if (targetLife < life)
                {
                    life = targetLife;
                }
            }
            if (!Dead)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Space) && Math.Abs(PhysicsBody.LinearVelocity.Y) <= 0.03f)
                {
                    this.PhysicsBody.ApplyImpulse(ref this.jumpImpulse);
                }

                if (Keyboard.GetState().IsKeyDown(Keys.A))
                {
                    Position2D = new Vector2(Position2D.X - 0.1f, Position2D.Y);
                    Walk();
                    if (ModelDirection == ModelDirection.Right)
                    {
                        Flip();
                    }
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.D))
                {
                    Position2D = new Vector2(Position2D.X + 0.1f, Position2D.Y);
                    Walk();
                    if (ModelDirection == ModelDirection.Left)
                    {
                        Flip();
                    }
                }
                else
                {
                    Idle();
                }

                if (Keyboard.GetState().IsKeyDown(Keys.O) && lastState.IsKeyUp(Keys.O))
                {
                    IncreaseLife();
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.L) && lastState.IsKeyUp(Keys.L))
                {
                    DecreaseLife();
                }
                if (targetLife == 0.0f)
                {
                    Die();
                }
            }

            this.lastState = Keyboard.GetState();

            this.World         = this.Rotation * this.Translation;
            HeroPosition       = this.Position3D;
            HeroModelDirection = this.ModelDirection;
        }