Beispiel #1
0
        public static List <GameTrigger> ConvertTriggers(List <LineTrigger> triggers, Track track)
        {
            List <GameTrigger> gametriggers = new List <GameTrigger>();
            const int          minute       = 40 * 60;
            int         lasthit             = 0;
            var         rider         = track.GetStart();
            var         hittest       = new HitTestManager();
            int         i             = 1;
            int         hitframe      = -1;
            LineTrigger activetrigger = null;
            float       zoom          = track.StartZoom;
            GameTrigger newtrigger    = null;

            do
            {
                var collisions = new LinkedList <int>();
                rider = rider.Simulate(
                    track.Grid,
                    track.Bones,
                    collisions);
                hittest.AddFrame(collisions);
                LineTrigger hittrigger = null;
                foreach (var lineid in collisions)
                {
                    foreach (var trigger in triggers)
                    {
                        if (trigger.LineID == lineid)
                        {
                            hittrigger = trigger;
                        }
                    }
                }
                if (hittrigger != null &&
                    hittrigger != activetrigger)
                {
                    if (activetrigger != null)
                    {
                        newtrigger.ZoomTarget = zoom;
                        newtrigger.End        = i;
                        gametriggers.Add(newtrigger);
                    }
                    hitframe      = i;
                    activetrigger = hittrigger;
                    newtrigger    = new GameTrigger()
                    {
                        TriggerType = TriggerType.Zoom, Start = i
                    };
                }
                if (activetrigger != null)
                {
                    var delta = i - hitframe;
                    if (!activetrigger.Activate(delta, ref zoom))
                    {
                        newtrigger.ZoomTarget = zoom;
                        newtrigger.End        = i;
                        gametriggers.Add(newtrigger);
                        activetrigger = null;
                    }
                }
                if (hittest.HasUniqueCollisions(i))
                {
                    lasthit = i;
                }
                i++;
            }while (i - lasthit < (minute * 2)); // be REALLY sure, 2 minutes.
            return(gametriggers);
        }
Beispiel #2
0
 public bool IsFrameUniqueCollision(int frame)
 {
     GetFrame(frame);
     return(_hittest.HasUniqueCollisions(frame));
 }