Beispiel #1
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Methods: Change Sprite Information
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private void ChangeSpriteInfo(TambourineSoundsManager.SoundTypes eNewSoundType)
    {
        Target.m_eSoundType = eNewSoundType;

        switch (eNewSoundType)
        {
        case TambourineSoundsManager.SoundTypes.CENTER_TAMBOURINE_AREA:
            ChangeSpriteInfo(Target.m_sprRedAreaNormal);
            break;

        case TambourineSoundsManager.SoundTypes.MIDDLE_TAMBOURINE_AREA:
            ChangeSpriteInfo(Target.m_sprBlueAreaNormal);
            break;

        case TambourineSoundsManager.SoundTypes.OUTER_TAMBOURINE_AREA:
            ChangeSpriteInfo(Target.m_sprYellowAreaNormal);
            break;

        case TambourineSoundsManager.SoundTypes.SOFT_TAMBOURINE_SHAKE:
        case TambourineSoundsManager.SoundTypes.HARD_TAMBOURINE_SHAKE:
        case TambourineSoundsManager.SoundTypes.MOVE_TAMBOURINE_SOUND:
        case TambourineSoundsManager.SoundTypes.RATTLE_TAMBOURINE_SHAKE:
            ChangeSpriteInfo(Target.m_sprShakeNormal);
            break;

        default:
            ChangeSpriteInfo(Target.m_sprCymbalNormal);
            break;
        }
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Check if SoundType Matches up to this Note.
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public bool CheckMatchingSoundType(TambourineSoundsManager.SoundTypes eSoundType)
    {
        switch (eSoundType)
        {
        case TambourineSoundsManager.SoundTypes.CENTER_TAMBOURINE_AREA:
            return(m_eSoundType == TambourineSoundsManager.SoundTypes.CENTER_TAMBOURINE_AREA);

        case TambourineSoundsManager.SoundTypes.MIDDLE_TAMBOURINE_AREA:
            return(m_eSoundType == TambourineSoundsManager.SoundTypes.MIDDLE_TAMBOURINE_AREA);

        case TambourineSoundsManager.SoundTypes.OUTER_TAMBOURINE_AREA:
            return(m_eSoundType == TambourineSoundsManager.SoundTypes.OUTER_TAMBOURINE_AREA);

        case TambourineSoundsManager.SoundTypes.SOFT_TAMBOURINE_SHAKE:
        case TambourineSoundsManager.SoundTypes.HARD_TAMBOURINE_SHAKE:
        case TambourineSoundsManager.SoundTypes.MOVE_TAMBOURINE_SOUND:
        case TambourineSoundsManager.SoundTypes.RATTLE_TAMBOURINE_SHAKE:
            return(m_eSoundType == TambourineSoundsManager.SoundTypes.SOFT_TAMBOURINE_SHAKE || m_eSoundType == TambourineSoundsManager.SoundTypes.HARD_TAMBOURINE_SHAKE ||
                   m_eSoundType == TambourineSoundsManager.SoundTypes.MOVE_TAMBOURINE_SOUND || m_eSoundType == TambourineSoundsManager.SoundTypes.RATTLE_TAMBOURINE_SHAKE);

        default:
            return(m_eSoundType == TambourineSoundsManager.SoundTypes.CYMBAL_SHAKER_SOUND_1 || m_eSoundType == TambourineSoundsManager.SoundTypes.CYMBAL_SHAKER_SOUND_2 ||
                   m_eSoundType == TambourineSoundsManager.SoundTypes.CYMBAL_SHAKER_SOUND_3 || m_eSoundType == TambourineSoundsManager.SoundTypes.CYMBAL_SHAKER_SOUND_4 ||
                   m_eSoundType == TambourineSoundsManager.SoundTypes.CYMBAL_SHAKER_SOUND_5 || m_eSoundType == TambourineSoundsManager.SoundTypes.CYMBAL_SHAKER_SOUND_6);
        }
    }
Beispiel #3
0
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //	* New Method: Check Successful Hit?
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 public bool CheckSuccessfulHit(TambourineSoundsManager.SoundTypes eSoundType)
 {
     if (m_lActiveChallengeNotes.Count > 0)
     {
         ChallengeNoteMovement matchingNote = GetFirstMovingNote();
         if (matchingNote != null && matchingNote.CheckMatchingSoundType(eSoundType) && matchingNote.CheckSuccessfulHit())
         //ChallengeNoteMovement matchingNote = GetFirstMatchingNoteType(eSoundType);
         //if(matchingNote != null && matchingNote.CheckSuccessfulHit())
         {
             m_lActiveChallengeNotes.Remove(matchingNote);
             return(true);
         }
         else
         {
             ChallengeScore -= 0.01f;
             Score          -= 0.01f;
             VisibleScore   -= 0.01f;
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Apply Challenge Data File Info To Challenges
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private void ApplyChallengeDataFileInfoToChallenges()
    {
        for (int i = 0; i < Target.m_arChallenges.Length; ++i)
        {
            if (Target.m_arChallenges[i] != null)
            {
                Target.CurrentChallengeID = i;
                string path = (Application.dataPath + "/DEBUG STUFF/Challenge Data/" + Target.CurrentChallengeIDAsString + ".txt");
                if (System.IO.File.Exists(path))
                {
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(path))
                    {
                        string[] challengeData = reader.ReadToEnd().Replace("\r", "").Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
                        Target.CurrentChallenge.m_oChallengeName.EnglishTranslation = challengeData[0].Replace("ChallengeName=", "");
                        Target.CurrentChallenge.BPM = (float)System.Convert.ToDouble(challengeData[1].Replace("ChallengeBPM=", ""));
                        Target.CurrentChallenge.backingTrackDelayTime = (float)System.Convert.ToDouble(challengeData[4].Replace("BackingDelay=", ""));
#if UNITY_EDITOR
                        Target.CurrentChallenge.iosBPM = Target.CurrentChallenge.BPM;
                        Target.CurrentChallenge.iosBackingTrackDelay = Target.CurrentChallenge.backingTrackDelayTime;
#endif
                        string vol = challengeData[5].Replace("BackingVolume=", "");
                        if (vol != "N/A")
                        {
                            Target.CurrentChallenge.m_oChallengeBackingTrackInfo.m_fMaxVolume = (float)System.Convert.ToDouble(vol);
                        }


                        System.Collections.Generic.LinkedList <GameObject> children = new System.Collections.Generic.LinkedList <GameObject>();
                        while (Target.CurrentChallenge.transform.childCount > 0)
                        {
                            Transform child = Target.CurrentChallenge.transform.GetChild(0);
                            child.parent = null;
                            children.AddLast(child.gameObject);
                        }
                        foreach (GameObject child in children)
                        {
                            DestroyImmediate(child);
                        }
                        for (int j = 7; j < challengeData.Length; ++j)
                        {
                            string[] noteData = challengeData[j].Replace("NoteData=", "").Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                            TambourineSoundsManager.SoundTypes eSoundType = (TambourineSoundsManager.SoundTypes)System.Convert.ToInt32(noteData[0]);
                            float fBeatPos = (float)System.Convert.ToDouble(noteData[1]);
                            Target.CurrentChallenge.AddNewChallengeNote(eSoundType, fBeatPos);
                        }

                        EditorUtility.SetDirty(Target.CurrentChallenge);
                    }
                }
                Target.m_arChallenges[i].gameObject.SetActive(false);
            }
        }

        if (Target.m_arChallenges[0] != null)
        {
            Target.m_arChallenges[0].gameObject.SetActive(true);
        }
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Methods: Play Current Note
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public void PlayNote(TambourineSoundsManager.SoundTypes eDesiredSound, float visibilityTime)
    {
        PlaybackInfo pbi = new PlaybackInfo();

        pbi.type      = eDesiredSound;
        pbi.startTime = 0.0f;
        pbi.endTime   = visibilityTime;
        StartCoroutine(PlayNote(pbi));
    }
Beispiel #6
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* Overwritten Method: Draw Editable Values Options
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    protected override void DrawEditableValuesOptions()
    {
        if (Target.m_rChallengeModeInfo != null)
        {
            TambourineSoundsManager.SoundTypes eNewSoundType = (TambourineSoundsManager.SoundTypes)EditorGUILayout.EnumPopup(new GUIContent("Sound Type: ", "What Sound Type is this Representing?"), Target.m_eSoundType);
            if (eNewSoundType != Target.m_eSoundType)
            {
                ChangeSpriteInfo(eNewSoundType);
            }


            float beatPos = DrawFloatField("Beat Position: ", Target.m_fBeatPos, "Which Beat/Metronome Position will this Notation start at?");
            float linePos = DrawFloatField("Line Position: ", Target.m_fLinePos, "Which Line will this Notation sit on?");

            if (beatPos != Target.m_fBeatPos)
            {
                // Move This notation to the specified Beat Position
                Target.m_fBeatPos = beatPos;
                float newX = Target.m_rChallengeModeInfo.victoryLocation.x + Target.m_rChallengeModeInfo.separationDifference.x * beatPos;
                Target.transform.localPosition = new Vector3(newX, Target.transform.localPosition.y, Target.transform.localPosition.z);

                // Placing OTHER Notations after this one on the next few lines over. Makes it look nicer in my opinion!
                if (sm_bAutoPlaceOtherNotations)
                {
                    LinkedList <Transform> lOtherNotations = Target.m_rChallengeModeInfo.GetNotations(Target.transform.name);
                    if (lOtherNotations.Count > 0)
                    {
                        newX += Target.m_rChallengeModeInfo.separationDifference.x * 4;
                        foreach (Transform otherNotation in lOtherNotations)
                        {
                            otherNotation.GetComponent <ChallengeNoteMovement>().m_fBeatPos = Target.m_fBeatPos + 4;
                            otherNotation.localPosition = new Vector3(newX, otherNotation.localPosition.y, otherNotation.localPosition.z);
                        }

                        // Place the Next Notation directly after this one. Keeping the remaining notations further away
                        lOtherNotations.First.Value.GetComponent <ChallengeNoteMovement>().m_fBeatPos = Target.m_fBeatPos + 1;
                        lOtherNotations.First.Value.localPosition = new Vector3(Target.transform.localPosition.x + Target.m_rChallengeModeInfo.separationDifference.x, lOtherNotations.First.Value.localPosition.y, lOtherNotations.First.Value.localPosition.z);
                    }
                }
            }

            if (linePos != Target.m_fLinePos)
            {
                // Move This notation to the specified Line Position
                Target.m_fLinePos = linePos;
                float newY = Target.m_rChallengeModeInfo.victoryLocation.y + Target.m_rChallengeModeInfo.separationDifference.y * linePos;
                Target.transform.localPosition = new Vector3(Target.transform.localPosition.x, newY, Target.transform.localPosition.z);
            }
        }
        else
        {
            DrawLabel("No Challenge Mode Info has been assigned!", Color.red);
        }
    }
//#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Change Sound Type
    //			Doing all the automatic placements for us.
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public void ChangeSoundType(TambourineSoundsManager.SoundTypes eSoundType, float fBeatPos)
    {
        ChangeSpriteInfo(eSoundType);

        // Move This notation to the specified Beat Position
        if (m_rChallengeModeInfo != null)
        {
            m_fBeatPos = fBeatPos;
            float newX = m_rChallengeModeInfo.victoryLocation.x + m_rChallengeModeInfo.separationDifference.x * fBeatPos;
            transform.localPosition = new Vector3(newX, transform.localPosition.y, transform.localPosition.z);
        }
    }
Beispiel #8
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Get First Matching Note
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private ChallengeNoteMovement GetFirstMatchingNoteType(TambourineSoundsManager.SoundTypes eSoundType)
    {
        foreach (ChallengeNoteMovement challengeNote in m_lActiveChallengeNotes)
        {
            if (challengeNote.CurrentState == ChallengeNoteMovement.MovementPhase.MOVEMENT && challengeNote.CheckMatchingSoundType(eSoundType))
            {
                return(challengeNote);
            }
        }

        return(null);
    }
Beispiel #9
0
    public bool UseMidiForAutoPlacement()
    {
        Midi__Init();                       // Init DLL Stuff
        Midi__ReadMidiFile();               // Will open up an OpenFileDialog Window that the user shall use to select a midi
        bool bValidMidi = !Midi__Empty();

        if (bValidMidi)
        {
            // We are about to replace all children with new Notes. Remove all current children from this challenge list.
            LinkedList <GameObject> children = new LinkedList <GameObject>();
            foreach (Transform child in transform)
            {
                children.AddLast(child.gameObject);
            }
            foreach (GameObject child in children)
            {
                DestroyImmediate(child);
            }

            // If We have a link to the Rhythm Game. Set that up as well.
#if UseMemoryGameManager
            if (m_rSoundsRhythmMemoryGame != null)
            {
                m_rSoundsRhythmMemoryGame.ResizePlaylistArray(m_ePlaylistTrack, Midi__Size());
            }
#endif

            // Set BPM
            this.BPM = Midi__BPM();


            // Make Challenge Notes
            while (!Midi__Empty())
            {
#if UseMemoryGameManager
                if (m_rSoundsRhythmMemoryGame != null)
                {
                    m_rSoundsRhythmMemoryGame.SetupEvent(m_ePlaylistTrack, iCurrentIndex, Midi__GetKey(), Midi__GetStartTime(), Midi__GetEndTime());
                }
#endif

                TambourineSoundsManager.SoundTypes eSoundType = GetMIDISoundTypeFromKey(Midi__GetKey());
                float fBeatPos = ((Midi__GetStartTime() + StartDelayTime) / MetronomeTime);
                AddNewChallengeNote(eSoundType, fBeatPos);

                Midi__NextNote();
            }
        }

        Midi__Dispose();
        return(bValidMidi);
    }
Beispiel #10
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Add New CHallenge Note
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public void AddNewChallengeNote(TambourineSoundsManager.SoundTypes eSoundType, float fBeatPos)
    {
        GameObject            challengeNote = Instantiate(m_goChallengeNotePrefab, Vector3.zero, Quaternion.identity) as GameObject;
        ChallengeNoteMovement cnm           = challengeNote.GetComponent <ChallengeNoteMovement>();

        int iCurrentIndex = transform.childCount + 1;

        challengeNote.transform.name          = "Challenge Note - " + (iCurrentIndex < 1000 ? "0" : "") + (iCurrentIndex < 100 ? "0" : "") + (iCurrentIndex < 10 ? "0" : "") + iCurrentIndex.ToString();
        challengeNote.transform.parent        = this.transform;
        challengeNote.transform.localPosition = Vector3.zero;

        cnm.m_rChallengeModeInfo = this;
        cnm.ChangeSoundType(eSoundType, fBeatPos);
    }
Beispiel #11
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Begin Highlight Effect
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public void BeginHighlightEffect(TambourineSoundsManager.SoundTypes eDrumArea)
    {
        if (eDrumArea == TambourineSoundsManager.SoundTypes.CENTER_TAMBOURINE_AREA || eDrumArea == TambourineSoundsManager.SoundTypes.MIDDLE_TAMBOURINE_AREA || eDrumArea == TambourineSoundsManager.SoundTypes.OUTER_TAMBOURINE_AREA)
        {
            m_arTambourineTargets[(int)eDrumArea].bHighlightTarget = true;
            m_arTambourineTargets[(int)eDrumArea].ttHighlightTimer.Reset();

            if (Visible)
            {
                m_arTambourineTargets[(int)eDrumArea].sprHighlightedTambourineTarget.enabled = true;
                m_arTambourineTargets[(int)eDrumArea].sprHighlightedTambourineTarget.color   = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                m_arTambourineTargets[(int)eDrumArea].sprHighlightedTambourineTarget.material.SetColor("_Colour", m_arTambourineTargets[(int)eDrumArea].sprHighlightedTambourineTarget.color);
            }
            else
            {
                m_arTambourineTargets[(int)eDrumArea].sprColouredTambourineTarget.enabled = true;
                m_arTambourineTargets[(int)eDrumArea].sprColouredTambourineTarget.color   = new Color(1.0f, 1.0f, 1.0f, 1.0f);
            }
        }
    }
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //	* New Method: Successful Hit?
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 public bool SuccessfulHit(TambourineSoundsManager.SoundTypes eSoundType)
 {
     return(CurrentChallenge.CheckSuccessfulHit(eSoundType));
 }
 public bool CheckSuccessfulHit(TambourineSoundsManager.SoundTypes eSoundType)
 {
     return(CheckMatchingSoundType(eSoundType) && CheckSuccessfulHit());
 }