コード例 #1
0
ファイル: TestSoftParticles.cs プロジェクト: Keilerr/csat
        public override void Update(float time)
        {
            if (Keyboard[Key.Escape])
            {
                Tests.NextTest = true;
            }

            // ohjaus
            float spd = time * 20;

            if (Keyboard[Key.ShiftLeft] || Keyboard[Key.ShiftRight])
            {
                spd *= 4;
            }
            if (Keyboard[Key.W])
            {
                camera.Move(spd);
            }
            if (Keyboard[Key.S])
            {
                camera.Move(-spd);
            }
            if (Keyboard[Key.A])
            {
                camera.Strafe(-spd);
            }
            if (Keyboard[Key.D])
            {
                camera.Strafe(spd);
            }
            if (Mouse[MouseButton.Left])
            {
                camera.Rotation.Y -= Mouse.X - oldMouseX;
                camera.Rotation.X -= Mouse.Y - oldMouseY;
            }


            Model self = actors[0];
            bool  moving = false, turning = false;

            if (Keyboard[Key.Up])
            {
                self.SetAnimation("walk");
                self.MoveXZ(-spd);
                moving = true;
                self.Update(time * 5);
            }
            else if (Keyboard[Key.Down])
            {
                self.SetAnimation("walk");
                self.MoveXZ(spd);
                moving = true;
                self.Update(-time * 5);
            }
            if (Keyboard[Key.Left])
            {
                if (moving == false)
                {
                    self.SetAnimation("act1");
                    self.Update(time);
                }
                self.Rotation.Y += spd * 15;
                turning          = true;
            }
            else if (Keyboard[Key.Right])
            {
                if (moving == false)
                {
                    self.SetAnimation("act3");
                    self.Update(time);
                }
                self.Rotation.Y -= spd * 15;
                turning          = true;
            }
            if (moving == false && turning == false) // idle
            {
                self.SetAnimation("act2");
                self.Update(time);
            }


            // tiputaanko
            Vector3 end   = new Vector3(self.Position.X, self.Position.Y - 10, self.Position.Z);
            Model   floor = (Model)scene.Search("floor");

            if (Intersection.CheckIntersection(ref self.Position, ref end, ref floor) == false)
            {
                self.Position.Y--; // kiva tippua
            }

            UpdateParticles(time);
            base.Update(time);
        }