コード例 #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            // Rot = 0;// -0.25f * JabMath.PI;// 1.0f * JabMath.PI;// gttf(gameTime);

            /*
             * Vector2 toCamera = (Position - Camera.Get.Position);
             * float dist = toCamera.Length();
             * dist /= 2000.0f;
             * if (dist > 1.0f || !Camera.Get.IsVisible(this))
             * {
             *  dist = 1.0f;
             * }
             * dist = 1.0f - dist;*/

            float closestChicken = float.MaxValue;

            for (int i = 0; i < world.Actors.Count; i++)
            {
                if (world.Actors[i].UserData is Chicken)
                {
                    if ((Position - world.Actors[i].Position).Length() < closestChicken && world.Actors[i].LinearVelocity.Length() > 5.0f)
                    {
                        closestChicken = (Position - world.Actors[i].Position).Length();
                    }
                }
            }
            if (closestChicken < 500 && closestChicken > 0)
            {
                FanSound.Volume = (500 - closestChicken) / 500.0f;
            }
            else
            {
                FanSound.Volume = 0.0f;
            }

            placeholder.Position = Position;
            placeholder.Rot      = Rot;

            box.Rot = placeholder.Rot;
            Vector2 airDir = new Vector2(JabMath.Sin(Rot), JabMath.Cos(Rot));

            box.Position = (placeholder.Position + airDir * box.Height / 2.0f) - (100 * airDir);
            for (int i = 0; i < world.Actors.Count; i++)
            {
            }
        }