Exemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            this.bodyGraphics.OrientationMatrix = base.OrientationMatrix;
            this.bodyGraphics.Translation = base.Translation;

            this.bodyGraphics.Update(gameTime);
            base.Update(gameTime);
        }
Exemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            var t = (float)gameTime.EllapsedGameTime.TotalSeconds;

            var keyboardState = Game.Keyboard.GetCurrentState();
            var mouseState = Game.Mouse.GetCurrentState();

            float mouseX = -mouseState.X;
            float mouseY = -mouseState.Y;

            LookAt = Vector3.Transform(LookAt, Matrix.RotationY(mouseX * MoveSpeed / 80f)).ToVector3();
            LookAt.Normalize();

            var lookAtNormal = new Vector3(-LookAt.Z, LookAt.Y, LookAt.X);
            LookAt = Vector3.Transform(LookAt, Matrix.RotationAxis(lookAtNormal, mouseY * MoveSpeed / 80f)).ToVector3();

            var q = Vector3.Zero;

            if (keyboardState.IsPressed(Key.W))
            {
                q += Vector3.UnitY * MoveSpeed;
            }

            if (keyboardState.IsPressed(Key.S))
            {
                q -= Vector3.UnitY * MoveSpeed;
            }

            if (keyboardState.IsPressed(Key.A))
            {
                q -= Vector3.UnitX * MoveSpeed;
            }

            if (keyboardState.IsPressed(Key.D))
            {
                q += Vector3.UnitX * MoveSpeed;
            }

            if (keyboardState.IsPressed(Key.Q))
            {
                q += Vector3.UnitZ * MoveSpeed * 2;
            }

            if (keyboardState.IsPressed(Key.E))
            {
                q -= Vector3.UnitZ * MoveSpeed * 2;
            }

            Position += q * t;
            LookAt = new Vector3(Position.X, Position.Y, 0);
            UpdateMatrices();
            //System.Windows.Forms.Cursor.Position = new Point(200, 200);
            base.Update(gameTime);
        }
Exemplo n.º 3
0
        public override void Draw(GameTime gameTime)
        {
            if (Settings.GraphicsSettings.VisibleViewTriangle)
                this.viewTriangleGraphics.Draw(gameTime);

            if (Settings.GraphicsSettings.VisibleSmellingCircle)
                this.smellingGraphics.Draw(gameTime);

            if (Settings.GraphicsSettings.VisibleBody)
                this.bodyGraphics.Draw(gameTime);

            base.Draw(gameTime);
        }
Exemplo n.º 4
0
 public override void Update(GameTime gameTime)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
 }
Exemplo n.º 6
0
 public override void Draw(GameTime gameTime)
 {
     base.Draw(gameTime);
 }
Exemplo n.º 7
0
 public virtual void Update(GameTime gameTime)
 {
 }
Exemplo n.º 8
0
 public virtual void Draw(GameTime gameTime)
 {
 }
Exemplo n.º 9
0
 public override void Update(GameTime gameTime)
 {
     this.UpdateEffect();
     base.Update(gameTime);
 }
Exemplo n.º 10
0
 public override void Draw(GameTime gameTime)
 {
     this.DrawCircle();
     base.Draw(gameTime);
 }
Exemplo n.º 11
0
        public override void Update(GameTime gameTime)
        {
            var t = (float)gameTime.EllapsedGameTime.TotalSeconds;

            AI(t);
            this.UpdateGraphics(gameTime);
            base.Update(gameTime);
        }
Exemplo n.º 12
0
        private void UpdateGraphics(GameTime gameTime)
        {
            if (Settings.GraphicsSettings.VisibleViewTriangle)
            {
                this.viewTriangleGraphics.OrientationMatrix = base.OrientationMatrix;
                this.viewTriangleGraphics.Translation = base.Translation;
                this.viewTriangleGraphics.Update(gameTime);

                // gyors teszt, hogy a kód és a grafika szinkronban van-e
                var sawHuman = false;

                foreach (var human in this.Game.World.AsObjects<HumanCharacter>())
                {
                    var viewTriangle = GeometryHelper.GetViewTriangle(this.Translation, this.OrientationVector, this.ViewDistance, this.ViewAngle);

                    // beware, ez most csak akkor detektál, ha az ember középpontja (origója) a háromszögbe esik
                    // nem elég, ha metszik a háromszög a kört
                    if (CollisionHelper.IsPointInTriangle(human.Translation, viewTriangle))
                    {
                        sawHuman = true;
                        break;
                    }
                }

                if (sawHuman)
                    this.viewTriangleGraphics.Color = Color.White;
                else
                    this.viewTriangleGraphics.Color = Color.Green;

            }

            if (Settings.GraphicsSettings.VisibleSmellingCircle)
            {
                this.smellingGraphics.Translation = base.Translation;
                this.smellingGraphics.Update(gameTime);

                // gyors teszt, hogy a kód és a grafika szinkronban van-e
                var smelledHuman = false;

                foreach (var human in this.Game.World.AsObjects<HumanCharacter>())
                {
                    var distance = Vector3.Distance(human.Translation, this.Translation);

                    if (distance < (this.SmellingRadius + human.Radius))
                    {
                        smelledHuman = true;
                        break;
                    }
                }

                if (smelledHuman)
                    this.smellingGraphics.Color = Color.White;
                else
                    this.smellingGraphics.Color = Color.Green;

            }

            if (Settings.GraphicsSettings.VisibleBody)
            {
                this.bodyGraphics.OrientationMatrix = base.OrientationMatrix;
                this.bodyGraphics.Translation = base.Translation;
                this.bodyGraphics.Update(gameTime);
            }
        }
Exemplo n.º 13
0
 public override void Draw(GameTime gameTime)
 {
     this.bodyGraphics.Draw(gameTime);
     base.Draw(gameTime);
 }