Esempio n. 1
0
    bool CheckTextureInSkin()
    {
        Skin customSkin = SkinManager.Instance.currentSkin;

        Note note = nCon.note;

        Note.NoteType    noteType    = NoteVisualsManager.GetVisualNoteType(note);
        Note.SpecialType specialType = NoteVisualsManager.IsStarpower(note);

        int arrayPos = NoteVisuals2DManager.GetNoteArrayPos(note);

        Note.NoteType visualNoteType = noteType;

        if (!Globals.ghLiveMode)
        {
            if (noteType == Note.NoteType.Hopo && Globals.drumMode)
            {
                visualNoteType = Note.NoteType.Strum;
            }
        }

        string noteKey = NoteVisuals2DManager.GetSkinKey(arrayPos, noteType, specialType, Globals.ghLiveMode);

        Sprite[] sprites = SkinManager.Instance.currentSkin.GetSprites(noteKey);

        return(sprites != null && sprites.Length > 0);
    }
    public static string GetSkinKey(int notePos, Note.NoteType noteType, Note.SpecialType specialType, bool isGhl)
    {
        skinKeySb.Clear();      // Reuse the same builder to reduce GC allocs
        StringBuilder sb = skinKeySb;

        sb.AppendFormat("{0}_", notePos);

        if (specialType == Note.SpecialType.StarPower)
        {
            sb.AppendFormat("sp_");
        }
        else
        {
            sb.AppendFormat("reg_");
        }

        switch (noteType)
        {
        case Note.NoteType.Strum:
        {
            sb.AppendFormat("strum");
            break;
        }

        case Note.NoteType.Hopo:
        {
            sb.AppendFormat("hopo");
            break;
        }

        case Note.NoteType.Tap:
        {
            sb.AppendFormat("tap");
            break;
        }

        case Note.NoteType.Cymbal:
        {
            sb.AppendFormat("cymbal");
            break;
        }

        default:
            break;
        }

        if (isGhl)
        {
            sb.AppendFormat("_ghl");
        }

        return(sb.ToString());
    }
Esempio n. 3
0
    public static int GetSkinKeyHash(int notePos, Note.NoteType noteType, Note.SpecialType specialType, bool isGhl)
    {
        int result = 4;
        int salt   = 1231;

        result = unchecked (result * salt + notePos);
        result = unchecked (result * salt + (int)noteType);
        result = unchecked (result * salt + (int)specialType);
        result = unchecked (result * salt + (isGhl ? 1 : -1));

        return(result);
    }
    public static Note.SpecialType IsStarpower(Note note)
    {
        Note.SpecialType specialType = Note.SpecialType.None;

        int index = SongObjectHelper.FindClosestPositionRoundedDown(note.tick, note.chart.starPower);

        if (index != SongObjectHelper.NOTFOUND)
        {
            Starpower sp = note.chart.starPower[index];
            if (sp.tick == note.tick || (sp.tick <= note.tick && sp.tick + sp.length > note.tick))
            {
                specialType = Note.SpecialType.StarPower;
            }
        }

        return(specialType);
    }
Esempio n. 5
0
    public static Note.SpecialType IsStarpower(Note note)
    {
        Note.SpecialType specialType = Note.SpecialType.None;

        foreach (Starpower sp in note.chart.starPower)
        {
            if (sp.tick == note.tick || (sp.tick <= note.tick && sp.tick + sp.length > note.tick))
            {
                specialType = Note.SpecialType.StarPower;
            }
            else if (sp.tick > note.tick)
            {
                break;
            }
        }

        return(specialType);
    }
    bool CheckTextureInSkin()
    {
        Skin customSkin = SkinManager.Instance.currentSkin;

        Note note = nCon.note;

        Note.NoteType    noteType    = NoteVisualsManager.GetVisualNoteType(note);
        Note.SpecialType specialType = NoteVisualsManager.IsStarpower(note);

        int arrayPos = NoteVisuals2DManager.GetNoteArrayPos(note, ChartEditor.Instance.laneInfo);

        Note.NoteType visualNoteType = noteType;

        if (!Globals.ghLiveMode)
        {
            if (noteType == Note.NoteType.Hopo && Globals.drumMode)
            {
                visualNoteType = Note.NoteType.Strum;
            }
        }

        bool isInSkin;
        bool isGhl = Globals.ghLiveMode;
        int  hash  = NoteVisuals2DManager.GetSkinKeyHash(arrayPos, noteType, specialType, isGhl);

        if (textureInSkinCache.TryGetValue(hash, out isInSkin))
        {
            return(isInSkin);
        }
        else
        {
            string   noteKey = NoteVisuals2DManager.GetSkinKey(arrayPos, noteType, specialType, isGhl);
            Sprite[] sprites = SkinManager.Instance.currentSkin.GetSprites(noteKey);

            isInSkin = sprites != null && sprites.Length > 0;
            textureInSkinCache[hash] = isInSkin;

            return(isInSkin);
        }
    }
Esempio n. 7
0
    public virtual void UpdateVisuals()
    {
        Note note = nCon.note;

        if (note != null)
        {
            noteType = note.type;

            // Star power?
            specialType = IsStarpower(note);

            // Update note visuals
            if (!noteRenderer)
            {
                noteRenderer = GetComponent <Renderer>();
            }
            noteRenderer.sortingOrder = -(int)note.tick;

            if (Globals.drumMode && note.guitarFret == Note.GuitarFret.Open)
            {
                noteRenderer.sortingOrder -= 1;
            }
        }
    }
Esempio n. 8
0
    public static string GetSkinKey(int notePos, Note.NoteType noteType, Note.SpecialType specialType, bool isGhl)
    {
        int hash = GetSkinKeyHash(notePos, noteType, specialType, isGhl);

        string stringKey;

        if (skinKeySkinCache.TryGetValue(hash, out stringKey))
        {
            return(stringKey);
        }

        skinKeySb.Clear();      // Reuse the same builder to reduce GC allocs
        StringBuilder sb = skinKeySb;

        sb.AppendFormat("{0}_", notePos);

        if (specialType == Note.SpecialType.StarPower)
        {
            sb.AppendFormat("sp_");
        }
        else
        {
            sb.AppendFormat("reg_");
        }

        switch (noteType)
        {
        case Note.NoteType.Strum:
        {
            sb.AppendFormat("strum");
            break;
        }

        case Note.NoteType.Hopo:
        {
            sb.AppendFormat("hopo");
            break;
        }

        case Note.NoteType.Tap:
        {
            sb.AppendFormat("tap");
            break;
        }

        case Note.NoteType.Cymbal:
        {
            sb.AppendFormat("cymbal");
            break;
        }

        default:
            break;
        }

        if (isGhl)
        {
            sb.AppendFormat("_ghl");
        }

        stringKey = sb.ToString();
        skinKeySkinCache[hash] = stringKey;

        return(stringKey);
    }
Esempio n. 9
0
    bool CheckTextureInSkin()
    {
        Texture2D textureInSkin = null;
        Skin      customSkin    = SkinManager.Instance.currentSkin;

        Note note = nCon.note;

        Note.NoteType    noteType    = note.type;
        Note.SpecialType specialType = NoteVisualsManager.IsStarpower(note);

        int arrayPos = GetSpriteArrayPos(note);

        if (Globals.ghLiveMode)
        {
            if (noteType == Note.NoteType.Strum)
            {
                if (specialType == Note.SpecialType.StarPower)
                {
                    textureInSkin = customSkin.sp_strum_ghl[arrayPos];
                }
                else
                {
                    textureInSkin = customSkin.reg_strum_ghl[arrayPos];
                }
            }
            else if (noteType == Note.NoteType.Hopo)
            {
                if (specialType == Note.SpecialType.StarPower)
                {
                    textureInSkin = customSkin.sp_hopo_ghl[arrayPos];
                }
                else
                {
                    textureInSkin = customSkin.reg_hopo_ghl[arrayPos];
                }
            }
            // Tap notes
            else
            {
                if (!note.IsOpenNote())
                {
                    if (specialType == Note.SpecialType.StarPower)
                    {
                        textureInSkin = customSkin.sp_tap_ghl[arrayPos];
                    }
                    else
                    {
                        textureInSkin = customSkin.reg_tap_ghl[arrayPos];
                    }
                }
            }
        }
        else
        {
            if (noteType == Note.NoteType.Strum)
            {
                if (specialType == Note.SpecialType.StarPower)
                {
                    textureInSkin = customSkin.sp_strum[arrayPos];
                }
                else
                {
                    textureInSkin = customSkin.reg_strum[arrayPos];
                }
            }
            else if (noteType == Note.NoteType.Hopo)
            {
                if (specialType == Note.SpecialType.StarPower)
                {
                    textureInSkin = customSkin.sp_hopo[arrayPos];
                }
                else
                {
                    textureInSkin = customSkin.reg_hopo[arrayPos];
                }
            }
            // Tap notes
            else
            {
                if (note.guitarFret != Note.GuitarFret.Open)
                {
                    if (specialType == Note.SpecialType.StarPower)
                    {
                        textureInSkin = customSkin.sp_tap[arrayPos];
                    }
                    else
                    {
                        textureInSkin = customSkin.reg_tap[arrayPos];
                    }
                }
            }
        }

        return(textureInSkin);
    }