示例#1
0
 internal static uint ParseNoteColor(NoteColor color)
 {
     if (color == NoteColor.Blue)
     {
         return(0);
     }
     else if (color == NoteColor.Green)
     {
         return(1);
     }
     else if (color == NoteColor.Pink)
     {
         return(2);
     }
     else if (color == NoteColor.Yellow)
     {
         return(3);
     }
     else if (color == NoteColor.White)
     {
         return(4);
     }
     else
     {
         return(0);
     }
 }
示例#2
0
    List <Note> loadNotes()
    {
        string[,] contents = CSVReader.parseCSV(songCsvPath);

        List <Note> workingNotes = new List <Note>();

        // For each row in the parsed CSV
        // Get the timestamp in column [0]
        // Then get the indices of any non-empty cells in that row
        // These marked cells are notes to be played at that timestamp
        for (int i = 1; i < contents.GetLength(0); i++)
        {
            if (string.IsNullOrEmpty(contents[i, 0]))
            {
                // Skip this row if the first cell is blank
                continue;
            }
            float timestamp   = float.Parse(contents[i, 0]);
            int   timestampMs = Mathf.RoundToInt(timestamp * 1000);

            for (int j = 1; j < contents.GetLength(1); j++)
            {
                if (!string.IsNullOrEmpty(contents[i, j]))
                {
                    NoteColor color = NoteColorMethods.getNoteColor(j - 1);
                    workingNotes.Add(new Note(color, timestampMs));
                }
            }
        }
        return(workingNotes);
    }
    private Color NoteColorToColor(NoteColor col)
    {
        Color color = Color.white;

        switch (col)
        {
        case NoteColor.blue:
            color = ColorExtension.hexToColor("007ACC");
            break;

        case NoteColor.green:
            color = Color.green;
            break;

        case NoteColor.yellow:
            color = Color.yellow;
            break;

        case NoteColor.pink:
            color = ColorExtension.hexToColor("EA81DC");
            break;
        }

        return(color);
    }
示例#4
0
        public void ChangeNoteColor(int id, NoteColor color)
        {
            var note = this.GetNoteById(id);

            note.NoteColor = color;

            this.db.Update(note);
            this.db.SaveChanges();
        }
示例#5
0
        public static ScoredClusterHit[] ProcessColor(BSMap map, NoteColor color)
        {
            var json      = map.Data.Notes.Where(n => n.Type == color).ToArray();
            var hits      = json.Select(x => Hit.FromSingle(map, x)).ToArray();
            var clustered = ClusterNotes(hits);
            var scored    = AnalyzeNotes(clustered);

            return(scored);
        }
        public static NoteColorCollection ColorById(NoteColor color)
        {
            if (_noteColors.ContainsKey(color))
            {
                return(_noteColors[color]);
            }

            throw new ArgumentException("Color not present in dictionary: " + color);
        }
示例#7
0
        public void ChangeColor(Note note, NoteColor newColor)
        {
            if (note == null || newColor == null)
            {
                return;
            }
            App.TelemetryClient.TrackEvent("ChangeColor_NoteNotesControlViewModel");

            AppData.ChangeNoteColor(note, newColor);
        }
示例#8
0
        private void OnTriggerEnter(Collider other)
        {
            if (IsOnCooldown() || BeatMap.Inverted != noteDetails.inverted)
            {
                Debug.LogWarning("Note is on cooldown");
                return;
            }
            saberTouched = other.GetComponent <Saber>();
            if (saberTouched != null)
            {
                bool refresh = false;
                currentCooldown += Time.deltaTime;
                BeatMap.EditorState currentState = BeatMap.GetCurrentState();
                // During playback, remove notes as they are hit //
                if (noteDetails.IsVisible() && (currentState == BeatMap.EditorState.Playback ||
                                                currentState == BeatMap.EditorState.Recording))
                {
                    Debug.LogWarning("INversion map-note - " + BeatMap.Inverted + "-" + noteDetails.inverted);
                    Debug.LogWarning("Current beat - " + BeatMap.GetCurrentBeat());
                    Debug.LogWarning("Note beat - " + noteDetails.timeToSpawn);
                    Debug.LogWarning("Difference - " + (BeatMap.GetCurrentBeat() - noteDetails.timeToSpawn));
                    saberTouched.addVibration(.5f, .05f, false);
                    meshRenderer.enabled = false;
                    noteDetails.inverted = !noteDetails.inverted;
                    Debug.LogWarning("Note changed to " + noteDetails.inverted);
                    refresh = true;
                }
                // During editing, highlight if the Note color has already been set //
                else if (currentState == BeatMap.EditorState.Editing && !noteDetails.inverted)
                {
                    saberTouched.Attach(gameObject);
                }

                // During editing if set to neutral, record saber direction and color //
                if ((currentState == BeatMap.EditorState.Editing || currentState == BeatMap.EditorState.Recording) &&
                    noteDetails.color == NoteColor.NONE)
                {
                    SlashDirection direction = saberTouched.GetSlashDirection(this);
                    NoteColor      color     = saberTouched.GetSaberColor();
                    noteDetails.color          = color;
                    noteDetails.slashDirection = direction;
                    refresh = true;
                }
                if (refresh)
                {
                    Refresh();
                    Debug.LogWarning("Notiying mini map of change inverted?- " + noteDetails.inverted);
                    MiniMap.AddNoteChange(noteDetails);
                }
            }
        }
示例#9
0
 public static Color GetNoteColor(NoteColor color)
 {
     if (color == NoteColor.LEFT)
     {
         return(Color.red);
     }
     else if (color == NoteColor.RIGHT)
     {
         return(Color.blue);
     }
     else
     {
         return(Color.grey);
     }
 }
示例#10
0
文件: Note.cs 项目: wortexx/notes
        public Note(Guid id, string title, string text, NoteColor color = NoteColor.Yellow)
            : base(id)
        {
            var clock = NcqrsEnvironment.Get<IClock>();

            Title = title;
            Text = text;
            Color = color;

            ApplyEvent(new NoteAdded
                           {
                               NoteId = id,
                               Title = title,
                               Text = text,
                               CreationDate = clock.UtcNow()
                           });
        }
示例#11
0
    public static int getXPosition(this NoteColor color)
    {
        if (color == NoteColor.GREEN)
        {
            return(-3);
        }
        if (color == NoteColor.RED)
        {
            return(-1);
        }
        if (color == NoteColor.YELLOW)
        {
            return(1);
        }
        if (color == NoteColor.BLUE)
        {
            return(3);
        }

        throw new System.Exception("Invalid NoteColor " + color);
    }
示例#12
0
        public Note(Vector2 position, NoteColor color) : base(position)
        {
            scale = originalScale;
            switch (color)
            {
            case NoteColor.Green:
                noteOrigin      = GameManager.GreenOrigin;
                noteDestination = GameManager.GreenHitter;
                this.color      = Color.SpringGreen;
                break;

            case NoteColor.Red:
                noteOrigin      = GameManager.RedOrigin;
                noteDestination = GameManager.RedHitter;
                this.color      = Color.Red;
                break;

            case NoteColor.Yellow:
                noteOrigin      = GameManager.YellowOrigin;
                noteDestination = GameManager.YellowHitter;
                this.color      = Color.Yellow;
                break;

            case NoteColor.Blue:
                noteOrigin      = GameManager.BlueOrigin;
                noteDestination = GameManager.BlueHitter;
                this.color      = Color.RoyalBlue;
                break;

            case NoteColor.Orange:
                noteOrigin      = GameManager.OrangeOrigin;
                noteDestination = GameManager.OrangeHitter;
                this.color      = Color.MonoGameOrange;
                break;
            }

            this.position = noteOrigin;
        }
示例#13
0
    GameObject getFab(NoteColor color)
    {
        GameObject fab = null;

        if (color == NoteColor.GREEN)
        {
            fab = greenNotePrefab;
        }
        if (color == NoteColor.RED)
        {
            fab = redNotePrefab;
        }
        if (color == NoteColor.YELLOW)
        {
            fab = yellowNotePrefab;
        }
        if (color == NoteColor.BLUE)
        {
            fab = blueNotePrefab;
        }

        return(fab);
    }
示例#14
0
        public static bool ChangeNoteColor(Note note, NoteColor newColor)
        {
            if (note == null)
            {
                return(false);
            }

            Debug.WriteLine("Change note color: " + newColor.Key);
            //App.TelemetryClient.TrackEvent("NoteColorChanged");

            note.Color = newColor;

            bool success = LocalDB.Update(note) == 1;

            if (!success)
            {
                return(false);
            }
            RoamingDB.Update(note);

            var handler = NoteColorChanged;

            if (handler != null)
            {
                handler(null, new NoteColorEventArgs(note, newColor));
            }

            var handler2 = NotesSaved;

            if (handler2 != null)
            {
                handler2(null, EventArgs.Empty);
            }

            return(true);
        }
示例#15
0
        public string GenerateStats()
        {
            Dictionary <string, int> stats = new Dictionary <string, int>();

            stats["taps"]   = (from t in TapData where t != Arrow.None && t != Arrow.All select t).Count();
            stats["length"] = TapData.Count;
            stats["jumps"]  = (from t in TapData where t.IsJump() select t).Count();
            List <NoteColor> colors = new List <NoteColor>()
            {
                NoteColor.Red,
                NoteColor.Yellow,
                NoteColor.Blue,
                NoteColor.Yellow
            };
            int       colorIndex   = 0;
            NoteColor currentColor = colors[0];

            int       streamCount = 0, longestStream = 0, totalStream = 0, currentStream = 0;
            int       jumpStreams = 0, streamsWithJumps = 0;
            int       skip        = 0;
            int       gallopCount = 0;
            bool      hasJump     = false;
            SpeedMode mode;

            SpeedChange nextChange    = null;
            int         changeIndex   = 0;
            int         currentBPM    = SpeedChanges[changeIndex++].BPM;
            double      measureNumber = 4;

            if (SpeedChanges.Count > changeIndex)
            {
                nextChange = SpeedChanges[changeIndex++];
            }

            if (currentBPM <= 100)
            {
                mode = SpeedMode.Slow;
            }
            else if (currentBPM > 100 && currentBPM < 230)
            {
                mode = SpeedMode.Normal;
            }
            else
            {
                mode = SpeedMode.Fast;
            }

            foreach (Arrow a in TapData)
            {
                if (a == Arrow.All)
                {
                    skip = 3;
                    continue;
                }

                switch (mode)
                {
                case SpeedMode.Normal:
                    if (skip > 0)
                    {
                        skip--;
                        if (a > Arrow.None)
                        {
                            currentStream++;
                        }
                        else
                        {
                            if (currentStream >= 3)
                            {
                                streamCount++;
                                totalStream += currentStream;
                                if (currentStream > longestStream)
                                {
                                    longestStream = currentStream;
                                }
                            }
                            else if (currentStream == 2)
                            {
                                gallopCount++;
                            }

                            currentStream = 0;
                        }
                    }
                    else
                    {
                        if (currentColor == NoteColor.Yellow)
                        {
                            if (a > Arrow.None && currentStream > 1)
                            {
                                currentStream--;

                                if (currentStream > 3)
                                {
                                    streamCount++;
                                    totalStream += currentStream;
                                    if (currentStream > longestStream)
                                    {
                                        longestStream = currentStream;
                                    }
                                }

                                hasJump       = false;
                                currentStream = 0;
                            }
                        }
                        else if (currentColor != NoteColor.Yellow)
                        {
                            if (currentStream == 0)
                            {
                                if (a > Arrow.None)
                                {
                                    currentStream++;
                                }
                            }
                            else
                            {
                                if (a > Arrow.None)
                                {
                                    currentStream++;
                                    if (currentStream > 2)
                                    {
                                        if (a.IsJump())
                                        {
                                            jumpStreams++;
                                            if (!hasJump)
                                            {
                                                streamsWithJumps++;
                                            }
                                            hasJump = true;
                                        }
                                    }
                                }
                                else
                                {
                                    if (currentStream >= 3)
                                    {
                                        streamCount++;
                                        totalStream += currentStream;
                                        if (currentStream > longestStream)
                                        {
                                            longestStream = currentStream;
                                        }
                                    }

                                    hasJump       = false;
                                    currentStream = 0;
                                }
                            }
                        }
                    }

                    break;

                case SpeedMode.Slow:
                    if (currentStream == 0)
                    {
                        if (a > Arrow.None)
                        {
                            currentStream++;
                        }
                    }
                    else
                    {
                        if (a > Arrow.None)
                        {
                            currentStream++;
                            if (a.IsJump())
                            {
                                jumpStreams++;
                            }
                        }
                        else
                        {
                            if (currentStream >= 3)
                            {
                                streamCount++;
                                totalStream += currentStream;
                                if (currentStream > longestStream)
                                {
                                    longestStream = currentStream;
                                }
                            }

                            hasJump       = false;
                            currentStream = 0;
                        }
                    }
                    break;

                case SpeedMode.Fast:
                    if (currentColor != NoteColor.Red)
                    {
                        if (a > Arrow.None && currentStream > 1)
                        {
                            currentStream--;

                            if (currentStream > 3)
                            {
                                streamCount++;
                                totalStream += currentStream;
                                if (currentStream > longestStream)
                                {
                                    longestStream = currentStream;
                                }
                            }

                            hasJump       = false;
                            currentStream = 0;
                        }
                    }
                    else if (currentColor == NoteColor.Red)
                    {
                        if (currentStream == 0)
                        {
                            if (a > Arrow.None)
                            {
                                currentStream++;
                                if (a.IsJump())
                                {
                                    jumpStreams++;
                                }
                            }
                        }
                        else
                        {
                            if (a > Arrow.None)
                            {
                                currentStream++;
                            }
                            else
                            {
                                if (currentStream >= 3)
                                {
                                    streamCount++;
                                    totalStream += currentStream;
                                    if (currentStream > longestStream)
                                    {
                                        longestStream = currentStream;
                                    }
                                }

                                currentStream = 0;
                            }
                        }
                    }

                    break;
                }

                measureNumber += .25;
                if (nextChange != null)
                {
                    if (measureNumber >= nextChange.Measure)
                    {
                        currentBPM = nextChange.BPM;

                        if (currentBPM <= 100)
                        {
                            mode = SpeedMode.Slow;
                        }
                        else if (currentBPM > 100 && currentBPM < 230)
                        {
                            mode = SpeedMode.Normal;
                        }
                        else
                        {
                            mode = SpeedMode.Fast;
                        }
                        if (SpeedChanges.Count > changeIndex)
                        {
                            nextChange = SpeedChanges[changeIndex++];
                        }
                    }
                }

                colorIndex   = colorIndex == 3 ? 0 : colorIndex + 1;
                currentColor = colors[colorIndex];
            }

            if (currentStream >= 3)
            {
                totalStream += currentStream;
                if (currentStream > longestStream)
                {
                    longestStream = currentStream;
                }
            }

            int twelfthCount = 0;

            foreach (Arrow a in TapData)
            {
                if (skip > 0)
                {
                    skip--;
                    if (a > Arrow.None)
                    {
                        twelfthCount++;
                    }
                }

                if (a == Arrow.All)
                {
                    skip = 3;
                }
            }

            int trillCount = 0, longestTrill = 0, totalTrill = 0, currentTrill = 0;

            changeIndex   = 0;
            currentBPM    = SpeedChanges[changeIndex++].BPM;
            measureNumber = 4;

            if (SpeedChanges.Count > changeIndex)
            {
                nextChange = SpeedChanges[changeIndex++];
            }

            if (currentBPM <= 100)
            {
                mode = SpeedMode.Slow;
            }
            else if (currentBPM > 100 && currentBPM < 230)
            {
                mode = SpeedMode.Normal;
            }
            else
            {
                mode = SpeedMode.Fast;
            }

            foreach (Arrow a in TapData)
            {
                if (skip > 0)
                {
                    skip--;
                }
                else
                {
                    if (a == Arrow.All)
                    {
                        skip = 3;
                        if (currentTrill >= 3)
                        {
                            trillCount++;
                            totalTrill += currentTrill;
                            if (currentTrill > longestTrill)
                            {
                                longestTrill = currentTrill;
                            }
                        }
                        else if (currentTrill == 2)
                        {
                            gallopCount++;
                        }

                        currentTrill = 0;
                        break;
                    }

                    switch (mode)
                    {
                    case SpeedMode.Normal:
                        if (currentTrill == 0)
                        {
                            if (a > Arrow.None)
                            {
                                currentTrill++;
                            }
                        }
                        else
                        {
                            if (a > Arrow.None)
                            {
                                currentTrill++;
                            }
                            else
                            {
                                if (currentTrill >= 3)
                                {
                                    trillCount++;
                                    totalTrill += currentTrill;
                                    if (currentTrill > longestTrill)
                                    {
                                        longestTrill = currentTrill;
                                    }
                                }
                                else if (currentTrill == 2)
                                {
                                    gallopCount++;
                                }

                                currentTrill = 0;
                            }
                        }
                        break;

                    case SpeedMode.Fast:
                        if (currentTrill == 0)
                        {
                            if (a > Arrow.None)
                            {
                                currentTrill++;
                                skip = 1;
                            }
                        }
                        else
                        {
                            if (a > Arrow.None)
                            {
                                currentTrill++;
                                skip = 1;
                            }
                            else
                            {
                                if (currentTrill >= 3)
                                {
                                    trillCount++;
                                    totalTrill += currentTrill;
                                    if (currentTrill > longestTrill)
                                    {
                                        longestTrill = currentTrill;
                                    }
                                }
                                else if (currentTrill == 2)
                                {
                                    gallopCount++;
                                }

                                currentTrill = 0;
                            }
                        }
                        break;
                    }
                }

                measureNumber += .25;
                if (nextChange != null)
                {
                    if (measureNumber >= nextChange.Measure)
                    {
                        currentBPM = nextChange.BPM;

                        if (currentBPM <= 100)
                        {
                            mode = SpeedMode.Slow;
                        }
                        else if (currentBPM > 100 && currentBPM < 230)
                        {
                            mode = SpeedMode.Normal;
                        }
                        else
                        {
                            mode = SpeedMode.Fast;
                        }
                        if (SpeedChanges.Count > changeIndex)
                        {
                            nextChange = SpeedChanges[changeIndex++];
                        }
                    }
                }

                colorIndex   = colorIndex == 3 ? 0 : colorIndex + 1;
                currentColor = colors[colorIndex];
            }

            if (currentTrill >= 3)
            {
                totalTrill += currentTrill;
                if (currentTrill > longestTrill)
                {
                    longestTrill = currentTrill;
                }
            }
            else if (currentTrill == 2)
            {
                gallopCount++;
            }

            if (streamCount > 0)
            {
                stats["stream_avg"] = (int)(totalStream / streamCount);
            }
            else
            {
                stats["stream_avg"] = 0;
            }
            int freezes = 0, freezeDepth = 0;

            for (int i = 0; i < TapData.Count; i++)
            {
                if ((TapData[i] & FreezeData[i]) > 0)
                {
                    freezes++;
                }

                if (FreezeData[i] > Arrow.None)
                {
                    freezeDepth++;
                }
            }

            stats["stream_long"]  = longestStream;
            stats["stream_total"] = totalStream;
            stats["jump_streams"] = jumpStreams;
            stats["stream_jumps"] = streamsWithJumps;
            stats["freezes"]      = freezes;
            stats["freeze_depth"] = freezeDepth;
            if (trillCount > 0)
            {
                stats["trill_avg"] = (int)(totalTrill / trillCount);
            }
            else
            {
                stats["trill_avg"] = 0;
            }

            stats["trill_long"]  = longestTrill;
            stats["trill_total"] = totalTrill;
            stats["twelth_note"] = twelfthCount;
            stats["gallops"]     = gallopCount;

            StringBuilder sb = new StringBuilder();

            foreach (string k in stats.Keys)
            {
                sb.Append(k + ":" + stats[k] + ",");
            }

            return(sb.ToString());
        }
示例#16
0
 public NoteData(NoteData other)
 {
     guid  = other.guid;
     color = other.color;
     text  = other.text;
 }
示例#17
0
 public NoteData(string guid)
 {
     this.guid = guid;
     color     = NoteColor.Lemon;
     text      = string.Empty;
 }
 public NoteColorEventArgs(NoteColor noteColor)
 {
     NoteColor = noteColor;
     Handled   = false;
 }
示例#19
0
        /// <summary>
        /// Rents a note from the <see cref="NotePool"/>, initializes it and returns it
        /// </summary>
        /// <param name="orderIndex">The note order</param>
        /// <param name="startTime">The time when the note was spawned</param>
        /// <param name="color">The notes color</param>
        /// <param name="hitTime">The time when the note should be hit</param>
        /// <param name="start">Spawn positon</param>
        /// <param name="hit">Position when note should be hit</param>
        /// <param name="destroy">Position when note should be destroyed</param>
        /// <param name="hitSize">The amount a note can be away from the <see cref="_hitPos"/> to be still valid to be hit</param>
        public static Note CreateNew(int orderIndex, float startTime, float hitTime, Vector3 start, Vector3 hit, Vector3 destroy, Vector3 hitSize,
                                     bool bigNote, Sprite defaultNoteSprite, Sprite defaultNoteOverlaySprite, NoteColor color)
        {
            Note n = NotePool.RentOne();

            if (n.transform.childCount == 0)
            {
                GameObject overlayChild = new GameObject();
                overlayChild.AddComponent <SpriteRenderer>().sprite = defaultNoteOverlaySprite;

                overlayChild.transform.SetParent(n.transform);
                overlayChild.transform.localPosition = Vector3.zero;
            }

            n.OrderIndex = orderIndex;
            n.Color      = color;

            n.StartTime = startTime;
            n.HitTime   = hitTime;
            n.HitSize   = hitSize;

            n._startPos   = start;
            n._hitPos     = hit;
            n._minHitPos  = new Vector3(hit.x - hitSize.x, hit.y, hit.z);
            n._maxHitPos  = new Vector3(hit.x + hitSize.x, hit.y, hit.z);
            n._destroyPos = destroy;

            n.State = NoteState.Spawned;

            if (bigNote)
            {
                n.transform.localScale = ActiveTaikoSettings.NoteScaleBig;
            }
            else
            {
                n.transform.localScale = ActiveTaikoSettings.NoteScaleNormal;
            }

            n.IsBigNote = bigNote;

            SpriteRenderer sr = n.GetComponent <SpriteRenderer>();

            switch (color)
            {
            default:
            case NoteColor.Red:
                sr.color = ActiveTaikoSettings.NoteColorRed;
                break;

            case NoteColor.Blue:
                sr.color = ActiveTaikoSettings.NoteColorBlue;
                break;

            case NoteColor.Yellow:
                sr.color = ActiveTaikoSettings.NoteColorYellow;
                break;
            }

            sr.sprite = defaultNoteSprite;

            Vector3 pos = start;

            pos.z = -1000f + orderIndex * .01f;

            n.transform.position = pos;
            n.gameObject.SetActive(true);
            return(n);
        }
示例#20
0
 public Note(NoteColor color, int spawnTimeMs)
 {
     this.color       = color;
     this.spawnTimeMs = Mathf.RoundToInt(spawnTimeMs - spawnToNoteTime * 1000);
 }
示例#21
0
 void OnColorSelected(NoteColor color)
 {
     _noteData.color = color;
     Persist();
     _mode = Mode.Default;
 }
示例#22
0
    public int CheckBulletToDestroy(NoteColor c, TypeOfInput t, float time)
    {
        double pressedTime = patternSynch.noteTimes[bulletToDestroy] - AudioSettings.dspTime;

        pressedTime = pressedTime < 0 ? -pressedTime : pressedTime;

        if (pressedTime <= offsetTolerance)
        {
            projectile = objectPooler.GetBulletToDestroy(bulletToDestroy);
            if (projectile == null)
            {
                return(-1);
            }

            else if ((projectile.isActiveAndEnabled && c.ToString().Equals(projectile.tag) && t == projectile.InputType))
            {
                if (projectile.InputType != TypeOfInput.HOLD)
                {
                    projectile.DestroyOnHit();
                    UpdateBulletToDestroy();
                    patternSynch.DestroyNote();
                    //if (projectile.Source != Projectile.Projectile_Source.ENEMY)
                    //{
                    if (pressedTime < offsetTolerance / 4.5f)
                    {
                        //Debug.Log("PERFECT");
                        return(1);
                    }
                    else if (pressedTime >= offsetTolerance / 4 && pressedTime < offsetTolerance / 3)
                    {
                        //Debug.Log("GOOD");
                        return(2);
                    }
                    else if (pressedTime >= offsetTolerance / 3 && pressedTime < offsetTolerance / 2)
                    {
                        //Debug.Log("MEH");
                        return(3);
                    }
                    else if (pressedTime >= offsetTolerance / 2)    // && pressedTime < offsetTolerance / 1.5f)
                    {
                        //Debug.Log("BAD");
                        return(4);
                    }
                    //}
                    //else
                    //{
                    if (pressedTime < offsetTolerance / 4)
                    {
                        //Debug.Log("PERFECT");
                        return(-1);
                    }
                    else if (pressedTime >= offsetTolerance / 4 && pressedTime < offsetTolerance / 3)
                    {
                        //Debug.Log("GOOD");
                        return(-2);
                    }
                    else if (pressedTime >= offsetTolerance / 3 && pressedTime < offsetTolerance / 2)
                    {
                        //Debug.Log("MEH");
                        return(-3);
                    }
                    else if (pressedTime >= offsetTolerance / 2)    // && pressedTime < offsetTolerance / 1.5f)
                    {
                        //Debug.Log("BAD");
                        return(-4);
                    }
                    //}
                }
            }
        }

        return(0);
    }
示例#23
0
    public override void InitPage()
    {
        StringBuilder sb = new StringBuilder();

        string id = Request.Params["id"];

        if (id.IsInt())
        {
            Edit e = new Edit();
            if (e.Load(id.ToInt()))
            {
                if (!e.Public)
                {
                    if (CurrentUser == null)
                    {
                        return;
                    }

                    if (CurrentUser.UserID != e.UserID)
                    {
                        return;
                    }
                }

                int              twelfthMode  = 0;
                NoteColor        currentColor = NoteColor.Red;
                List <NoteColor> colorCycle   = new List <NoteColor>()
                {
                    NoteColor.Red, NoteColor.Yellow, NoteColor.Blue, NoteColor.Yellow
                };
                int    currentMeasure = 0;
                double yPos           = 16;
                user.Text   = e.UserID;
                song.Text   = Song.GetSong(e.SongID).Title;
                name.Text   = e.Name;
                rating.Text = e.Rating.ToString();
                style.Text  = e.Style;
                e.GenerateSteps();

                Page.Title = "\"" + e.Name + "\"" + " - " + Song.GetSong(e.SongID).Title;

                Arrow  a;
                double multiplier = speed.SelectedValue.ToDouble();
                SpeedMod = multiplier.ToString();
                double sixteenthNoteSpacing = (8 * multiplier);
                double twelfthNoteSpacing   = (10.66 * multiplier);
                double measureHeight        = sixteenthNoteSpacing * 16;
                chartHeight  = (int)(measureHeight * (e.Taps.Count / 16));
                freezeEndPos = 3 * sixteenthNoteSpacing;
                switch (e.Style)
                {
                case "Single":
                    chartWidth = 136;
                    break;

                case "Double":
                    chartWidth = 264;
                    break;

                case "Couple":
                    chartWidth = 364;
                    break;
                }


                Dictionary <Arrow, double> freezeLength = new Dictionary <Arrow, double>();
                freezeLength[Arrow.P1L] = 0;
                freezeLength[Arrow.P1D] = 0;
                freezeLength[Arrow.P1U] = 0;
                freezeLength[Arrow.P1R] = 0;
                freezeLength[Arrow.P2L] = 0;
                freezeLength[Arrow.P2D] = 0;
                freezeLength[Arrow.P2U] = 0;
                freezeLength[Arrow.P2R] = 0;
                double top = 0;
                if (noteskin.SelectedValue == "")
                {
                    for (int i = 0; i < e.Freezes.Count; i++)
                    {
                        a = e.Freezes[i];

                        if (twelfthMode > 0)
                        {
                        }

                        yPos = (((int)i / 4) * (sixteenthNoteSpacing * 4) + ((i % 4) * sixteenthNoteSpacing) + 16) + 2;

                        if (a.HasFlag(Arrow.P1L))
                        {
                            freezeLength[Arrow.P1L]++;
                        }
                        else
                        {
                            if (freezeLength[Arrow.P1L] > 0)
                            {
                                top = yPos - (freezeLength[Arrow.P1L] * sixteenthNoteSpacing);
                                sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 36);
                            }

                            freezeLength[Arrow.P1L] = 0;
                        }

                        if (a.HasFlag(Arrow.P1D))
                        {
                            freezeLength[Arrow.P1D]++;
                        }
                        else
                        {
                            if (freezeLength[Arrow.P1D] > 0)
                            {
                                top = yPos - (freezeLength[Arrow.P1D] * sixteenthNoteSpacing);
                                sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 68);
                            }

                            freezeLength[Arrow.P1D] = 0;
                        }

                        if (a.HasFlag(Arrow.P1U))
                        {
                            freezeLength[Arrow.P1U]++;
                        }
                        else
                        {
                            if (freezeLength[Arrow.P1U] > 0)
                            {
                                top = yPos - (freezeLength[Arrow.P1U] * sixteenthNoteSpacing);
                                sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 100);
                            }

                            freezeLength[Arrow.P1U] = 0;
                        }

                        if (a.HasFlag(Arrow.P1R))
                        {
                            freezeLength[Arrow.P1R]++;
                        }
                        else
                        {
                            if (freezeLength[Arrow.P1R] > 0)
                            {
                                top = yPos - (freezeLength[Arrow.P1R] * sixteenthNoteSpacing);
                                sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 132);
                            }

                            freezeLength[Arrow.P1R] = 0;
                        }


                        if (e.Style == "Double")
                        {
                            if (a.HasFlag(Arrow.P2L))
                            {
                                freezeLength[Arrow.P2L]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2L] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2L] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 164);
                                }

                                freezeLength[Arrow.P2L] = 0;
                            }

                            if (a.HasFlag(Arrow.P2D))
                            {
                                freezeLength[Arrow.P2D]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2D] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2D] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 196);
                                }

                                freezeLength[Arrow.P2D] = 0;
                            }

                            if (a.HasFlag(Arrow.P2U))
                            {
                                freezeLength[Arrow.P2U]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2U] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2U] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 228);
                                }

                                freezeLength[Arrow.P2U] = 0;
                            }

                            if (a.HasFlag(Arrow.P2R))
                            {
                                freezeLength[Arrow.P2R]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2R] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2R] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 260);
                                }

                                freezeLength[Arrow.P2R] = 0;
                            }
                        }

                        else if (e.Style == "Couple")
                        {
                            if (a.HasFlag(Arrow.P2L))
                            {
                                freezeLength[Arrow.P2L]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2L] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2L] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 164 + 100);
                                }

                                freezeLength[Arrow.P2L] = 0;
                            }

                            if (a.HasFlag(Arrow.P2D))
                            {
                                freezeLength[Arrow.P2D]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2D] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2D] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 196 + 100);
                                }

                                freezeLength[Arrow.P2D] = 0;
                            }

                            if (a.HasFlag(Arrow.P2U))
                            {
                                freezeLength[Arrow.P2U]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2U] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2U] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 228 + 100);
                                }

                                freezeLength[Arrow.P2U] = 0;
                            }

                            if (a.HasFlag(Arrow.P2R))
                            {
                                freezeLength[Arrow.P2R]++;
                            }
                            else
                            {
                                if (freezeLength[Arrow.P2R] > 0)
                                {
                                    top = yPos - (freezeLength[Arrow.P2R] * sixteenthNoteSpacing);
                                    sb.AppendFormat(freezeTemplate, top + 16, (yPos - (sixteenthNoteSpacing * 3) - (top - (sixteenthNoteSpacing * 2))), 260 + 100);
                                }

                                freezeLength[Arrow.P2R] = 0;
                            }
                        }
                    }
                }

                Arrow f = Arrow.None;
                for (int i = 0; i < e.Taps.Count; i++)
                {
                    a = e.Taps[i];
                    f = e.Freezes[i];

                    currentColor = colorCycle[i % 4];

                    yPos = (((int)i / 4) * (sixteenthNoteSpacing * 4) + ((i % 4) * sixteenthNoteSpacing) + 16) + 1;
                    if (i % 16 == 0)
                    {
                        sb.AppendFormat(measureTemplate, (currentMeasure * measureHeight) + 24, (currentMeasure + 1));
                        currentMeasure++;
                    }

                    if (a == Arrow.All)
                    {
                        twelfthMode = 3;
                        continue;
                    }

                    if (twelfthMode > 0)
                    {
                        if (twelfthMode == 3)
                        {
                            currentColor = NoteColor.Red;
                        }
                        else
                        {
                            currentColor = NoteColor.Green;
                        }

                        yPos = (((int)i / 4) * (sixteenthNoteSpacing * 4) + (((3 - twelfthMode) % 3) * twelfthNoteSpacing) + 16) + 1;
                        twelfthMode--;
                    }

                    if (a.HasFlag(Arrow.P1L))
                    {
                        if (noteskin.SelectedValue == "C")
                        {
                            currentColor = f.HasFlag(Arrow.P1L) ? NoteColor.Blue : NoteColor.Red;
                        }

                        sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "left", yPos, 36);
                    }

                    if (a.HasFlag(Arrow.P1D))
                    {
                        if (noteskin.SelectedValue == "C")
                        {
                            currentColor = f.HasFlag(Arrow.P1D) ? NoteColor.Blue : NoteColor.Red;
                        }

                        sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "down", yPos, 68);
                    }

                    if (a.HasFlag(Arrow.P1U))
                    {
                        if (noteskin.SelectedValue == "C")
                        {
                            currentColor = f.HasFlag(Arrow.P1U) ? NoteColor.Blue : NoteColor.Red;
                        }

                        sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "up", yPos, 100);
                    }

                    if (a.HasFlag(Arrow.P1R))
                    {
                        if (noteskin.SelectedValue == "C")
                        {
                            currentColor = f.HasFlag(Arrow.P1R) ? NoteColor.Blue : NoteColor.Red;
                        }

                        sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "right", yPos, 132);
                    }

                    if (e.Style == "Double")
                    {
                        if (a.HasFlag(Arrow.P2L))
                        {
                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "left", yPos, 164);
                        }

                        if (a.HasFlag(Arrow.P2D))
                        {
                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "down", yPos, 196);
                        }

                        if (a.HasFlag(Arrow.P2U))
                        {
                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "up", yPos, 228);
                        }

                        if (a.HasFlag(Arrow.P2R))
                        {
                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "right", yPos, 260);
                        }
                    }

                    else if (e.Style == "Couple")
                    {
                        if (a.HasFlag(Arrow.P2L))
                        {
                            if (noteskin.SelectedValue == "C")
                            {
                                currentColor = f.HasFlag(Arrow.P2L) ? NoteColor.Blue : NoteColor.Red;
                            }

                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "left", yPos, 164 + 100);
                        }

                        if (a.HasFlag(Arrow.P2D))
                        {
                            if (noteskin.SelectedValue == "C")
                            {
                                currentColor = f.HasFlag(Arrow.P2D) ? NoteColor.Blue : NoteColor.Red;
                            }

                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "down", yPos, 196 + 100);
                        }

                        if (a.HasFlag(Arrow.P2U))
                        {
                            if (noteskin.SelectedValue == "C")
                            {
                                currentColor = f.HasFlag(Arrow.P2U) ? NoteColor.Blue : NoteColor.Red;
                            }

                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "up", yPos, 228 + 100);
                        }

                        if (a.HasFlag(Arrow.P2R))
                        {
                            if (noteskin.SelectedValue == "C")
                            {
                                currentColor = f.HasFlag(Arrow.P2R) ? NoteColor.Blue : NoteColor.Red;
                            }

                            sb.AppendFormat(imgTemplate, currentColor.ToString().ToLower(), "right", yPos, 260 + 100);
                        }
                    }
                }
            }
        }

        chart_tags.Text = sb.ToString();
    }
 public static Texture2D NoteByColor(NoteColor color)
 {
     return(!_notes.ContainsKey(color) ? LemonNoteTexture : _notes[color]);
 }
示例#25
0
    void SpawnNoteLeft()
    {
        if (hasStarted)
        {
            currentNoteLeft       = noteTypeLeft[currentNoteIndex];
            currentNoteRight      = noteTypeRight[currentNoteIndex];
            currentNoteColorLeft  = noteColorLeft[currentNoteIndex];
            currentNoteColorRight = noteColorRight[currentNoteIndex];

            currentNoteIndex++;

            switch (currentNoteLeft)
            {
            case NoteType.None:
                //print ("None NoteType^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
                break;

            case NoteType.Touch:
            {
                float   myButtonXPosition     = spawnPoint.transform.position.x + Mathf.Sin((angleLeft[currentNoteIndex] * Mathf.PI) / 180) * radius;
                float   myButtonYPosition     = spawnPoint.transform.position.y + Mathf.Cos((angleLeft[currentNoteIndex] * Mathf.PI) / 180) * radius;
                Vector3 myButtonVector        = new Vector3(myButtonXPosition, myButtonYPosition, 0);
                Vector3 myButtonMoveDirection = (myButtonVector - spawnPoint.transform.position).normalized * moveSpeed;


                GameObject myButton = ObjectPooler.SharedInstance.GetPooledNote(ObjectPooler.SharedInstance.notesPooledLeft);
                if (myButton != null)
                {
                    myButton.transform.position = spawnPoint.transform.position;
                    myButton.transform.rotation = spawnPoint.transform.rotation;
                    //keep color to use in ScaleAcrDistance
                    realcolorLeft = myButton.GetComponent <SpriteRenderer> ().color;
                    //fade color for first frame
                    myButton.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, .01f);
                    myButton.SetActive(true);
                }

                //GameObject myButton = Instantiate (noteTouchLeft, spawnPoint.transform.position, spawnPoint.transform.rotation) as GameObject;
                myButton.transform.SetParent(yourCanvasVariable.transform);
                myButton.GetComponent <Rigidbody> ().velocity = new Vector2(myButtonMoveDirection.x, myButtonMoveDirection.y);
                myButton.transform.rotation = Quaternion.Euler(0, 0, -1 * angleLeft[currentNoteIndex]);
            }
            break;


            //LongHold Not Spawning
            case NoteType.LongHold:
            {
                float   myButtonXPosition     = spawnPoint.transform.position.x + Mathf.Sin((angleLeft[currentNoteIndex] * Mathf.PI) / 180) * radius;
                float   myButtonYPosition     = spawnPoint.transform.position.y + Mathf.Cos((angleLeft[currentNoteIndex] * Mathf.PI) / 180) * radius;
                Vector3 myButtonVector        = new Vector3(myButtonXPosition, myButtonYPosition, 0);
                Vector3 myButtonMoveDirection = (myButtonVector - spawnPoint.transform.position).normalized * moveSpeed;


                GameObject myButton = LongHoldPooler.SharedInstance.GetPooledLHNote(LongHoldPooler.SharedInstance.LHPooledLeft);
                if (myButton != null)
                {
                    myButton.transform.position = spawnPoint.transform.position;
                    myButton.transform.rotation = spawnPoint.transform.rotation;
                    //keep color to use in ScaleAcrDistance
                    realcolorLeft = myButton.GetComponent <SpriteRenderer> ().color;
                    //fade color for first frame
                    myButton.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, .01f);
                    myButton.SetActive(true);
                }

                //GameObject myButton = Instantiate (noteTouchLeft, spawnPoint.transform.position, spawnPoint.transform.rotation) as GameObject;
                myButton.transform.SetParent(yourCanvasVariable.transform);
                myButton.GetComponent <Rigidbody> ().velocity = new Vector2(myButtonMoveDirection.x, myButtonMoveDirection.y);
                myButton.transform.rotation = Quaternion.Euler(0, 0, -1 * angleLeft[currentNoteIndex]);
            }
            break;

            default:
                //print ("Incorrect NoteType^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
                break;
            }
        }
    }
 public InspectorNoteAttribute(string header, string message, NoteColor color)
 {
     this.header  = header;
     this.message = message;
     this.color   = NoteColorToColor(color);
 }