Example #1
0
    //spawn (ghost?) boxes to all lanes
    void spawn(int colorFromLane = -1)
    {//spawns 'ghost' boxes on all lanes to signify a beat (used for pattern creation)
        for (int lane = 0; lane < lanesEnd.Length; lane++)
        {
            Transform destTransform = lanesEnd[lane].transform;

            GameObject beatbox = null;
            if (colorFromLane < 0)
            {
                beatbox = AssetManager.instance.getGhostBeatbox();
            }
            else
            {
                beatbox = AssetManager.instance.getBeatbox(colorFromLane);
            }

            //HISTORIC_TODO bug in resize causing tiny scales on reused pool boxes -- that was due to the trails messing up the bounds
            Utils.resizeToMatch(beatbox, destTransform.gameObject);

            if (beatbox.transform.localScale.x < 0.05)
            {
                Debug.Log("Unexpected shrinking boxes!!!!");
                Debug.Log(beatbox.transform.localScale + " " + beatbox.transform.name + " " + destTransform.gameObject.transform.localScale);
            }
            //beatbox.transform.localScale *= 0.5f;
            beatbox.transform.position = lanesStart[lane].transform.position;

            BeatBox boxScript = beatbox.GetComponent <BeatBox>();
            //boxScript.init(laneStart[lane].transform.position, laneEnd[lane].transform.position, speed, timestamp);
            boxScript.init(lanesStart[lane].transform.position, lanesEnd[lane], timeToLaneEnd[lane], -1, false);

            //EventManager.TriggerEvent(EventManager.EVENT_BEAT, new BeatData(lane, -1, bpm));
        }
    }
Example #2
0
    public void beatBoxArrived(BeatBox beatBox)
    {
        beatBoxArrivalTime = currentTime();// Time.time;
        beatBoxArrival     = beatBox;

        trailArrivalTime = beatBox.getTrailTime();

        checkingTrail = false;

        if (Settings.instance.difficultyTouchToHit)
        {
            if (isAlreadyInside)
            {
                beatBoxArrival.hit(1);

                beatBoxArrival = null;//TODO currently not checking trail in touchToHit mode
                //if (trailArrivalTime <= 0)//no trail, we can discard the box
                //    beatBoxArrival = null;
                //else
                //    checkingTrail = true;
                startParticles();
            }
            else
            {
                beatBoxArrival.miss();
                beatBoxArrival     = null;
                beatBoxArrivalTime = -10;
            }
        }
    }
Example #3
0
        public void TestPropertyAssignments()
        {
            BeatBox bb = new BeatBox();

            bb.Height = 1;
            Assert.IsTrue(bb.Height == 1);

            bb.Width = 2;
            Assert.IsTrue(bb.Width == 2);

            bb.Left = 3;
            Assert.IsTrue(bb.Left == 3);

            bb.Top = 5;
            Assert.IsTrue(bb.Top == 5);

            bb.GutterWidth = 6;
            Assert.IsTrue(bb.GutterWidth == 6);

            bb.IsActive = true;
            Assert.IsTrue(bb.IsActive);
            bb.IsActive = false;
            Assert.IsFalse(bb.IsActive);

            bb.ActiveColor = Color.FromName("Green");
            Assert.IsTrue(bb.ActiveColor == Color.FromName("Green"));
            bb.ActiveColor = Color.FromName("Red");
            Assert.IsTrue(bb.ActiveColor == Color.FromName("Red"));

            bb.InactiveColor = Color.FromName("Yellow");
            Assert.IsTrue(bb.InactiveColor == Color.FromName("Yellow"));
            bb.InactiveColor = Color.FromName("Purple");
            Assert.IsTrue(bb.InactiveColor == Color.FromName("Purple"));
        }
Example #4
0
    BeatBox spawn(int lane, Vector3 futureFinalDest, int direction = -1)
    {
        //Debug.Log("Spawning with futureLaneDest " + futureFinalDest);
        BeatBox box = spawn(lane, false, false, direction);

        box.setFutureLanePosition(futureFinalDest);
        return(box);
    }
    static void Main(string[] args)
    {
        TimeSpan duration          = new TimeSpan(0, 5, 0); // run for 5 minutes total
        TimeSpan beatInterval      = new TimeSpan(0, 0, 1); // regular beats every 1 second
        uint     minRandomInterval = 5;                     // minimum random interval is 5ms
        uint     maxRandomInterval = 30;                    // maximum random interval is 30ms

        using (BeatBox beatBox = new BeatBox(duration, beatInterval, minRandomInterval, maxRandomInterval))
        {
            beatBox.TickEvent += TickHandler;
            EventWaitHandle completionHandle = beatBox.Start();
            completionHandle.WaitOne();
        }
        return;
    }
Example #6
0
    BeatBox spawn(int lane, bool ghostBox = false, bool reverseDirection = false, int direction = -1)
    {//spawns beatbox in right lane with right color
        bool doGhostMiss = !ghostBox && !reverseDirection;

        Transform destTransform = lanesEnd[lane].transform;
        //Debug.Log("Instancing beat at lane " + lane + " timestamp " + arrivalTimestamp + " T2E" + timeToLaneEnd[lane]);

        GameObject beatbox = null;

        if (ghostBox)
        {
            beatbox = AssetManager.instance.getGhostBeatbox();
        }
        else
        {
            beatbox = AssetManager.instance.getBeatbox(lane);
        }

        //ODO bug in resize causing tiny scales on reused pool boxes -- that was due to the trails messing up the bounds. still some Unexpected shrinking boxes traces
        Utils.resizeToMatch(beatbox, destTransform.gameObject);

        if (beatbox.transform.localScale.x < 0.05)
        {
            Debug.Log("Unexpected shrinking boxes!!!!");
            Debug.Log(beatbox.transform.localScale + " " + beatbox.transform.name + " " + destTransform.gameObject.transform.localScale);
        }
        //beatbox.transform.localScale *= 0.5f;
        beatbox.transform.position = lanesStart[lane].transform.position;

        BeatBox boxScript = beatbox.GetComponent <BeatBox>();

        //boxScript.init(laneStart[lane].transform.position, laneEnd[lane].transform.position, speed, timestamp);

        if (Settings.instance.difficultyDirectional)
        {
            boxScript.init(lanesStart[lane].transform.position, lanesEnd[lane], timeToLaneEnd[lane], direction, doGhostMiss, reverseDirection);
        }
        else
        {
            boxScript.init(lanesStart[lane].transform.position, lanesEnd[lane], timeToLaneEnd[lane], -1, doGhostMiss, reverseDirection);
        }

        //EventManager.TriggerEvent(EventManager.EVENT_BEAT, new BeatData(lane, -1, bpm));
        return(boxScript);
    }
Example #7
0
 public void reset()
 {
     registeredBeat       = new RegisteredBeat(0, SongRow.BoxType.NONE);
     checkingTrail        = false;
     beatBoxArrival       = null;
     lastLaneHit          = -10;//init with value higher than maxTimeDelta
     beatBoxArrivalTime   = -10;
     trailArrivalTime     = -10;
     handTransform        = null;
     spawningBlock        = null;
     prevPosition         = transform.position;
     beatPlayMode         = BeatPlayMode.TRIGGER_IMMEDIATE;
     audioLoopOffsetTotal = 0;
     //addedBeatDuration = 0;
     //beatCyclesWhileInside = 0;
     //tmpBeatCyclesWhileInside = 0;
     wasAudioTriggered = false;
 }
Example #8
0
    void laneTriggerUp()
    {
        if (checkingTrail)
        {
            //Debug.Log("Trigger exit, missed trail, remaining trailArrivalTime " + trailArrivalTime + " " + beatBoxArrival.getTrailTime());
            beatBoxArrival.trailMiss();
            beatBoxArrival = null;
        }
        float time = currentTime() - seekOffset();

        checkingTrail = false;
        if (beatPlayMode != BeatPlayMode.LOOP_TO_AUDIO && beatPlayMode != BeatPlayMode.LOOP_TO_BEAT)
        {
            mat.SetColor("_BaseColor", AssetManager.instance.getHitBoxColor(false));
        }
        else
        {
            mat.SetColor("_BaseColor", AssetManager.instance.getHitBoxLoopColor());
        }

        if (registeredBeat.type == SongRow.BoxType.HOLD)
        {
            registeredBeat.clear();
        }
        //TODO maybe_hold should be deprecated, alway use action to enable hold, regular, directional, ...
        if (registeredBeat.type == SongRow.BoxType.MAYBE_HOLD)
        {
            if (time - registeredBeat.timestamp > 0.5f)
            {
                registeredBeat.type = SongRow.BoxType.HOLD;
            }
            else
            {
                registeredBeat.type = SongRow.BoxType.REGULAR;
            }
        }



        isAlreadyInside = false;
    }
Example #9
0
    void Update()
    {
        float audioTime = mediaSource.getTime();// -playStartOffset;//TODO necessary to add playStartOffset? let's go with no, but it does affect the boxes that were spawned before clip start, so should add the offset once available, to existing boxes

        //Debug.Log("... " + frameSeekOffset + " " + seekOffset + " " + state);
        if (state != State.MODELLING)
        {
            //we check user lane pos drag in all states, for different use cases (eg. while idle just switch custom layouts, for recording save the new pos, etc.)
            bool lanePosChanged = false;
            //Vector3[] changedLanes = new Vector3[lanesEnd.Length];
            for (int lane = 0; lane < lanesEnd.Length; lane++)
            {
                HitChecker.RegisteredMove move = lanesEnd[lane].getRegisteredMove();
                if (move != null)
                {
                    lanePosChanged = true;
                    if (playMode == Settings.PlayMode.RECORD_PATTERN)
                    {
                        lanePosChanges.Add(new SongRow(getLanesPosition(), audioTime));
                        //Debug.Log("Recorded lane pos change at " + audioTime);
                    }
                    //changedLanes[lane] = move.position;
                }
                //else//non changing lanes we set to current position (this is saved as custom positions in UIManager)
                //    changedLanes[lane] = lanesEnd[lane].transform.position;
            }
            if (lanePosChanged && (state != State.PLAYING && state != State.SEEK_TO_PLAY))   //only broadcast lane change in idle states, this changes the ui and settings, no need to do while playing/recording
            {
                EventManager.TriggerEvent(EventManager.EVENT_USER_LANE_LAYOUT_CHANGE, null); //new LayoutParam(changedLanes));
            }
        }

        if (state != State.SEEK_TO_PLAY && state != State.PLAYING)
        {
            return;
        }


        if (state == State.SEEK_TO_PLAY) //spawn the beats that have timestamp shorter than timeToLaneEnd
        {
            if (recordingStartFlag && playMode == Settings.PlayMode.RECORD_PATTERN)
            {//spawn colored boxes when the song begins (well, seekOffset time before it begins)
                spawn(-1);
                recordingStartFlag = false;

                //TODO setting this initial position messes up the resulting pattern lanes pos?!?!

                //Vector3[] lanePos = Settings.instance.getLayout();//we also save current layout as starting one for the pattern
                lanePosChanges.Add(new SongRow(getLanesPosition(), 0));
            }
            frameSeekOffset += Time.deltaTime;
            //Debug.Log("... " + frameSeekOffset + " " + seekOffset);
            if (seekOffset <= frameSeekOffset)
            {
                Debug.Log("TimeToEnd offset is complete, starting clip. Offset " + seekOffset + " " + playMode);
                mediaSource.setVolume(0.9f);
                mediaSource.play();
                //state = State.READY_TO_PLAY;
                state = State.PLAYING;
                //TODO to keep things simple, make sure all lanes in a layout always have same distance
                frameSeekOffset = seekOffset;// timeToLaneEnd[0];//this works, as long as all lanes have same distance
            }
        }
        if (state == State.PLAYING)
        {
            if (!mediaSource.isPlaying())
            {
                Debug.Log("Song end, stopping");
                EventManager.TriggerEvent(EventManager.EVENT_END_OF_SONG, null);
                stop();
                return;
            }
            //if (audioSource.time == 0)
            //    elapsedPlayTime += Time.deltaTime;
        }


        if (playMode == Settings.PlayMode.RECORD_PATTERN)
        {
            //TODO spawn line instead of ghostboxes

            /*
             * int index = getNextRowIndex(SongRow.Type.BEAT, audioTime + frameSeekOffset, beatRowIndex);
             * while (index >= 0)
             * {
             *  //Debug.Log("BEAT at " + songRows[SongRow.Type.BEAT][index].timestamp + " " + time + " clip time " + audioSource.time);
             *  spawn(songRows[SongRow.Type.BEAT][index].timestamp);
             *  beatRowIndex = index + 1;
             *  index = getNextRowIndex(SongRow.Type.BEAT, audioTime + frameSeekOffset, beatRowIndex);
             *
             * }
             * */

            //lane pos change caused by switch button
            //TODO let's deactivate this, it's enough with drag?
            if (InputUtils.isCustomLayoutSwitchDown())
            {
                //Settings.instance.setCustomLayouts(!Settings.instance.isCustomLayouts());//already done in uimanager.update()
                //setLanesPosition(lanePos);//UIManager already takes care of position changes, just need to save the new pos for the recording
                Vector3[] lanePos = Settings.instance.getLayout();
                lanePosChanges.Add(new SongRow(lanePos, audioTime));
            }

            int activeLaneChanges = 0;

            //take hitcheckers registered beats and save/spawn
            float laneBoxAverageTime = 0;
            for (int lane = 0; lane < lanesEnd.Length; lane++)
            {
                HitChecker.RegisteredBeat beat = lanesEnd[lane].getRegisteredBeat();

                if (beat != null && beat.type != SongRow.BoxType.NONE)// && (prevRegisteredBeats[lane] == null || prevRegisteredBeats[lane].type == SongRow.BoxType.NONE))// || beat.timestamp > prevRegisteredBeats[lane].timestamp + Settings.instance.minTimeBetweenRegisteredBeats))//avoid duplicates
                {
                    //if (prevRegisteredBeats[lane] != null)
                    //    Debug.Log(beat.timestamp + " " + prevRegisteredBeats[lane].timestamp + " " + prevRegisteredBeats[lane].type);
                    //if (prevRegisteredBeats[lane].type != SongRow.BoxType.NONE && beat.timestamp < prevRegisteredBeats[lane].timestamp + Settings.instance.minTimeBetweenRegisteredBeats)
                    if (beat.timestamp < prevRegisteredBeats[lane].timestamp + Settings.instance.minTimeBetweenRegisteredBeats)
                    {
                        Debug.Log("Ignoring box!!!");
                        continue;
                    }

                    laneBoxAverageTime                 += beat.timestamp;
                    prevRegisteredBeats[lane].type      = beat.type;
                    prevRegisteredBeats[lane].timestamp = beat.timestamp;
                    activeLaneChanges++;

                    int direction = SongRow.getDirection(beat.type);

                    if (direction >= 0)
                    {
                        spawn(lane, false, true, direction);
                    }
                    else
                    {
                        switch (beat.type)
                        {
                        case SongRow.BoxType.REGULAR:
                            spawn(lane, false, true);
                            break;

                        case SongRow.BoxType.HOLD:
                            //TODO keep holds array to extend trail
                            //use lastHoldBox[lane]?
                            BeatBox holdBeatBox = spawn(lane, false, true);//TODO spawn recording trails and stuff (currently just ghostbox + regular box)
                            holdBeatBox.holdTrail(1.5f, Color.grey);
                            break;
                        }
                    }
                }
                else
                {
                    prevRegisteredBeats[lane].type = SongRow.BoxType.NONE;
                    //prevRegisteredBeats[lane].timestamp = beat.timestamp;
                }
            }
            if (activeLaneChanges > 0)
            {
                //if (laneBoxAverageTime == 0)
                //    Debug.Log("0 TIMESTAMP!!!!!!!!");
                if (laneBoxAverageTime != 0)//ignore timestamp zeros, those are from... release? TODO, wtf?
                {
                    processedRecordedBeats.Add(new SongRow(laneBoxAverageTime / activeLaneChanges, prevRegisteredBeats));
                }
            }
        }

        lanePosChangeProgressTime += Time.deltaTime;
        if (mediaSource.isPlaying() && playMode == Settings.PlayMode.PLAY && mediaSource.getTime() <= 0)
        {
            playStartOffset += Time.deltaTime;
            Debug.Log("not playing yet?!?!?!?!?!?!?!?!? " + playStartOffset);
        }
        else
        if (playMode == Settings.PlayMode.PLAY || playMode == Settings.PlayMode.TEST_PATTERN_PLAY)
        {
            //adjust lane position smoothly
            if (lanePosChangeProgressTime <= totalDuration)
            {
                setLanesPosition(currentLaneDestination, lanePosChangeProgressTime / totalDuration);
            }

            //check updated lane pos to set smooth change
            int index = getNextRowIndex(SongRow.Type.LANE_POS, audioTime, lanPosRowIndex);
            if (index >= 0)
            {
                if (songData.rows[SongRow.Type.LANE_POS].Count > index + 1)
                {
                    totalDuration = songData.rows[SongRow.Type.LANE_POS][index + 1].timestamp - songData.rows[SongRow.Type.LANE_POS][index].timestamp;
                    //Debug.Log("Total duration " + totalDuration);
                    lanePosChangeProgressTime = 0;
                    currentLaneDestination    = songData.rows[SongRow.Type.LANE_POS][index].lanePositions;
                }
                else
                {
                    setLanesPosition(songData.rows[SongRow.Type.LANE_POS][index].lanePositions, totalDuration);
                }

                lanPosRowIndex = index + 1;
            }

            //beat BPM change checks. using just for event notification to animators
            //TODO songRow types for animations (new segment?)...
            index = getNextRowIndex(SongRow.Type.BPM, audioTime + frameSeekOffset, bpmRowIndex);
            if (index >= 0)
            {
                float bpm = songData.rows[SongRow.Type.BPM][index].bpm;
                //calculateTimeToLaneEnd(Math.Max(bpm, 120));//doing this messes up the pattern (fast beats overtaking slow ones)
                EventManager.TriggerEvent(EventManager.EVENT_BPM_CHANGE, new BeatData(-1, -1, bpm));
                bpmRowIndex = index + 1;
            }

            //beat with chroma check
            int   activatedLaneCount  = 0;
            float searchAheadBeatTime = (audioTime + frameSeekOffset);

            index = getNextRowIndex(SongRow.Type.BOX, searchAheadBeatTime, boxRowIndex);
            if (index >= 0)
            {
                //EventManager.TriggerEvent(EventManager.EVENT_BEAT, new BeatData(-1, -1, bpm));

                SongRow songRow = songData.rows[SongRow.Type.BOX][index];
                boxRowIndex = index + 1;
                //int[] activeLanes = songRow.activeLanes;
                for (int lane = 0; lane < timeToLaneEnd.Length; lane++)
                {
                    if (songRow.activeLanes[lane] > 0)
                    {
                        //finds out if the lane will be at a different location when beat arrives, which should be songRow.timestamp + timeToLaneEnd
                        //TODO review the timing for this
                        //look at where the lane end might be at the time the box arrives (now + timeToLaneEnd)
                        int validFutureLanePosIndex = -1;
                        //int futureLanePosIndex = getNextRowIndex(SongRow.Type.LANE_POS, time - seekOffset + timeToLaneEnd[lane], lanPosRowIndex);
                        int futureLanePosIndex = getNextRowIndex(SongRow.Type.LANE_POS, songRow.timestamp, lanPosRowIndex);
                        while (futureLanePosIndex >= 0)
                        {
                            validFutureLanePosIndex = futureLanePosIndex;
                            //futureLanePosIndex = getNextRowIndex(SongRow.Type.LANE_POS, time - seekOffset + timeToLaneEnd[lane], futureLanePosIndex + 1);
                            futureLanePosIndex = getNextRowIndex(SongRow.Type.LANE_POS, songRow.timestamp, futureLanePosIndex + 1);
                        }

                        if (validFutureLanePosIndex >= 0)
                        {
                            Debug.Log("Beat should arrive at " + (songRow.timestamp + timeToLaneEnd[lane]));
                            Debug.Log("Closest position update  " + songData.rows[SongRow.Type.LANE_POS][validFutureLanePosIndex] + " index " + validFutureLanePosIndex + " at " + songData.rows[SongRow.Type.LANE_POS][validFutureLanePosIndex].timestamp);
                        }
                        Vector3 futureLanePos = Vector3.zero;
                        if (validFutureLanePosIndex >= 0)
                        {
                            futureLanePos = songData.rows[SongRow.Type.LANE_POS][validFutureLanePosIndex].lanePositions[lane];
                        }

                        //validFutureLanePosIndex = -1;
                        //validFutureLanePosIndex = -1;
                        //spawning a hold or regular note, with lane position at time of arrival (if it changes)
                        //notTODO it's not a bug, it's a feature: hold lanes get restarted at init of other lane changes. fixed (it was a timestamping, index fetching, nut sucking problem)
                        bool isHold = Settings.instance.difficultyTrailBoxes && songRow.activeLanes[lane] == 2;
                        if (isHold)
                        {
                            //we create new hold
                            if (lastHoldBox[lane] == null || !lastHoldBox[lane].isTrailActive())
                            {    //don't feed trails to boxes that are already done!
                                if (validFutureLanePosIndex >= 0)
                                {
                                    lastHoldBox[lane] = spawn(lane, futureLanePos);
                                }
                                else
                                {
                                    lastHoldBox[lane] = spawn(lane, false, false);
                                }
                                activatedLaneIndex += 2;

                                Color laneColor = AssetManager.instance.getLaneColor(lane);
                                laneColor.a = 0.2f;
                                //we add the initial trail to the box
                                if (songData.rows[SongRow.Type.BOX].Count > index + 1 && songData.rows[SongRow.Type.BOX][index + 1].activeLanes[lane] == (int)SongRow.BoxType.HOLD)
                                {
                                    lastHoldBox[lane].holdTrail(songData.rows[SongRow.Type.BOX][index + 1].timestamp - songRow.timestamp, laneColor);
                                }
                                //else
                                //    lastHoldBox[lane].holdTrail(audioSource.clip.length - songRow.timestamp, laneColor);//last hold with no other box to set finish time
                            }
                            else //we add trail to existing hold
                            {    //index-1 should always be inside bounds, since it is a trail for previous row
                                //if (songRow.timestamp - songRows[SongRow.Type.BOX][index - 1].timestamp > 0)//hmm...
                                //{
                                //lastHoldBox[lane].holdTrail(songRow.timestamp - songRows[SongRow.Type.BOX][index - 1].timestamp, AssetManager.instance.getLaneColor(lane));
                                if (songData.rows[SongRow.Type.BOX].Count > index + 1 && songData.rows[SongRow.Type.BOX][index + 1].activeLanes[lane] == (int)SongRow.BoxType.HOLD)
                                {
                                    //problem here is that last segment of trail addition addst time after trail should have endend
                                    lastHoldBox[lane].holdTrail(songData.rows[SongRow.Type.BOX][index + 1].timestamp - songRow.timestamp, Color.white);        //AssetManager.instance.getLaneColor(lane) - new Color(0,0,0,0.6f));
                                    //lastHoldBox[lane].holdTrail(songRow.timestamp + songRows[SongRow.Type.BOX][index - 1].timestamp, Color.white);//AssetManager.instance.getLaneColor(lane) - new Color(0,0,0,0.6f));
                                    activatedLaneIndex += 3;
                                }
                                //else
                                //    lastHoldBox[lane] = null;//we can finish the trail here?
                                //}
                            }
                            //TODO current//problem is that trail finishes at the right time, but beatbox still stays in place... should disable trail
                        }
                        else
                        {    //non hold box
                            if (lastHoldBox[lane] != null)
                            {
                                activatedLaneIndex += 4;
                            }
                            lastHoldBox[lane] = null;

                            int direction = SongRow.getDirection(songRow.activeLanes[lane]);

                            if (validFutureLanePosIndex >= 0)
                            {
                                lastRegularBox[lane] = spawn(lane, futureLanePos, direction);
                            }
                            else
                            {
                                lastRegularBox[lane] = spawn(lane, false, false, direction);
                            }

                            //Debug.Log("Spawning note (test note at 3.5s) note.ts" + songRow.timestamp + " audiotime+offset" + time + " audiotime" + audioSource.time + " audiotime+offset+seekoffset " + (time + seekOffset) + "  with playOffset " + (audioSource.time + frameSeekOffset + playStartOffset));
                            //Debug.Log("Spawning note frameOffset " + frameSeekOffset + " seekOffset" + seekOffset);// + " audiotime" + audioSource.time + " audiotime+offset+seekoffset " + (time + seekOffset) + " -playOffset " + (audioSource.time - seekOffset + playStartOffset));

                            EventManager.TriggerEvent(EventManager.EVENT_BEAT_NOTE, new BeatData(lane, -1, bpm));

                            activatedLaneIndex += lane;
                            activatedLaneCount++;
                            //activatedTimestamp = songRow.timestamp;
                        }
                    }
                    else
                    {
                        if (lastHoldBox[lane] != null)
                        {    //this lane is currently inactive, so no more trail to add to current trail box, next trail will be added to new box
                            lastHoldBox[lane]   = null;
                            activatedLaneIndex += 5;
                        }
                        else
                        {
                            activatedLaneIndex += 6;
                        }
                    }
                }

                //index = getNextRowIndex(SongRow.Type.BOX, searchAheadBeatTime, boxRowIndex);
            }

            index = getNextRowIndex(SongRow.Type.BEAT, searchAheadBeatTime, beatRowIndex);
            if (index >= 0)
            {
                EventManager.TriggerEvent(EventManager.EVENT_BEAT, new BeatData(-1, -1, bpm));
                //difficulty +1 code
                if (playMode == Settings.PlayMode.PLAY && Settings.instance.difficultyPlusOneBox)    //ignore the option +1 when testing
                {
                    //if (activatedLaneCount < Settings.instance.patternMaxActiveLanesAtOnce)
                    //if (activatedLaneCount == 0)
                    //{
                    int plusOneLane = (activatedLaneIndex + activatedLaneCount) % lanesEnd.Length;
                    //while (lastHoldBox[plusOneLane] != null)
                    //    plusOneLane = (++activatedLaneIndex + activatedLaneCount) % lanesEnd.Length;

                    if (lastRegularBox[plusOneLane] != null && searchAheadBeatTime - lastRegularBox[plusOneLane].timeToLaneEnd > 0.5f)
                    {
                        plusOneLane++;
                    }

                    if (plusOneLane < lanesEnd.Length)
                    {
                        spawn(plusOneLane, !Settings.instance.ghostBoxWithLaneColor);
                    }
                    //}
                }
                //EventManager.TriggerEvent(EventManager.EVENT_BEAT, new BeatData(-1, -1, bpm));
                beatRowIndex = index + 1;
                //index = getNextRowIndex(SongRow.Type.BEAT, audioTime, beatRowIndex);
            }
        }
    }
Example #10
0
    void playBeatBox(float clipTime)
    {
        if (beatBoxArrival != null)
        {
            if (lastLaneHit > 0)//if there was a hit triggered in the lane (by key or beater)
            {
                float timeDelta = Mathf.Abs(lastLaneHit - beatBoxArrivalTime);
                //Debug.Log("Checking hit beatboxarrivaltime " + beatBoxArrivalTime + " vs lastLaneHit " + lastLaneHit + " delta " + timeDelta);
                if (timeDelta <= maxTimeDelta)
                {
                    if (beatBoxArrival.direction >= 0)
                    {
                        //Debug.Log(":::::::::lastLaneDirection " + lastLaneDirection + " beatBoxArrival.direction " + beatBoxArrival.direction);
                        if (lastLaneDirection != beatBoxArrival.direction)
                        {
                            beatBoxArrival.miss();
                            beatBoxArrival     = null;
                            beatBoxArrivalTime = -10;
                        }
                        else
                        {
                            beatBoxArrival.hit(timeDelta / maxTimeDelta);

                            startParticles();
                        }
                    }
                    else
                    {
                        beatBoxArrival.hit(timeDelta / maxTimeDelta);
                        startParticles();
                    }

                    if (trailArrivalTime <= 0)//no trail, we can discard the box
                    {
                        beatBoxArrival = null;
                    }
                    else
                    {
                        checkingTrail = true;
                    }
                }
                lastLaneHit = -10;
            }

            if (!checkingTrail && beatBoxArrival != null && beatBoxArrivalTime < clipTime - maxTimeDelta) //past due time and has no trail, it's a miss
            {
                //Debug.Log("MISS! " + beatBoxArrivalTime + " " + (clipTime - maxTimeDelta));
                beatBoxArrival.miss();
                beatBoxArrival     = null;
                beatBoxArrivalTime = -10;
            }
        }
        if (lastLaneHit > 0 && lastLaneHit < clipTime - maxTimeDelta)
        {
            lastLaneHit = -10;
        }


        if (checkingTrail)//this needs to be checked after main checks above
        {
            //at this point, controller should stay inside checker, otherwise ontriggerexit would cause a miss()
            trailArrivalTime -= Time.deltaTime;
            if (trailArrivalTime <= 0)
            {
                beatBoxArrival.trailHit();
                beatBoxArrival = null;
                checkingTrail  = false;
            }
        }
    }
Example #11
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnTestWaveStream = new System.Windows.Forms.Button();
            this.btnPlay = new System.Windows.Forms.Button();
            this.btnStop = new System.Windows.Forms.Button();
            this.btnCapTest = new System.Windows.Forms.Button();
            this.btnTestSynthesis = new System.Windows.Forms.Button();
            this.btnShowWaveForm = new System.Windows.Forms.Button();
            this.track1 = new ErnstTech.SynthesizerControls.Track();
            this.beatBox1 = new ErnstTech.SynthesizerControls.BeatBox();
            this.btnViewWaveForm = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.txtExpression = new System.Windows.Forms.TextBox();
            this.btnParse = new System.Windows.Forms.Button();
            this.txtDuration = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.btnExprShow = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // btnTestWaveStream
            // 
            this.btnTestWaveStream.Location = new System.Drawing.Point(112, 64);
            this.btnTestWaveStream.Margin = new System.Windows.Forms.Padding(2, 3, 3, 3);
            this.btnTestWaveStream.Name = "btnTestWaveStream";
            this.btnTestWaveStream.Size = new System.Drawing.Size(112, 23);
            this.btnTestWaveStream.TabIndex = 1;
            this.btnTestWaveStream.Text = "Test Wave Stream";
            this.btnTestWaveStream.Click += new System.EventHandler(this.btnTestWaveStream_Click);
            // 
            // btnPlay
            // 
            this.btnPlay.Location = new System.Drawing.Point(232, 64);
            this.btnPlay.Name = "btnPlay";
            this.btnPlay.Size = new System.Drawing.Size(75, 23);
            this.btnPlay.TabIndex = 2;
            this.btnPlay.Text = "Play";
            this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click);
            // 
            // btnStop
            // 
            this.btnStop.Location = new System.Drawing.Point(320, 64);
            this.btnStop.Name = "btnStop";
            this.btnStop.Size = new System.Drawing.Size(75, 23);
            this.btnStop.TabIndex = 2;
            this.btnStop.Text = "Stop";
            this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
            // 
            // btnCapTest
            // 
            this.btnCapTest.Location = new System.Drawing.Point(402, 64);
            this.btnCapTest.Name = "btnCapTest";
            this.btnCapTest.Size = new System.Drawing.Size(112, 23);
            this.btnCapTest.TabIndex = 3;
            this.btnCapTest.Text = "Capabilities Test";
            this.btnCapTest.Click += new System.EventHandler(this.btnCapTest_Click);
            // 
            // btnTestSynthesis
            // 
            this.btnTestSynthesis.Location = new System.Drawing.Point(13, 64);
            this.btnTestSynthesis.Margin = new System.Windows.Forms.Padding(3, 3, 1, 3);
            this.btnTestSynthesis.Name = "btnTestSynthesis";
            this.btnTestSynthesis.Size = new System.Drawing.Size(96, 23);
            this.btnTestSynthesis.TabIndex = 4;
            this.btnTestSynthesis.Text = "Test Synthesizer";
            this.btnTestSynthesis.Click += new System.EventHandler(this.button1_Click);
            // 
            // btnShowWaveForm
            // 
            this.btnShowWaveForm.Location = new System.Drawing.Point(13, 93);
            this.btnShowWaveForm.Name = "btnShowWaveForm";
            this.btnShowWaveForm.Size = new System.Drawing.Size(96, 23);
            this.btnShowWaveForm.TabIndex = 7;
            this.btnShowWaveForm.Text = "Show Waveform";
            this.btnShowWaveForm.Click += new System.EventHandler(this.btnShowWaveForm_Click);
            // 
            // track1
            // 
            this.track1.BeatCount = 16;
            this.track1.Location = new System.Drawing.Point(16, 144);
            this.track1.Name = "track1";
            this.track1.Size = new System.Drawing.Size(176, 144);
            this.track1.TabIndex = 6;
            // 
            // beatBox1
            // 
            this.beatBox1.BaseFrequency = 200F;
            this.beatBox1.Location = new System.Drawing.Point(224, 192);
            this.beatBox1.Name = "beatBox1";
            this.beatBox1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.beatBox1.SampleQuality = ErnstTech.SoundCore.AudioBits.Bits16;
            this.beatBox1.Size = new System.Drawing.Size(480, 296);
            this.beatBox1.TabIndex = 0;
            // 
            // btnViewWaveForm
            // 
            this.btnViewWaveForm.Location = new System.Drawing.Point(112, 93);
            this.btnViewWaveForm.Name = "btnViewWaveForm";
            this.btnViewWaveForm.Size = new System.Drawing.Size(112, 23);
            this.btnViewWaveForm.TabIndex = 8;
            this.btnViewWaveForm.Text = "View Wave Form";
            this.btnViewWaveForm.Click += new System.EventHandler(this.btnViewWaveForm_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(232, 94);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(89, 15);
            this.label1.TabIndex = 9;
            this.label1.Text = "Expression Test:";
            // 
            // txtExpression
            // 
            this.txtExpression.Location = new System.Drawing.Point(232, 113);
            this.txtExpression.Name = "txtExpression";
            this.txtExpression.Size = new System.Drawing.Size(309, 23);
            this.txtExpression.TabIndex = 10;
            this.txtExpression.Text = "cos(2 * PI * (220 + 4 * cos(2 * PI * 10 * t)) * t) * 0.5";
            // 
            // btnParse
            // 
            this.btnParse.Location = new System.Drawing.Point(483, 143);
            this.btnParse.Name = "btnParse";
            this.btnParse.Size = new System.Drawing.Size(75, 23);
            this.btnParse.TabIndex = 11;
            this.btnParse.Text = "Test";
            this.btnParse.UseVisualStyleBackColor = true;
            this.btnParse.Click += new System.EventHandler(this.btnParse_Click);
            // 
            // txtDuration
            // 
            this.txtDuration.Location = new System.Drawing.Point(232, 142);
            this.txtDuration.Name = "txtDuration";
            this.txtDuration.Size = new System.Drawing.Size(51, 23);
            this.txtDuration.TabIndex = 12;
            this.txtDuration.Text = "1.0";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(289, 147);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(109, 15);
            this.label2.TabIndex = 9;
            this.label2.Text = "Test Duration (secs)";
            // 
            // btnExprShow
            // 
            this.btnExprShow.Location = new System.Drawing.Point(402, 142);
            this.btnExprShow.Name = "btnExprShow";
            this.btnExprShow.Size = new System.Drawing.Size(75, 23);
            this.btnExprShow.TabIndex = 13;
            this.btnExprShow.Text = "Show";
            this.btnExprShow.UseVisualStyleBackColor = true;
            this.btnExprShow.Click += new System.EventHandler(this.btnExprShow_Click);
            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(712, 486);
            this.Controls.Add(this.btnExprShow);
            this.Controls.Add(this.txtDuration);
            this.Controls.Add(this.btnParse);
            this.Controls.Add(this.txtExpression);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.btnViewWaveForm);
            this.Controls.Add(this.btnShowWaveForm);
            this.Controls.Add(this.track1);
            this.Controls.Add(this.btnTestSynthesis);
            this.Controls.Add(this.btnCapTest);
            this.Controls.Add(this.btnPlay);
            this.Controls.Add(this.btnTestWaveStream);
            this.Controls.Add(this.beatBox1);
            this.Controls.Add(this.btnStop);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }
Example #12
0
        public void TestCreate()
        {
            BeatBox bb = new BeatBox();

            Assert.Pass();
        }