private void GetNoteObject(Note prevNote = null) { // Grab pooled object switch (Type) { case NoteType.Step: noteObject = Side == Side.Left ? Pools.LeftStep.GetPooledObject() : Pools.RightStep.GetPooledObject(); noteObject.transform.position = new Vector3((float)Globals.CalcTransX(this), 0, -5); noteObject.transform.localScale = new Vector3(Globals.BaseNoteScale / 16.0f * Width, Globals.BaseNoteZScale, 1); isScaleSet = true; noteObject.SetActive(true); break; case NoteType.Hold: quadObject = new NoteQuad(Side == Side.Left ? Pools.LeftHold.GetPooledObject() : Pools.RightHold.GetPooledObject()); quadObject.SetActive(true); break; case NoteType.Slide: quadObject = new NoteQuad(Side == Side.Left ? Pools.LeftSlide.GetPooledObject() : Pools.RightSlide.GetPooledObject()); quadObject.SetActive(true); break; case NoteType.Shuffle: noteObject = Side == Side.Left ? Pools.LeftShuffle.GetPooledObject() : Pools.RightShuffle.GetPooledObject(); noteObject.transform.position = new Vector3(0, 0, -5); noteObject.SetActive(true); //quadObject = Side == Side.Left ? Pools.LeftHold.GetPooledObject() : Pools.RightHold.GetPooledObject(); // FIXME use Slide when appropriate //noteQuadObject = new NoteQuad(quadObject); quadObject = new NoteQuad(Side == Side.Left ? Pools.LeftHold.GetPooledObject() : Pools.RightHold.GetPooledObject()); // FIXME use Slide when appropriate //quadObject.SetVerts(this, prevNote); //quadObject.transform.position = new Vector3(quadObject.XOffset, -0.0001f, -10); quadObject.SetActive(true); //quadObject.SetActive(true); break; case NoteType.Motion: noteObject = Motion == Motion.Down ? Pools.MotionDown.GetPooledObject() : Pools.MotionUp.GetPooledObject(); noteObject.transform.position = new Vector3(0, 0, -5); isScaleSet = true; noteObject.SetActive(true); break; default: break; } texturesLoaded = true; }
private void SetVerts(double currentBeat) { var curDist = Globals.GetDistAtBeat(currentBeat); var y1 = Globals.GetDistAtBeat(parent.BeatLocation) - curDist - Globals.StepNoteHeightOffset + 1; var y2 = Globals.GetDistAtBeat(parent.BeatLocation) - curDist - Globals.StepNoteHeightOffset; SetVerts( (float)Globals.CalcTransX(0, 16, Side.Left), (float)Globals.CalcTransX(0, 16, Side.Right), (float)y1, (float)Globals.CalcTransX(0, 16, Side.Left), (float)Globals.CalcTransX(0, 16, Side.Right), (float)y2, 0.05f); }
private void SetVerts(double currentBeat) { //var y1 = (parent.BeatLocation - currentBeat) * Globals.BeatToWorldYUnits + Globals.StepNoteHeightOffset; //var y2 = (parent.BeatLocation - currentBeat) * Globals.BeatToWorldYUnits - Globals.StepNoteHeightOffset; var curDist = Globals.GetDistAtBeat(currentBeat); var y1 = Globals.GetDistAtBeat(parent.BeatLocation) - curDist + Globals.StepNoteHeightOffset; var y2 = Globals.GetDistAtBeat(parent.BeatLocation) - curDist - Globals.StepNoteHeightOffset; SetVerts( (float)Globals.CalcTransX(parent, Side.Left), (float)Globals.CalcTransX(parent, Side.Right), (float)y1, (float)Globals.CalcTransX(parent, Side.Left), (float)Globals.CalcTransX(parent, Side.Right), (float)y2); }
public static bool CheckHit(Note note) { var noteMin = Globals.CalcTransX(note, Side.Left); var noteMax = Globals.CalcTransX(note, Side.Right); float diffMS = float.MaxValue; if (note.Type != NoteType.Shuffle) { var validPoints = Points.Where(x => x.Value.Valid && x.Value.MinX <noteMax && x.Value.MaxX> noteMin).ToList(); if (validPoints.Count == 0) { return(false); // No need to modify hit result-- defaults to false } validPoints.Sort((x, y) => Math.Abs(x.Value.Beat - note.BeatLocation).CompareTo(Math.Abs(y.Value.Beat - note.BeatLocation))); // Use the closest point and get the time difference //float diffMS = (float)(((note.BeatLocation - validPoints.First().Beat) * 60 / Globals.CurrentBpm)); diffMS = (float)(Globals.GetSecAtBeat(note.BeatLocation) - Globals.GetSecAtBeat(validPoints.First().Value.Beat)); if (diffMS > NoteTiming.Bad) // Too soon to hit, just leave { return(false); } // All other times are valid note.HitResult.WasHit = true; note.HitResult.Difference = diffMS; } else { var validPoints = Points.Where(x => x.Value.Valid && (float)(Globals.GetSecAtBeat(note.BeatLocation) - Globals.GetSecAtBeat(x.Value.UpdateBeat)) < NoteTiming.Shuffle && x.Value.VelX >= NoteTiming.ShuffleVelocityThreshold).ToList(); if (validPoints.Count == 0) { return(false); // No need to modify hit result-- defaults to false } // If any points exist, then we're fine note.HitResult.WasHit = true; note.HitResult.Difference = diffMS; } return(true); }
private void SetVerts(double currentBeat) { var curDist = Globals.GetDistAtBeat(currentBeat); var y1 = Globals.GetDistAtBeat(parent.BeatLocation) - curDist; var y2 = Globals.GetDistAtBeat(prevNote.BeatLocation) - curDist; int reps = (int)(Math.Ceiling(Math.Abs(y1 - y2) / repetitionY)); // Offset y's if the note is a step note //if (prevNote.Type == NoteType.Step) // y2 += Globals.StepNoteHeightOffset; /*else*/ if (prevNote.Type == NoteType.Shuffle) { //y2 += Globals.ShuffleNoteHeightOffset; y2 -= Globals.ShuffleNoteHeightOffset; } if (parent.Type == NoteType.Shuffle) { y1 -= Globals.ShuffleNoteHeightOffset; } if (parent.Type == NoteType.Slide) { y1 -= Globals.StepNoteHeightOffset; y2 -= Globals.StepNoteHeightOffset; } if (parent.Type == NoteType.Hold) { y2 -= Globals.StepNoteHeightOffset; } var topNote = parent.Type == NoteType.Hold || parent.Type == NoteType.Shuffle ? prevNote : parent; SetVerts( Globals.CalcTransX(topNote, Side.Left), Globals.CalcTransX(topNote, Side.Right), y1, Globals.CalcTransX(prevNote, Side.Left), Globals.CalcTransX(prevNote, Side.Right), y2, reps); }
private void SetVerts(double currentBeat) { var curDist = Globals.GetDistAtBeat(currentBeat); var y1 = Globals.GetDistAtBeat(parent.BeatLocation) - curDist + Globals.ShuffleNoteHeightOffset; var y2 = Globals.GetDistAtBeat(parent.BeatLocation) - curDist - Globals.ShuffleNoteHeightOffset; var minXNote = parent.LaneIndex > prevNote.LaneIndex ? prevNote : parent; var maxXNote = parent.LaneIndex > prevNote.LaneIndex ? parent : prevNote; float leftOffset = 0; float rightOffset = 0; //float leftOffset = shuffleStartSide == Side.Left ? (float)Globals.ShuffleXOffset : 0; //float rightOffset = shuffleStartSide == Side.Right ? (float)Globals.ShuffleXOffset : 0; SetVerts( (float)Globals.CalcTransX(minXNote, Side.Left) + rightOffset, (float)Globals.CalcTransX(maxXNote, Side.Right) - leftOffset, (float)y1, (float)Globals.CalcTransX(minXNote, Side.Left) + rightOffset, (float)Globals.CalcTransX(maxXNote, Side.Right) - leftOffset, (float)y2); }
public HitState CheckHold(TouchCollection tc, double currentBeat) { if (currentBeat < StartNote.BeatLocation) { IsPlayerHolding = false; return(HitState.Unknown); } Note firstNote, secondNote; if (Notes[0].BeatLocation > currentBeat) { firstNote = StartNote; secondNote = Notes[0]; } else if (Notes.Count < 2 || Notes.Last().BeatLocation < currentBeat) { IsPlayerHolding = false; return(HitState.Unknown); } else { firstNote = Notes.Reverse <Note>().First(x => x.BeatLocation <= currentBeat); secondNote = Notes.First(x => x.BeatLocation >= currentBeat); } if (firstNote == null || secondNote == null) { IsPlayerHolding = false; return(HitState.Unknown); } bool useFirstNote = false; double noteMin = 0, noteMax = 0; // Interpolate based on currentBeat switch (secondNote.Type) { case NoteType.Step: // Shouldn't be possible case NoteType.Motion: IsPlayerHolding = false; return(HitState.Unknown); case NoteType.Hold: // Lane index and width is the same as the first note case NoteType.Shuffle: // Actual shuffle motion is not calculated here (but perhaps we need to figure in some dead space?) useFirstNote = true; break; case NoteType.Slide: // Lane index and width must be interpolated double fNoteMin = Globals.CalcTransX(firstNote, Side.Left); double fNoteMax = Globals.CalcTransX(firstNote, Side.Right); double sNoteMin = Globals.CalcTransX(secondNote, Side.Left); double sNoteMax = Globals.CalcTransX(secondNote, Side.Right); double ratio = (currentBeat - firstNote.BeatLocation) / (secondNote.BeatLocation - firstNote.BeatLocation); noteMin = (sNoteMin - fNoteMin) * ratio + fNoteMin; noteMax = (sNoteMax - fNoteMax) * ratio + fNoteMax; break; default: break; } if (useFirstNote) { noteMin = Globals.CalcTransX(firstNote, Side.Left); noteMax = Globals.CalcTransX(firstNote, Side.Right); } var validPoints = tc.Points.Where(x => x.Value.MinX <noteMax && x.Value.MaxX> noteMin).ToList(); if (validPoints.Count == 0 && !(Globals.AutoMode == GameSettingsScreen.AutoMode.Auto)) { IsPlayerHolding = false; } else { IsPlayerHolding = true; HitTexture.SetVerts((float)noteMax, (float)noteMin, (float)-Globals.StepNoteHeightOffset, (float)Globals.StepNoteHeightOffset, 0.1f); } var gradeBeat = GradePoints.Find(x => Math.Abs(x.GradeBeat - currentBeat) < NoteTiming.BeatTolerance && x.State == HitState.Unknown); if (gradeBeat != null) { if (IsPlayerHolding) { gradeBeat.State = HitState.Hit; } else { gradeBeat.State = HitState.Miss; } return(gradeBeat.State); } return(HitState.Unknown); }