public void Update(GameTime gameTime, _Helicopter heli)
        {
            BoundingBox   bBox    = heli.GetBoundingBox();
            _MachineState state   = heli.GetMachineState();
            Vector3       heliPos = heli.Position;

            this.SetupView(this.position, this.target, this.up);
            this.SetupProjection();

            this.CameraRotation(gameTime);
            if (cameraMove == true)
            {
                this.CameraTranslation(gameTime);
            }

            this.view  = Matrix.Identity;
            this.view *= Matrix.CreateRotationX(MathHelper.ToRadians(rotation.X));
            this.view *= Matrix.CreateRotationY(MathHelper.ToRadians(rotation.Y));

            this.view *= Matrix.CreateTranslation(this.position);
            this.view  = Matrix.Invert(this.view);

            this.TranslateBoundingBox();

            if (this.boundingBox.Intersects(bBox))
            {
                if (state == _MachineState.On)
                {
                    cameraMove = false;

                    this.view *= Matrix.CreateRotationY(MathHelper.ToRadians(-180));
                    //this.view *= Matrix.CreateRotationX(MathHelper.ToRadians(10));
                }

                this.view *= Matrix.CreateTranslation(-heliPos);

                if (state == _MachineState.Off && cameraMove == false)
                {
                    Console.WriteLine("Saiu");
                    this.position = this.position + new Vector3(0, 30, 55);
                    this.view    *= Matrix.CreateRotationY(MathHelper.ToRadians(-180));
                    this.view    *= Matrix.CreateRotationX(MathHelper.ToRadians(10));
                    cameraMove    = true;
                }
            }

            //Console.WriteLine("BoxC: " + this.boundingBox.ToString());
            //Console.WriteLine("BoxH: " + bBox.ToString());
            //Console.WriteLine("State: " + state.ToString());
        }
Example #2
0
        public void Update(GameTime gameTime)
        {
            foreach (_Quad w in sides)
            {
                w.SetMatrixIndetity();
            }

            this.sides[1].SetMatrixIndetity();
            this.sides[1].CreateRotation(_TransformOrientation.X, -45);
            this.sides[1].CreateTranslation(0, 9.5f, -1.5f);

            this.sides[8].SetMatrixIndetity();
            this.sides[8].CreateRotation(_TransformOrientation.X, -45);
            this.sides[8].CreateTranslation(-5, 8.25f, -2.75f);

            this.sides[15].SetMatrixIndetity();
            this.sides[15].CreateRotation(_TransformOrientation.X, -45);
            this.sides[15].CreateTranslation(5, 8.25f, -2.75f);

            angle += 4f;
            foreach (_Quad w in backHelixSides)
            {
                w.SetMatrixIndetity();
                if (helixOn)
                {
                    w.CreateRotation(_TransformOrientation.X, angle);
                }
                w.CreateTranslation(1, 6.5f, -24.5f);
            }

            foreach (_Quad w in topHelixSides)
            {
                w.SetMatrixIndetity();
                if (helixOn)
                {
                    w.CreateRotation(_TransformOrientation.Y, angle);
                }
                w.CreateTranslation(0, 12.5f, -6f);
            }

            //maquina de estados
            switch (state)
            {
            case _MachineState.Off:
                helixOn = false;
                aux    += gameTime.ElapsedGameTime.Milliseconds * 0.0008f;
                if (aux >= 5)
                {
                    state = _MachineState.On;
                }
                break;

            case _MachineState.On:
                helixOn = true;
                aux    -= gameTime.ElapsedGameTime.Milliseconds * 0.0008f;
                if (aux <= 0)
                {
                    state = _MachineState.FlyingUp;
                }
                break;

            case _MachineState.FlyingUp:
                helixOn = true;
                this.CreateTranslation(0, aux, 0);

                aux += gameTime.ElapsedGameTime.Milliseconds * 0.0008f;
                if (aux >= 5)
                {
                    state = _MachineState.Flying;
                }
                break;

            case _MachineState.Flying:
                helixOn = true;
                this.CreateTranslation(0, aux, 0);

                aux2 += gameTime.ElapsedGameTime.Milliseconds * 0.0008f;
                if (aux2 >= 5)
                {
                    state = _MachineState.FlyingDown;
                    aux2  = 0;
                }
                break;

            case _MachineState.FlyingDown:
                helixOn = true;
                this.CreateTranslation(0, aux, 0);
                aux -= gameTime.ElapsedGameTime.Milliseconds * 0.0008f;
                if (aux <= 0)
                {
                    state = _MachineState.Off;
                }
                break;

            default:
                state = _MachineState.Off;
                break;
            }
            //fim maquina de estados
            //Console.WriteLine(this.world.ToString());
            //Console.WriteLine("Position: " + position);
            //this.TranslateBoundingBox();
            //Console.WriteLine("Position: " + this.position);
            Console.WriteLine("BoxHeli: " + this.boundingBox.ToString());
        }