public override void Update(RenderContext renderContext) { noteIn.UpdateTarget(targetPos); noteOut.UpdateTarget(targetPos); if ((position.X <= (targetPos.X + 800) && position.X >= (targetPos.X - 1600))) { block.CanDraw = true; } else { block.CanDraw = false; } if (CurrentState == NoteState.Enter) { block.Color = Color.SaddleBrown; if (!block.HitTest(targetPos) && !noteIn.Sprite.HitTest(targetPos) && !noteOut.Sprite.HitTest(targetPos)) { CurrentState = NoteState.Passed; SceneManager.ActiveScene.DoSomething(); } } else { block.Color = Color.White; } base.Update(renderContext); }
private void UpdatePressing() { bool allPressed = true; for (int i = 0; i < noteStates.Length; i++) { NoteState state = noteStates[i]; Note note = notes[i]; NoteData data = noteData[state.NoteDataIndex]; switch (state.PressState) { case NoteStateEnum.Pressed: Color pressedColor = pressedGradient.Evaluate(Time.time - state.TimePressed) * data.Color; state.ConePropertyBlock.SetColor(emissiveColorName, Color.black); state.ConePropertyBlock.SetColor(emissiveColorNameBurst, Color.black); state.DomePropertyBlock.SetColor(emissiveColorName, pressedColor); state.DomePropertyBlock.SetColor(albedorColorName, data.DomeColor); note.DomeRenderer.SetPropertyBlock(state.DomePropertyBlock); note.ConeRenderer.SetPropertyBlock(state.ConePropertyBlock); float pressedPos = pressedPosCurve.Evaluate(Time.time - state.TimePressed) * pressedOffset; note.transform.localPosition = note.InitialPosition + (note.Forward * pressedPos); break; case NoteStateEnum.Reset: case NoteStateEnum.Releasing: default: state.ConePropertyBlock.SetColor(emissiveColorName, Color.black); state.ConePropertyBlock.SetColor(emissiveColorNameBurst, Color.black); state.DomePropertyBlock.SetColor(emissiveColorName, Color.black); state.DomePropertyBlock.SetColor(albedorColorName, data.DomeColor); note.DomeRenderer.SetPropertyBlock(state.DomePropertyBlock); note.ConeRenderer.SetPropertyBlock(state.ConePropertyBlock); if (state.PressedNow) { note.Animator.SetTrigger("Burst"); note.Animator.SetTrigger("Transparency"); state.PressState = NoteStateEnum.Pressed; state.TimePressed = Time.time; note.AudioSource.PlayOneShot(data.Clip, data.Volume); note.AudioSource.PlayOneShot(data.PressClip, data.PressVolume); releaseIndexQueue.Enqueue(i); } allPressed = false; break; } noteStates[i] = state; } if (allPressed) { xyloState = StateEnum.Releasing; timeAllPressed = Time.time; } }
public int CheckOut(GameObject2D sprite) { if (CurrentState == NoteState.Enter) { CurrentState = NoteState.Passed; return(noteOut.CheckCollision(sprite)); } return(-1); }
void StateUpdate() { // -missTime -perTime perTime missTime // none | good | per | good | miss if (State != NoteState.None) { return; } NoteState prevState = State; if (Stage.TheStageSetting.AutoPlay) { BeatOffset = 0f; State = Stage.Time > this.Time ? NoteState.Perfect : NoteState.None; if (prevState != State) { StageScore.AddScore(State); } } else if (Stage.Time - Time > Stage.TheStageSetting.MissTime) { BeatOffset = Stage.TheStageSetting.MissTime; State = NoteState.Miss; if (prevState != State) { StageScore.AddScore(State); } } else if (BeatOffset < -Stage.TheStageSetting.MissTime) { State = NoteState.None; } else if (BeatOffset < -Stage.TheStageSetting.PerfectTime) { State = NoteState.Good; } else if (BeatOffset < Stage.TheStageSetting.PerfectTime) { State = NoteState.Perfect; } else if (BeatOffset < Stage.TheStageSetting.MissTime) { State = NoteState.Good; } else { State = NoteState.Miss; } if (prevState != State) { Ani.SetTrigger(State.ToString()); } }
public void Judge() { this.noteState = NoteState.Inactive; Vector3 pos = this.transform.localPosition; pos.y = 0; this.transform.localPosition = pos; this.timer = 0; }
private void OnRightKeyStateChanged(AccordeonRightKeys noteKey, NoteState state) { var pureNote = AccordeonRightKeyToNote(mRightHandOctaveShift, noteKey); var realNotes = SelectedRightRegister.GetNotes(pureNote); foreach (var n in realNotes) { mMidiHelper.Note(mChannelIdForRightSide, n, state, mKeystrokeForce); } }
public void UpdateState() { switch (state) { default: break; // 生成前 case NoteState.KillUnit: state = NoteState.WaitTap; break; case NoteState.KillLinkStart: state = NoteState.WaitLinkStart; break; case NoteState.KillLinkEnd: state = NoteState.WaitLinkEnd; break; // 生成済み単体タップ待ち case NoteState.WaitTap: state = NoteState.End; break; // 生成済みTouchStart待ち case NoteState.WaitLinkStart: state = NoteState.LinkStarted; Debug.LogWarning("NoteState.LinkStarted"); break; // 生成済みTouchEnd待ち case NoteState.WaitLinkEnd: state = NoteState.End; Debug.LogWarning("NoteState.End"); break; // 終了 case NoteState.End: break; } if (!view) { return; } var debugText = view.GetComponentInChildren <Text>(); if (debugText) { debugText.text = "" + state; debugText.raycastTarget = false; } }
/// <summary> /// Выполняет загрузку и синхронизацию заметок /// </summary> /// <returns></returns> private async Task Sync(NoteState selector = NoteState.Active) { logger.Info("Запуск синхронизации с сервером..."); SyncAnimation = true; await Task.Delay(1500); var watch = Stopwatch.StartNew(); var count = await apiClient.Notes.GetCount(); if (count > 0) { if (selector != NoteState.Active) { Items.Clear(); } CenterLabelVisibility = Visibility.Hidden; var notes = (await LoadNotes()).Where(n => n.State == selector).ToArray(); // Добавляем заметки foreach (var note in notes) { note.RemoveEvent += RemoveNote; note.ArchiveEvent += ArchiveNote; note.EditEvent += EditNote; if (!Items.Contains(note)) { Items.Add(note); } } // Удаляем те что не нужны for (int i = 0; i < Items.Count; i++) { if (!notes.Contains(Items[i])) { Items.RemoveAt(i); } } } else { CenterLabelVisibility = Visibility.Visible; } SyncAnimation = false; watch.Stop(); logger.Info($"Синхронизация завершена. Выполнено за {watch.ElapsedMilliseconds} мс"); }
//[EnableCors("AnyOrigin")] public ActionResult <NoteState> Create(NoteState item) { var gr = _clusterClient.GetGrain <INoteGrain>(item.note_id); if (gr.getNote().Result != "") { return(BadRequest()); } gr.setData(item.finished, item.noteText, item.noteDate); return(StatusCode(201)); }
private NoteItem CreateOneNote(float index, int xId, NoteState state) { var note = new NoteItem(); // ノートに時間情報を付与する note.timeMsec = GetNoteTimeFromIndex(index); // 位置IDを付与 note.xId = xId; // stateを付与 note.state = state; return(note); }
public float Create(float parentWidth, float parentHeight, object masterView, string userNoteFileName, DisplayMessageBoxDelegate displayMessageBoxDelegate, NoteSizeChanging onNoteSizeChanging) { OnNoteSizeChanging = onNoteSizeChanging; RequestDisplayMessageBox = displayMessageBoxDelegate; UserNotePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), userNoteFileName); MasterView = masterView; // create a child control list ChildControls = new List <IUIControl>( ); UserNoteControls = new List <UserNote>( ); //store these seperately so we can back them up and test touch input. // now use a reader to get each element XmlTextReader reader = new XmlTextReader(new StringReader(NoteXml)); try { // begin reading the xml stream bool finishedReading = false; while (finishedReading == false && reader.Read( )) { switch (reader.NodeType) { case XmlNodeType.Element: { if (reader.Name == "Note") { ParseNote(reader, parentWidth, parentHeight); } else { throw new Exception(String.Format("Expected <Note> element. Found <{0}> instead.", reader.Name)); } finishedReading = true; break; } } } } catch (Exception e) { throw new Exception(e.Message + string.Format("\nLine Number: {0}", reader.LineNumber)); } // now load our note state (which will restore stuff) NoteState noteState = LoadState(UserNotePath); return(noteState != null ? noteState.ScrollOffsetPercent : 0.00f); }
public int CheckCollision(GameObject2D sprite) { if (CurrentState == NoteState.Normal) { if (noteIn.CheckCollision(sprite) > 0) { CurrentState = NoteState.Enter; return(1); } return(0); } return(0); }
public Note( string text, string header, NoteState state, DateTime startedAt, TimeSpan duration) { Text = text; Header = header; State = state; StartedAt = startedAt; Duration = duration; }
public void HandleTriggerExit(Note note, Collider other) { if (!other.CompareTag("Player")) { return; } NoteState state = noteStates[note.NoteIndex]; state.ActiveColliders.Remove(other); state.PressedNow = state.ActiveColliders.Count > 0; noteStates[note.NoteIndex] = state; }
public void HandleTriggerEnter(Note note, Collider other) { if (!other.CompareTag("Player")) { return; } NoteState state = noteStates[note.NoteIndex]; state.ActiveColliders.Add(other); state.PressedNow = true; noteStates[note.NoteIndex] = state; }
protected override void Awake() { base.Awake(); List <int> noteDataIndexes = new List <int>(); for (int i = 0; i < notes.Length; i++) { noteDataIndexes.Add(i % noteData.Length); } int n = noteDataIndexes.Count; while (n > 1) { n--; int k = UnityEngine.Random.Range(0, n + 1); int value = noteDataIndexes[k]; noteDataIndexes[k] = noteDataIndexes[n]; noteDataIndexes[n] = value; } noteStates = new NoteState[notes.Length]; for (int i = 0; i < notes.Length; i++) { NoteState state = new NoteState(); state.ActiveColliders = new HashSet <Collider>(); state.ConePropertyBlock = new MaterialPropertyBlock(); state.DomePropertyBlock = new MaterialPropertyBlock(); state.BurstPropertyBlock = new MaterialPropertyBlock(); state.NoteDataIndex = noteDataIndexes[i]; state.NotePlaybackIndex = i; state.TimePressed = -100; state.TimeReleased = -100; noteStates[i] = state; notes[i].Initialize(i, this); NoteData data = noteData[state.NoteDataIndex]; Note note = notes[i]; state.BurstPropertyBlock.SetColor(emissiveColorNameBurst, data.Color); state.DomePropertyBlock.SetColor(emissiveColorName, Color.black); state.DomePropertyBlock.SetColor(albedorColorName, data.DomeColor); state.ConePropertyBlock.SetColor(emissiveColorName, Color.black); note.DomeRenderer.SetPropertyBlock(state.DomePropertyBlock); note.BurstRenderer.SetPropertyBlock(state.BurstPropertyBlock); note.ConeRenderer.SetPropertyBlock(state.ConePropertyBlock); } }
private void OnLeftKeyStateChanged(int bassValveId, NoteState state) { var realNotes = selectedBassRegister.GetNotes(bassValveId); if (realNotes == null) { return; } foreach (var n in realNotes) { mMidiHelper.Note(mChannelIdForLeftSide, n, state, mKeystrokeForce); } }
public static void RemoveAllNotes(NoteState state) { int len = NotePool.Count; for (int i = 0; i < len; i++) { Note note = NotePool[i].GetComponent <Note>(); if (note && note.State == state) { NotePool.DespawnToDefault(NotePool[i]); i--; len--; } } }
public Color colorFromNoteState(NoteState n) { if (n == NoteState.Attempted) { return(Color.FromArgb(255, 198, 50)); } if (n == NoteState.Failed) { return(Color.FromArgb(225, 28, 28)); } if (n == NoteState.Success) { return(Color.FromArgb(20, 200, 20)); } return(Color.FromArgb(0, 0, 0)); }
internal void Note(int channel, int note, NoteState state, int volume = 127) { MidiMessage msg; switch (state) { case NoteState.On: msg = MidiMessage.StartNote(note, volume, channel); break; default: msg = MidiMessage.StopNote(note, 0, channel); break; } midiOut?.Send(msg.RawData); }
public void AddNote(NoteState state, string name) { if (name.Length == 0) { Console.WriteLine("Name cannot be empty"); } else if (Enum.IsDefined(typeof(NoteState), state)) { Note note = new Note(state, name, DateTime.Now); list.Add(note); UpdateCounts(note, true); } else { Console.WriteLine($"Invalid state {state}"); } }
public void SaveState(float scrollOffsetPercent) { // open a stream using (StreamWriter writer = new StreamWriter(UserNotePath, false)) { NoteState noteState = new NoteState( ); // Scroll position noteState.ScrollOffsetPercent = scrollOffsetPercent; // User Notes noteState.UserNoteContentList = new List <NoteState.UserNoteContent>( ); foreach (UserNote note in UserNoteControls) { noteState.UserNoteContentList.Add(note.GetContent( )); } // //Reveal Boxes List <IUIControl> revealBoxes = new List <IUIControl>( ); GetControlOfType <RevealBox>(revealBoxes); noteState.RevealBoxStateList = new List <NoteState.RevealBoxState>( ); foreach (RevealBox revealBox in revealBoxes) { noteState.RevealBoxStateList.Add(revealBox.GetState( )); } // //Text Inputs List <IUIControl> textInputs = new List <IUIControl>( ); GetControlOfType <TextInput>(textInputs); noteState.TextInputStateList = new List <NoteState.TextInputState>( ); foreach (TextInput textInput in textInputs) { noteState.TextInputStateList.Add(textInput.GetState( )); } // now we can serialize this and save it. string json = JsonConvert.SerializeObject(noteState); writer.WriteLine(json); } }
private static void SysCall_StopNoteHandler(FOS_System.Object objState) { NoteState state = (NoteState)objState; if (state.dur_ms >= 0) { state.dur_ms -= 2000; } else { //BasicConsole.WriteLine("Note muted."); Playing = false; Hardware.Timers.PIT.ThePIT.MuteSound(); Hardware.Timers.PIT.ThePIT.UnregisterHandler(state.handlerId); } }
public List <Note> GetNotes(NoteState state) { if (Enum.IsDefined(typeof(NoteState), state)) { List <Note> result = new List <Note>(); this.list.ForEach(note => { if (state == note.noteState) { result.Add(note); } }); return(result); } else { Console.WriteLine($"Invalid state {state}"); return(null); } }
public static void AddScore(NoteState state) { if (!IsOpen) { return; } if (NoteNum <= 0) { Debug.LogWarning("Can NOT add score now. Because the notenum is < 0. Did you forgot to call StageScore.Open() after load a map ?"); return; } switch (state) { case NoteState.Perfect: PerfectNum++; Combo++; MaxCombo = Mathf.Max(MaxCombo, Combo); CurrentScore += K * Combo; break; case NoteState.Good: GoodNum++; Combo++; MaxCombo = Mathf.Max(MaxCombo, Combo); CurrentScore += K * Combo * GoodScoreRant; break; case NoteState.Miss: Combo = 0; MissNum++; break; default: break; } }
public int CheckCollision(GameObject2D sprite) { if (CurrentState == NoteState.Normal) { if (note.HitTest(sprite)) { // Find the bounds of the rectangle intersection float top = Math.Max(note.BoundingRect.Value.Top, sprite.BoundingRect.Value.Top); float bottom = Math.Min(note.BoundingRect.Value.Bottom, sprite.BoundingRect.Value.Bottom); float left = Math.Max(note.BoundingRect.Value.Left, sprite.BoundingRect.Value.Left); float right = Math.Min(note.BoundingRect.Value.Right, sprite.BoundingRect.Value.Right); float width = right - left; float height = bottom - top; float area = width * height; if (area > 100) { if (area > 800) { if (area >= 1500) { CurrentState = NoteState.Passed; return(1); } CurrentState = NoteState.Passed; return(3); } CurrentState = NoteState.Passed; return(2); } return(0); } return(0); } return(0); }
private void UpdateResetting() { for (int i = 0; i < noteStates.Length; i++) { NoteState state = noteStates[i]; Note note = notes[i]; NoteData data = noteData[state.NoteDataIndex]; note.transform.localPosition = Vector3.Lerp(note.transform.localPosition, note.InitialPosition, Time.time - timeAllReleased); state.ConePropertyBlock.SetColor(emissiveColorName, Color.black); state.DomePropertyBlock.SetColor(emissiveColorName, Color.black); state.DomePropertyBlock.SetColor(albedorColorName, data.DomeColor); note.DomeRenderer.SetPropertyBlock(state.DomePropertyBlock); note.ConeRenderer.SetPropertyBlock(state.ConePropertyBlock); if (Time.time > timeAllReleased + 1) { xyloState = StateEnum.Pressing; } } }
public static void Beat(int fret, int stringID, float time = -1f) { int len = NotePool.Count; for (int i = 0; i < len; i++) { Note note = NotePool[i].GetComponent <Note>(); if (note) { if (note.Y != stringID) { continue; } if (note.X != fret && note.Type != NoteInfo.NoteType.Zero) { continue; } if (time < 0f) { time = StageMusic.Main.Time; } if (note.Time > time + TheStageSetting.MissTime) { break; } else { NoteState state = note.Beat(time); if (state != NoteState.None && state != NoteState.Holding) { StageScore.AddScore(state); break; } } } } }
public MidiKey() { state = NoteState.off; velocity = 0; keyPressure = 0; }
/// <summary> /// Restore note to normal pitch /// </summary> public void Tonal() { state = NoteState.Tonal; }
public static void Main() { OwnerThread = ProcessManager.CurrentThread; Kernel.Processes.SystemCalls.SleepThread(Kernel.Processes.SystemCalls.IndefiniteSleepThread); while (!Terminate) { //Scheduler.Disable(); Awake = false; //BasicConsole.WriteLine("Playing notes..."); while (LiveNoteRequests.Count > 0) { //BasicConsole.WriteLine("Playing note..."); NoteRequest theReq = (NoteRequest)LiveNoteRequests.Pop(); try { Hardware.Timers.PIT.MusicalNote note = theReq.note; Hardware.Timers.PIT.MusicalNoteValue duration = theReq.duration; int bpm = theReq.bpm; int dur_ms = (int)duration * 60 * 1000 / (bpm * 16); long do_ms = dur_ms; if (dur_ms >= 2000) { dur_ms -= 2000; do_ms = 2000; } else { dur_ms = 0; } NoteState state = new NoteState() { dur_ms = dur_ms }; if (note != Timers.PIT.MusicalNote.Silent) { Hardware.Timers.PIT.ThePIT.PlaySound((int)note); } Playing = true; state.handlerId = Hardware.Timers.PIT.ThePIT.RegisterHandler(new Hardware.Timers.PITHandler(SysCall_StopNoteHandler, state, 1000000L * do_ms, true)); while (Playing) { Kernel.Processes.SystemCalls.SleepThread(Kernel.Processes.SystemCalls.IndefiniteSleepThread); } } catch { BasicConsole.Write("Error processing note request! "); if (ExceptionMethods.CurrentException != null) { BasicConsole.Write(ExceptionMethods.CurrentException.Message); } BasicConsole.WriteLine(); Playing = false; Hardware.Timers.PIT.ThePIT.MuteSound(); BasicConsole.DelayOutput(15); } finally { DeadNoteRequests.Push(theReq); } } //BasicConsole.WriteLine("Finished playing notes."); if (!Awake) { //BasicConsole.WriteLine("Sleeping non-critical interrupts thread..."); //Scheduler.Enable(); if (Kernel.Processes.SystemCalls.SleepThread(Kernel.Processes.SystemCalls.IndefiniteSleepThread) != Kernel.Processes.SystemCallResults.OK) { BasicConsole.SetTextColour(BasicConsole.error_colour); BasicConsole.WriteLine("Failed to sleep play notes thread!"); BasicConsole.SetTextColour(BasicConsole.default_colour); } } } }