Exemplo n.º 1
0
        public void StartShiftingCursor(ILevelSetCursor cursor, int desired)
        {
            int actual;

            lock (Synch)
            {
                int origQueryPointer = cursor.QueryPointer;
                cursor.QueryPointer = MyMath.Clamp(cursor.QueryPointer + desired, 0, levels.Count - 1);
                actual = cursor.QueryPointer - origQueryPointer;
            }

            cursor.ShiftComplete(desired, actual);
        }
Exemplo n.º 2
0
        private static void UpdateFlyingEffects(Camera camera)
        {
            double currTime = Time.GameTimeTotalSeconds;

            for (int i = 0; i < flyingEffects.Count; ++i)
            {
                ScoreEffect scoreEffect = flyingEffects[i];

                float timeElapsed = (float)(currTime - scoreEffect.spawnTime);
                if (timeElapsed > kFlyingEffectSeconds)
                {
                    flyingEffects.RemoveAt(--i + 1);
                    ReleaseScoreEffect(scoreEffect);
                    continue;
                }

                Score score;
                scores.TryGetValue((int)scoreEffect.color, out score);

                Viewport viewport = BokuGame.bokuGame.GraphicsDevice.Viewport;

                float pct = timeElapsed / kFlyingEffectSeconds;

                // If the thing went to the recycle bin, remove our reference to it.
                if (scoreEffect.thing != null && scoreEffect.thing.CurrentState == GameThing.State.Inactive)
                {
                    scoreEffect.thing = null;
                }

                // If we still have a reference to the thing, update the source position of the flying score's path.
                if (scoreEffect.thing != null)
                {
                    scoreEffect.thingPosition = scoreEffect.thing.Movement.Position;
                }

                Vector3 pt0 = scoreEffect.thingPosition + new Vector3(0, 0, scoreEffect.thingBoundingRadius * 2);

                Vector3 pt1 = new Vector3(
                    (float)viewport.Width * 0.5f,
                    (float)viewport.Height * 0.3f,
                    0.75f);
                pt1 = viewport.Unproject(
                    pt1,
                    camera.ProjectionMatrix,
                    camera.ViewMatrix,
                    Matrix.Identity);

                Vector3 pt2 = new Vector3(
                    (float)viewport.Width * 0.6f,
                    (float)viewport.Height * 0.1f,
                    0.5f);
                pt2 = viewport.Unproject(
                    pt1,
                    camera.ProjectionMatrix,
                    camera.ViewMatrix,
                    Matrix.Identity);

                Vector3 pt3 = new Vector3(
                    (float)viewport.Width * 0.9f,
                    y_margin + ScoreBoardFont().LineSpacing *score.order,
                    0.5f);
                pt3 = viewport.Unproject(
                    pt3,
                    camera.ProjectionMatrix,
                    camera.ViewMatrix,
                    Matrix.Identity);

                scoreEffect.curr = MyMath.CubicBezier(pt0, pt1, pt2, pt3, pct);

                scoreEffect.alpha = MyMath.Clamp((1f - pct) * 5, 0, 1);
            }
        }