Пример #1
0
    /// <summary>
    /// load a music node from a www dtx file.
    /// </summary>
    /// <param name="www"></param>
    /// <param name="parentNode"></param>
    /// <returns></returns>
    public MusicNode LoadMusicNode(WWW www, Node parentNode = null)
    {
        if (parentNode == null)
        {
            parentNode = Root;
        }

        try
        {
            if (string.IsNullOrEmpty(www.error))
            {
                using (var stream = new MemoryStream(www.bytes))
                {
                    var music = new MusicNode(www.url, parentNode, stream);
                    parentNode.ChildNodeList.Add(music);
                    return(music);
                }
            }
            else
            {
                Debug.LogError("Fail to load www data: " + www.url + "\nError:" + www.error);
                return(null);
            }
        }
        catch (Exception ex)
        {
            Debug.LogError("Fail to load music file: " + www.url + "\nmessage=" + ex.Message + "\ntrace:\n" + ex.StackTrace);
            return(null);
        }
    }
Пример #2
0
    public void OnPlaceNote()
    {
        //clipValue =

        int noteID = (int)Random.Range(0, (prefabs.Count - 1));

        order++;
        if (order >= prefabs.Count)
        {
            order = 0;
        }
        Debug.Log(noteID);
        GameObject prefabNote = prefabs[noteID];
        GameObject note       = Instantiate(prefabNote, Cursor.transform.position, Cursor.transform.rotation) as GameObject;

        note.transform.parent = sequence.transform;
        MusicNode musicNode = (note.GetComponent <MusicNode>() as MusicNode);

        // musicNode.GetComponent<AudioSource>
        musicNode.SetAnchorID("node" + musicNodes.Count.ToString());
        musicNode.SetAudioClip(audioClips[noteID]);
        musicNodes.Add(note);
        musicNode.SetMasterAudioSync(masterAudio);
        BeatCounter.Instance.observersList.Add(note);
    }
Пример #3
0
    public void Initialization()
    {
        var musicName = "never_look_back";
        var when      = A.Dummy <ICondition>();
        var sut       = new MusicNode(musicName, when);

        sut.MusicName.Should().Be(musicName);
        sut.When.Should().Be(when);
    }
Пример #4
0
    public async Task OnEnterAsyncShouldUpdateState()
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MusicName = "sad_story";

        var sut = new MusicNode("open_sky", null);
        await sut.EnterAsync(context);

        context.State.MusicName.Should().Be("open_sky");
    }
Пример #5
0
    public async Task OnEnterAsyncShouldReturnLastMusicName()
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MusicName = "enigma";

        var sut = new MusicNode("free_mind", null);

        var ret = await sut.EnterAsync(context);

        ret.Should().Be("enigma");
    }
Пример #6
0
    public SetNode(SetDef.Block block, string baseFolder, Node parentNode)
    {
        Title  = block.Title;
        Parent = parentNode;

        for (int i = 0; i < MusicNodes.Length; i++)
        {
            MusicNodes[i] = null;
            if (string.IsNullOrEmpty(block.File[i]))
            {
                continue;
            }

            try
            {
                var fullPath = Path.Combine(baseFolder, block.File[i]);
                if (!File.Exists(fullPath))
                {
                    continue;
                }

                var musicNode = new MusicNode(fullPath, this);
                ChildNodeList.Add(musicNode);

                Difficulty[i].Label = block.Label[i];
                Difficulty[i].Level = (float)musicNode.Score.Difficulty;
                MusicNodes[i]       = musicNode;

                if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(MusicNodes[i].Title))
                {
                    Title = MusicNodes[i].Title;
                }
            }
            catch (System.Exception ex)
            {
                Debug.LogError("fail to load. Exception:" + ex);
            }
        }

        for (var i = 0; i < ThumbnailNames.Length; i++)
        {
            var fullPath = Path.Combine(baseFolder, ThumbnailNames[i]);
            if (File.Exists(fullPath))
            {
                PreviewImagePath = fullPath;
                break;
            }
        }
    }
Пример #7
0
    public async Task OnEnterAsyncShouldNotRaiseEventIfMusicWasNotChanged()
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MusicName = "crime_fighter";

        var invoker = new TestInvoker(context);

        var sut = new MusicNode("crime_fighter", null);
        var ret = await sut.EnterAsync(context);

        ret.Should().Be("crime_fighter");

        invoker.Count.Should().Be(0);
    }
Пример #8
0
    public async Task ShouldRaiseEventWithStateArg(string stateArg)
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MusicName = "theme";

        var invoker = new TestInvoker(context);

        var sut = new MusicNode("goodbye", null);
        await sut.EnterAsync(context, stateArg);

        invoker.ShouldContainSingle <IMusicChangeEvent>(
            i => i.Should().BeEquivalentTo(new { MusicName = stateArg })
            );
    }
Пример #9
0
    public void RemoveNode(object sender, object args)
    {
        MusicNode n = null;

        if (queueForTracks[0].Contains((MusicNode)sender))
        {
            n = queueForTracks[0].Dequeue();
        }

        if (queueForTracks[1].Contains((MusicNode)sender))
        {
            n = queueForTracks[1].Dequeue();
        }
        m_OnInput(n, Rank.MISS);
    }
Пример #10
0
    IEnumerator DestroyRoutine()
    {
        while (queueForTracks[0].Count != 0)
        {
            MusicNode n = queueForTracks[0].Dequeue();
            Destroy(n.gameObject);
            yield return(null);
        }

        while (queueForTracks[1].Count != 0)
        {
            MusicNode n = queueForTracks[1].Dequeue();
            Destroy(n.gameObject);
            yield return(null);
        }
    }
Пример #11
0
    public void AsessInput(int position)
    {
        int currentInput = position == -1 ? 0 : 1;

        if (queueForTracks.Length == 0)
        {
            return;
        }

        if (queueForTracks[currentInput].Count == 0)
        {
            return;
        }

        MusicNode currentNode = queueForTracks[currentInput].Dequeue();

        if (currentNode == null)
        {
            return;
        }

        Rank inputRank;

        if (currentInput == 1)
        {
            RInputAnimator.Scale();
        }
        else
        {
            LInputAnimator.Scale();
        }

        if (Mathf.Abs(songPosition - currentNode.beat) < 1.4f)
        {
            inputRank = Rank.PERFECT;
        }
        else if (Mathf.Abs(songPosition - currentNode.beat) < 2f)
        {
            inputRank = Rank.GOOD;
        }
        else
        {
            inputRank = Rank.MISS;
        }

        m_OnInput.Invoke(currentNode, inputRank);
    }
Пример #12
0
    public MusicNode GetNode(float posX, float startY, float endY, float removeLineY, float posZ, float beat, int times, Color color, int id)
    {
        //check if there is an inactive instance
        foreach (MusicNode node in objList)
        {
            if (!node.gameObject.activeInHierarchy)
            {
                node.Initialize(posX, startY, endY, removeLineY, posZ, beat, times, color, id);
                node.gameObject.SetActive(true);
                return(node);
            }
        }

        //no inactive instances, instantiate a new GetComponent
        MusicNode musicNode = ((GameObject)Instantiate(nodePrefab)).GetComponent <MusicNode>();

        musicNode.Initialize(posX, startY, endY, removeLineY, posZ, beat, times, color, id);
        objList.Add(musicNode);
        return(musicNode);
    }
Пример #13
0
    public void OnUpdate()
    {
        if (paused)
        {
            return;
        }

        songPosition = (float)(AudioSettings.dspTime - dspTimeSong) * m_AudioService.GetAudioSource().pitch;
        float beatToShow = songPosition / crotchet + BeatsShownOnScreen;

        for (int i = 0; i < len; i++)
        {
            int            nextIndex = trackNextIndices[i];
            SongInfo.Track currTrack = tracks[i];

            if (nextIndex < currTrack.Notes.Length && currTrack.Notes[nextIndex].note < beatToShow)
            {
                SongInfo.Note currNote  = currTrack.Notes[nextIndex];
                Vector3       parentPos = i == 0 ? LeftParent.position : RightParent.position;
                MusicNode     musicNode = Instantiate(NodePrefab, new Vector3(parentPos.x, Screen.height + 200, 0), this.transform.rotation, i == 0 ? LeftParent : RightParent);
                musicNode.Initialize(parentPos.x, Screen.height + 200, finishLineY, 0, currNote.note);

                trackNextIndices[i]++;
                queueForTracks[i].Enqueue(musicNode);
            }
        }

        if (songPosition > songLength)
        {
            if (m_OnFinish != null)
            {
                m_OnFinish.Invoke();
                paused = true;

                m_OnFinish = null;
                m_OnInput  = null;
            }
        }
    }
Пример #14
0
    public async Task ParseAsync(XmlReader reader, IParsingContext parsingContext, IParentParsingContext parentParsingContext)
    {
        var myContext = new TextParentParsingContext();
        await elementParser.ParseAsync(reader, parsingContext, myContext, Settings);

        var parsedText = myContext.ParsedText;

        if (parsedText is null)
        {
            return;
        }

        if (parsingContext.SceneContext.HasMusic)
        {
            parsingContext.LogError(reader, "Mais de uma definição de música para a mesma cena.");
            return;
        }
        parsingContext.SceneContext.HasMusic = true;

        var node = new MusicNode(parsedText.Length == 0 ? null : parsedText, myContext.When);

        parentParsingContext.AddNode(node);
        parsingContext.RegisterDismissNode(DismissNode);
    }
Пример #15
0
    private void OnInput(MusicNode node, Conductor.Rank rank)
    {
        if (node == null)
        {
            return;
        }

        switch (rank)
        {
        case Conductor.Rank.PERFECT:
            ScoreController.AddScore(ScoreController.PERFECT_SCORE);
            break;

        case Conductor.Rank.GOOD:
            ScoreController.AddScore(ScoreController.GREAT_SCORE);
            break;

        case Conductor.Rank.MISS:
            ScoreController.AddScore(-25);
            break;
        }

        Destroy(node.gameObject);
    }
Пример #16
0
    public void TouchTrigger()
    {
        //if (selected != null)
        //{
        //    return;
        //}
        //if ((Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began))
        if (Input.GetMouseButtonDown(0))
        {
            //Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
            Ray        raycast = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit raycastHit;
            if (Physics.Raycast(raycast, out raycastHit))
            {
                string targ = null;
                if (raycastHit.collider.transform.parent != null)
                {
                    targ = raycastHit.collider.transform.parent.name;
                }
                if (targ != null)
                {
                    if (targ.Contains("music node"))
                    {
                        MusicNode selected_new = (MusicNode)raycastHit.collider.transform.parent.GetComponent("MusicNode");
                        if (selected != null)
                        {
                            if (selected_new.name != selected.name)
                            {
                                selected.Deselected();
                                selected = selected_new;
                            }
                        }
                        else
                        {
                            selected = selected_new;
                        }
                        selected.Selected();
                        print(targ);
                    }
                }

                if (raycastHit.collider.GetComponent("Recorder") != null)
                {
                    if (selected != null)
                    {
                        recording = true;
                        r.Selected();
                        StartRecording();
                        print("Recording");
                    }
                }
            }
            else
            {
                if (selected != null)
                {
                    selected.Deselected();
                    selected = null;
                }
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (recording == true)
            {
                recording = false;
                r.Deselected();
                StopRecording();
                print("stopped recording");
            }
        }
    }
Пример #17
0
    public void PlayerInputted(int trackNumber)
    {
        //Add Animation to the track

        if (queueForTracks[trackNumber].Count != 0)
        {
            //peek the node in the queue
            MusicNode frontNode = queueForTracks[trackNumber].Peek();

            if (frontNode.times > 0)
            {
                return;                      //multi-times node should be handled in the Update() func
            }
            float offsetY = Mathf.Abs(frontNode.gameObject.transform.position.y - partitionManager.finishLineY);
            //Note porté minimum
            if (offsetY < partitionManager.badOffsetY)
            {
                if (frontNode.isStone)
                {
                    BossManager.Instance.TriggerNextAttackStone();
                    int life = BossManager.Instance.GetStoneLife();
                    if (life > 0)
                    {
                        frontNode.updateSprite(life - 1);
                    }
                }
                if (offsetY < partitionManager.perfectOffsetY) //perfect hit
                {
                    //fait quelque chose sur le gameplay selon la qualité du hit
                    frontNode.PerfectHit();
                    ChargeRole(PartitionManager.Rank.PERFECT);

                    //SendBeatHit to particle
                    if (HarmonieBar.Instance.GetMultiplier() == 2)
                    {
                        tracks[trackNumber].PlayParticle(PartitionManager.Rank.HARMONIE);
                    }
                    else
                    {
                        tracks[trackNumber].PlayParticle(PartitionManager.Rank.PERFECT);
                    }

                    //Harmonie
                    if (PlayerManager.Instance.PlayersByRole(currentRole.RoleState) > 1)
                    {
                        HarmonieBar.Instance.GiveHarmonie(HARMONIEPerfect);
                    }

                    //Remove node
                    queueForTracks[trackNumber].Dequeue();
                }
                else if (offsetY < partitionManager.goodOffsetY) //good hit
                {
                    //fait quelque chose sur le gameplay selon la qualité du hit
                    frontNode.GoodHit();
                    ChargeRole(PartitionManager.Rank.GOOD);

                    //SendBeatHit to particle
                    if (HarmonieBar.Instance.GetMultiplier() == 2)
                    {
                        tracks[trackNumber].PlayParticle(PartitionManager.Rank.HARMONIE);
                    }
                    else
                    {
                        tracks[trackNumber].PlayParticle(PartitionManager.Rank.GOOD);
                    }

                    //Harmonie
                    if (PlayerManager.Instance.PlayersByRole(currentRole.RoleState) > 1)
                    {
                        HarmonieBar.Instance.GiveHarmonie(HARMONIEGood);
                    }

                    //Remove node
                    queueForTracks[trackNumber].Dequeue();
                }
                else if (offsetY < partitionManager.badOffsetY) //bad hit
                {
                    //fait quelque chose sur le gameplay selon la qualité du hit
                    frontNode.BadHit();
                    ChargeRole(PartitionManager.Rank.BAD);

                    //SendBeatHit to particle
                    if (HarmonieBar.Instance.GetMultiplier() == 2)
                    {
                        tracks[trackNumber].PlayParticle(PartitionManager.Rank.HARMONIE);
                    }
                    else
                    {
                        tracks[trackNumber].PlayParticle(PartitionManager.Rank.BAD);
                    }

                    //Harmonie
                    if (PlayerManager.Instance.PlayersByRole(currentRole.RoleState) > 1)
                    {
                        HarmonieBar.Instance.GiveHarmonie(HARMONIEBad);
                    }

                    //Remove node
                    queueForTracks[trackNumber].Dequeue();
                }
            }
            else
            {
                // ---> MISS : trop tot / trop tard
                ShieldBar.Instance.TakeDamage(8);

                player = PlayerManager.Instance.GetPlayer(idplayer);
                // Son en fct du perso
                if (player.Personnage.id == 0)
                {
                    int i = Random.Range(1, 5);
                    switch (i)
                    {
                    case 1:
                        SoundMgr.Instance.PlaySound("FailPiano1");
                        break;

                    case 2:
                        SoundMgr.Instance.PlaySound("FailPiano2");
                        break;

                    case 3:
                        SoundMgr.Instance.PlaySound("FailPiano3");
                        break;

                    case 4:
                        SoundMgr.Instance.PlaySound("FailPiano4");
                        break;
                    }
                }
                else if (player.Personnage.id == 1)
                {
                    int i = Random.Range(1, 5);
                    switch (i)
                    {
                    case 1:
                        SoundMgr.Instance.PlaySound("FailBass1");
                        break;

                    case 2:
                        SoundMgr.Instance.PlaySound("FailBass2");
                        break;

                    case 3:
                        SoundMgr.Instance.PlaySound("FailBass3");
                        break;

                    case 4:
                        SoundMgr.Instance.PlaySound("FailBass4");
                        break;
                    }
                }
                else if (player.Personnage.id == 2)
                {
                    int i = Random.Range(1, 5);
                    switch (i)
                    {
                    case 1:
                        SoundMgr.Instance.PlaySound("FailGuitar1");
                        break;

                    case 2:
                        SoundMgr.Instance.PlaySound("FailGuitar2");
                        break;

                    case 3:
                        SoundMgr.Instance.PlaySound("FailGuitar3");
                        break;

                    case 4:
                        SoundMgr.Instance.PlaySound("FailGuitar4");
                        break;
                    }
                }
                else if (player.Personnage.id == 3)
                {
                    int i = Random.Range(1, 5);
                    switch (i)
                    {
                    case 1:
                        SoundMgr.Instance.PlaySound("FailBell1");
                        break;

                    case 2:
                        SoundMgr.Instance.PlaySound("FailBell2");
                        break;

                    case 3:
                        SoundMgr.Instance.PlaySound("FailBell3");
                        break;

                    case 4:
                        SoundMgr.Instance.PlaySound("FailBell4");
                        break;
                    }
                }
            }
        }

        /*
         * else
         * {
         *  //BarManager.Instance.GetImpact(currentRole, PartitionManager.Rank.MISS);
         *  ChargeRole(PartitionManager.Rank.MISS);
         * }*/
    }
Пример #18
0
    void PlayerInputted(int trackNumber)
    {
        //check if multi-times node exists
        if (previousMusicNodes[trackNumber] != null)
        {
            //dispatch beat on hit event (multi-times node is always PERFECT)
            if (beatOnHitEvent != null)
            {
                beatOnHitEvent(trackNumber, Rank.PERFECT);
            }

            //check if the node should be removed
            if (previousMusicNodes[trackNumber].MultiTimesHit())
            {
                //print("Multi-Times Succeed!");
                previousMusicNodes[trackNumber] = null;
            }
        }
        else if (queueForTracks[trackNumber].Count != 0)
        {
            //peek the node in the queue
            MusicNode frontNode = queueForTracks[trackNumber].Peek();

            if (frontNode.times > 0)
            {
                return;                                  //multi-times node should be handled in the Update() func
            }
            float offsetY = Mathf.Abs(frontNode.gameObject.transform.position.y - finishLineY);

            if (offsetY < perfectOffsetY)             //perfect hit
            {
                frontNode.PerfectHit();
                //print("Perfect");

                //dispatch beat on hit event
                if (beatOnHitEvent != null)
                {
                    beatOnHitEvent(trackNumber, Rank.PERFECT);
                }

                queueForTracks[trackNumber].Dequeue();
            }
            else if (offsetY < goodOffsetY)             //good hit
            {
                frontNode.GoodHit();
                //print("Good");

                //dispatch beat on hit event
                if (beatOnHitEvent != null)
                {
                    beatOnHitEvent(trackNumber, Rank.GOOD);
                }

                queueForTracks[trackNumber].Dequeue();
            }
            else if (offsetY < badOffsetY)             //bad hit
            {
                frontNode.BadHit();

                //dispatch beat on hit event
                if (beatOnHitEvent != null)
                {
                    beatOnHitEvent(trackNumber, Rank.BAD);
                }

                queueForTracks[trackNumber].Dequeue();
            }
        }
    }
 public BlockContextModifierNode(MusicNode body)
 {
     Body = body;
 }
Пример #20
0
    public void SearchAndAddToParentNode(Node parentNode, string folder, Action <string> onFileDetected = null)
    {
        if (!Directory.Exists(folder))
        {
            return;
        }

        var dirInfo    = new DirectoryInfo(folder);
        var setDefPath = Path.Combine(folder, @"set.def");

        if (File.Exists(setDefPath))
        {
            onFileDetected?.Invoke(setDefPath);

            var setDef = SetDef.RestoreFrom(setDefPath);
            foreach (var block in setDef.Blocks)
            {
                var setNode = new SetNode(block, folder, parentNode);

                if (0 < setNode.ChildNodeList.Count)
                {
                    parentNode.ChildNodeList.Add(setNode);
                }
            }
            return;
        }
        else
        {
            //----------------
            var fileInfos = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly)
                            .Where((fileInfo) => SearchExtensions.Any(ext => (Path.GetExtension(fileInfo.Name).ToLower() == ext)));
            var anyDtxFile = false;
            foreach (var fileInfo in fileInfos)
            {
                var vpath = fileInfo.FullName;
                onFileDetected?.Invoke(vpath);

                try
                {
                    var music = new MusicNode(vpath, parentNode);
                    parentNode.ChildNodeList.Add(music);
                    anyDtxFile = true;
                }
                catch
                {
                }
            }
            if (anyDtxFile)
            {
                return;
            }
        }

        foreach (var subDirInfo in dirInfo.GetDirectories())
        {
            var DTXFILES   = "dtxfiles.";
            var boxDefPath = Path.Combine(subDirInfo.FullName, @"box.def");
            if (subDirInfo.Name.ToLower().StartsWith(DTXFILES))
            {
                var boxNode = new BoxNode(subDirInfo.Name.Substring(DTXFILES.Length), parentNode);
                parentNode.ChildNodeList.Add(boxNode);

                var backNode = new BackNode(boxNode);
                boxNode.ChildNodeList.Add(backNode);

                SearchAndAddToParentNode(boxNode, subDirInfo.FullName, onFileDetected);
            }
            else if (File.Exists(boxDefPath))
            {
                var boxNode = new BoxNode(boxDefPath, parentNode);
                parentNode.ChildNodeList.Add(boxNode);

                var backNode = new BackNode(boxNode);
                boxNode.ChildNodeList.Add(backNode);

                SearchAndAddToParentNode(boxNode, subDirInfo.FullName, onFileDetected);
            }
            else
            {
                SearchAndAddToParentNode(parentNode, subDirInfo.FullName, onFileDetected);
            }
        }
    }
Пример #21
0
    void Update()
    {
        //for count down
        if (!songStarted)
        {
            return;
        }

        //for pausing
        if (paused)
        {
            if (pauseTimeStamp < 0f)             //not managed
            {
                pauseTimeStamp = (float)AudioSettings.dspTime;
                //print("pausetimestamp:" + pauseTimeStamp.ToString());
                audioSource.Pause();
            }

            return;
        }
        else if (pauseTimeStamp > 0f)         //resume not managed
        {
            pausedTime += (float)AudioSettings.dspTime - pauseTimeStamp;
            //print("resumetimestamp:"+AudioSettings.dspTime.ToString());
            //print("offset"+pausedTime.ToString());
            audioSource.Play();

            pauseTimeStamp = -1f;
        }

        //calculate songposition
        songposition = (float)(AudioSettings.dspTime - dsptimesong - pausedTime) * audioSource.pitch - songInfo.songOffset;
        //print (songposition);

        //check if need to instantiate new nodes
        float beatToShow = songposition / crotchet + BeatsShownOnScreen;

        //loop the tracks for new MusicNodes
        for (int i = 0; i < len; i++)
        {
            int            nextIndex = trackNextIndices[i];
            SongInfo.Track currTrack = tracks[i];

            if (nextIndex < currTrack.notes.Length && currTrack.notes[nextIndex].note < beatToShow)
            {
                SongInfo.Note currNote = currTrack.notes[nextIndex];

                //set z position
                float layerZ = nextLayerZ[i];
                nextLayerZ[i] += LayerOffsetZ;

                //get a new node
                MusicNode musicNode = MusicNodePool.instance.GetNode(trackSpawnPosX[i], startLineY, finishLineY, removeLineY, layerZ, currNote.note, currNote.times, trackColors[i]);

                //enqueue
                queueForTracks[i].Enqueue(musicNode);

                //update the next index
                trackNextIndices[i]++;
            }
        }

        //loop the queue to check if any of them reaches the finish line
        for (int i = 0; i < len; i++)
        {
            //empty queue, continue
            if (queueForTracks[i].Count == 0)
            {
                continue;
            }

            MusicNode currNode = queueForTracks[i].Peek();

            //multi-times note
            if (currNode.times > 0 && currNode.transform.position.y <= finishLineY + goodOffsetY)
            {
                //have previous note stuck on the finish line
                if (previousMusicNodes[i] != null)
                {
                    previousMusicNodes[i].MultiTimesFailed();

                    //dispatch miss event
                    if (beatOnHitEvent != null)
                    {
                        beatOnHitEvent(i, Rank.MISS);
                    }
                }

                //pause the note
                currNode.paused = true;

                //align to finish line
                currNode.transform.position = new Vector3(currNode.transform.position.x, finishLineY, currNode.transform.position.z);

                //deque, but keep a reference
                previousMusicNodes[i] = currNode;
                queueForTracks[i].Dequeue();
            }
            else if (currNode.transform.position.y <= finishLineY - goodOffsetY)               //single time note
            {
                //have previous note stuck on the finish line
                if (previousMusicNodes[i] != null)
                {
                    previousMusicNodes[i].MultiTimesFailed();
                    previousMusicNodes[i] = null;

                    //dispatch miss event
                    if (beatOnHitEvent != null)
                    {
                        beatOnHitEvent(i, Rank.MISS);
                    }
                }

                //deque
                queueForTracks[i].Dequeue();

                //dispatch miss event (if a multi-times note is missed, its next single note would also be missed)
                if (beatOnHitEvent != null)
                {
                    beatOnHitEvent(i, Rank.MISS);
                }
            }
        }


        //check to see if the song reaches its end
        if (songposition > songLength)
        {
            songStarted = false;

            if (songCompletedEvent != null)
            {
                songCompletedEvent();
            }
        }
    }
Пример #22
0
    public void OnTriggerEnter(Collider other)
    {
        MusicNode n = (MusicNode)transform.parent.GetComponent("MusicNode");

        n.Activated();
    }
Пример #23
0
 public InstrumentBlockModifier(MusicNode body, string instrumentName) : base(body)
 {
     InstrumentName = instrumentName;
 }
Пример #24
0
    private void Update()
    {
        if (Input.GetKeyDown("p"))/////////////////////////////////////
        {
            FireBall();
        }

        if (!ConductorCustom.Instance.paused)
        {
            //check if need to instantiate new nodes
            float beatToShow = ConductorCustom.songposition / ConductorCustom.crotchet + ConductorCustom.BeatsShownOnScreen;
            for (int i = 0; i < queueForTracks.Length; i++)
            {
                int            nextIndex = trackNextIndices[i];
                SongInfo.Track currTrack = tracksNode[i];

                if (nextIndex < currTrack.notes.Length && currTrack.notes[nextIndex].note < beatToShow)
                {
                    SongInfo.Note currNote = currTrack.notes[nextIndex];

                    //set z position
                    float layerZ = nextLayerZ[i];
                    nextLayerZ[i] += LayerOffsetZ;
                    //get a new node
                    MusicNode musicNode = MusicNodePool.instance.GetNode(tracks[i].offsetX, partitionManager.startLineY, partitionManager.finishLineY, partitionManager.removeLineY, layerZ, currNote.note, currNote.times, TracksColors[i], idplayer);
                    if (nextNoteIsStone)
                    {
                        musicNode.isStone = true;
                        nextNoteIsStone   = false;
                    }
                    //enqueue
                    queueForTracks[i].Enqueue(musicNode);

                    //update the next index
                    trackNextIndices[i]++;
                }
            }

            for (int i = 0; i < queueForTracks.Length; i++)
            {
                //empty queue, continue
                if (queueForTracks[i].Count == 0)
                {
                    continue;
                }

                MusicNode currNode = queueForTracks[i].Peek();

                //multi-times note
                if (currNode.transform.position.y <= partitionManager.finishLineY - partitionManager.badOffsetY)   //single time note
                {
                    //have previous note stuck on the finish line
                    if (previousMusicNodes[i] != null)
                    {
                        previousMusicNodes[i].MultiTimesFailed();
                        previousMusicNodes[i] = null;

                        //dispatch miss event
                        if (beatOnHitEvent != null)
                        {
                            beatOnHitEvent(i, PartitionManager.Rank.MISS);
                        }
                    }

                    //deque
                    queueForTracks[i].Dequeue();

                    //dispatch miss event (if a multi-times note is missed, its next single note would also be missed)
                    if (beatOnHitEvent != null)
                    {
                        beatOnHitEvent(i, PartitionManager.Rank.MISS);
                    }
                }
            }
        }
    }