public void ResetBrush() { if (curRenderer != null) { Destroy(curRenderer.gameObject); curRenderer = null; StopSound?.Invoke("TattooGun"); } }
private void Draw() { Ray r = cam.ScreenPointToRay(Input.mousePosition); bool hit = Physics2D.Raycast(r.origin, r.direction, Mathf.Infinity, targetLayer); if (hit) { if (Input.GetMouseButtonDown(0)) { CreateBrush(); PlaySound?.Invoke("TattooGun"); } if (Input.GetMouseButton(0)) { if (curRenderer == null) { CreateBrush(); } Vector2 curPos = cam.ScreenToWorldPoint(Input.mousePosition); if (curPos != previousPos) { AddPoint(curPos); previousPos = curPos; } } else { curRenderer = null; StopSound?.Invoke("TattooGun"); } } else { curRenderer = null; StopSound?.Invoke("TattooGun"); } }
private void OnDisable() { ResetCursor(); ResetBrush(); StopSound?.Invoke("TattooGun"); }
public void Update(float time, bool[] b, bool[] released) { if (!initialized) { return; } ReadPpdData(time, SpeedScale * EventManager.BPM); ReadExternalPpdData(time); Logger.Instance.AddLog("Time:{0}, pressed:{1}, released:{2}", time, String.Join(",", b.Select(v => v ? "1" : "0").ToArray()), String.Join(",", released.Select(v => v ? "1" : "0").ToArray())); foreach (Mark mk in MarkLayer.Children.Reverse()) { if (removeMarks.Contains(mk)) { continue; } var exmk = mk as ExMarkBase; var results = new MarkResults(); int soundType = -1; bool remove = false; var isAuto = false; switch (AutoMode) { case AutoMode.All: isAuto = true; break; case AutoMode.ExceptSlide: isAuto = !mk.IsScratch; break; } if (exmk != null) { remove = exmk.ExUpdate(EventManager.GetCorrectTime(time, mk.Time), SpeedScale * EventManager.BPM, ref b, ref released, results, isAuto, ref soundType, CreateEffect ); if (isAuto) { if (soundType >= 0 && soundType < 10) { var index = randomChangeManager.Invert(soundType); if (PlaySound != null) { PlaySound.Invoke(index, true); } } else if (soundType >= 10) { var index = randomChangeManager.Invert(soundType - 10); if (StopSound != null) { StopSound.Invoke(index, false); } if (EventManager.GetReleaseSound(index) && PlaySound != null) { PlaySound.Invoke(index, false); } } } else { //manual if (exmk.IsScratch && exmk.IsLong && soundType >= 0 && soundType < 10) { var index = randomChangeManager.Invert(soundType); if (PlaySound != null) { PlaySound.Invoke(index, false); } } else { var index = randomChangeManager.Invert(soundType); if (EventManager.GetReleaseSound(index) && PlaySound != null) { PlaySound.Invoke(index, false); } } } } else { remove = mk.Update(EventManager.GetCorrectTime(time, mk.Time), SpeedScale * EventManager.BPM, ref b, results, isAuto, ref soundType, CreateEffect ); if (isAuto) { if (soundType != -1) { var index = randomChangeManager.Invert(soundType); if (PlaySound != null) { PlaySound.Invoke(index, false); } } } } if (results[EffectType.Cool] || results[EffectType.Fine]) { if (ACPressing[(int)mk.ButtonType] != null) { OnPressingButton(mk.ButtonType, false); for (int i = 0; i < ACPressing.Length; i++) { if (ACPressing[i] != null) { AddToRemove(ACPressing[i]); } } Array.Clear(ACPressing, 0, ACPressing.Length); } if (ChangeCombo != null) { ChangeCombo.Invoke(true, mk.Position); } } if (results[EffectType.Pressing]) { // 同時にHoldが始まったときに2個目ので1個目のを消す if (ACPressing[(int)mk.ButtonType] != null && ACPressing[(int)mk.ButtonType] != mk) { OnPressingButton(mk.ButtonType, false); for (int i = 0; i < ACPressing.Length; i++) { if (ACPressing[i] != null) { AddToRemove(ACPressing[i]); } } Array.Clear(ACPressing, 0, ACPressing.Length); } if (OnPressingButton(mk.ButtonType, true)) { for (int i = 0; i < ACPressing.Length; i++) { if (ACPressing[i] != null) { AddToRemove(ACPressing[i]); } } Array.Clear(ACPressing, 0, ACPressing.Length); } ACPressing[(int)mk.ButtonType] = exmk; RemoveFromConnection(exmk); } if (results[EffectType.PressReleased]) { OnPressingButton(mk.ButtonType, false); for (int i = 0; i < ACPressing.Length; i++) { if (ACPressing[i] != null) { AddToRemove(ACPressing[i]); } } Array.Clear(ACPressing, 0, ACPressing.Length); } if (results[EffectType.Slide]) { var slideExMark = exmk as SlideExMark; for (var i = slideExMark.ProcessedPressingFrames; i < slideExMark.PressingFrames; i++) { var position = slideExMark.GetPressedSlidePosition(i + 1); if (slideExMark.IsMaxSlide && (i + 1) == slideExMark.ExCount) { // do nothing for max slide } else { var score = 10 * (i + 1); Slide?.Invoke(slideExMark, position, score, exmk.IsRight); } } slideExMark.ProcessedPressingFrames = slideExMark.PressingFrames; } if (results[EffectType.Safe] || results[EffectType.Sad] || results[EffectType.Worst]) { if (ChangeCombo != null) { ChangeCombo.Invoke(false, mk.Position); } } if (results[EffectType.Cool] || results[EffectType.Fine] || results[EffectType.Safe] || results[EffectType.Sad] || results[EffectType.Worst]) { if (EvaluateCount != null) { EvaluateCount.Invoke(results.First, false); } } if (remove) { if (exmk is SlideExMark && ((SlideExMark)exmk).IsMaxSlide) { var slideExMark = ((SlideExMark)exmk); var score = 1000 + 10 * slideExMark.ExCount; var position = slideExMark.GetPressedSlidePosition(slideExMark.ExCount); MaxSlide?.Invoke(slideExMark, position, score, exmk.IsRight); } AddToRemove(mk); } } foreach (Mark mk in removeMarks) { MarkLayer.RemoveChild(mk); mk.Dispose(); } if (MarkLayer.ChildrenCount > 0 && AutoMode == AutoMode.None) { for (int i = 0; i < 10; i++) { int iter = MarkLayer.ChildrenCount - 1; while (b[i] && iter >= 0) { var mk = MarkLayer[iter] as Mark; if (mk is ExMarkBase exmk && exmk.ExMarkState != ExMarkBase.ExState.Waiting) { iter--; continue; } var eval = mk.Evaluate(time); if (eval == EffectType.None) { iter--; continue; } Action proc = () => { b[i] = false; ChangeCombo?.Invoke(false, mk.Position); EvaluateCount.Invoke(eval, true); mk_ChangeMarkEvaluate(mk, eval, true, false, mk.Position); MarkLayer.RemoveChild(mk); RemoveFromConnection(mk); mk.Dispose(); }; if (scriptManager.ProcessMissPressManager.Process(mk, (MarkType)i, out bool isMissPress)) { if (isMissPress) { proc(); break; } } else if (mk.NoteType == NoteType.AC || (mk.NoteType == NoteType.ACFT && !mk.IsScratch)) { proc(); break; } iter--; } } } removeMarks.Clear(); Update(); }
public void Update(float time, bool[] b, bool[] released, bool fadeout) { if (!initialized) { return; } cd.Update(); readppddata(time); foreach (Mark mk in marks) { if (removemarks.Contains(mk)) { continue; } ExMark exmk = mk as ExMark; EffectType result = 0; int soundtype = -1; bool remove = false; if (exmk != null) { remove = exmk.ExUpdate(em.GetCorrectTime(time, mk.Time), gameutility.SpeedScale * em.BPM, ref b, ref released, ref result, gameutility.Auto, ref soundtype, CreateEffect ); if (gameutility.Auto) { if (soundtype >= 0 && soundtype < 10) { int index = Array.IndexOf(keychange, soundtype); if (PlaySound != null) { PlaySound.Invoke(index, true); } } else if (soundtype >= 10) { int index = Array.IndexOf(keychange, soundtype - 10); if (StopSound != null) { StopSound.Invoke(index, false); } if (em.GetReleaseSound(index) && PlaySound != null) { PlaySound.Invoke(index, false); } } } else { //manual int index = Array.IndexOf(keychange, soundtype); if (em.GetReleaseSound(index) && PlaySound != null) { PlaySound.Invoke(index, false); } } } else { remove = mk.Update(em.GetCorrectTime(time, mk.Time), gameutility.SpeedScale * em.BPM, ref b, ref result, gameutility.Auto, ref soundtype, CreateEffect ); if (gameutility.Auto) { if (soundtype != -1) { int index = Array.IndexOf(keychange, soundtype); if (PlaySound != null) { PlaySound.Invoke(index, false); } } } } if (result != EffectType.None) { if (result == EffectType.Cool || result == EffectType.Fine) { if (gameutility.Auto && ACPressing[(int)mk.ButtonType] != null) { if (PressingButton != null) { PressingButton.Invoke(mk.ButtonType, false); } for (int i = 0; i < ACPressing.Length; i++) { if (ACPressing[i] != null) { AddRemove(ACPressing[i]); } } Array.Clear(ACPressing, 0, ACPressing.Length); } if (ChangeCombo != null) { ChangeCombo.Invoke(true, new Vector2(mk.Position.X + 10, mk.Position.Y - 60)); } } else if (result == EffectType.Pressing) { if (PressingButton != null) { if (PressingButton.Invoke(mk.ButtonType, true)) { for (int i = 0; i < ACPressing.Length; i++) { if (ACPressing[i] != null) { AddRemove(ACPressing[i]); } } Array.Clear(ACPressing, 0, ACPressing.Length); } } ACPressing[(int)mk.ButtonType] = exmk; CheckConnection(exmk); } else if (result == EffectType.PressReleased) { PressingButton.Invoke(mk.ButtonType, false); for (int i = 0; i < ACPressing.Length; i++) { if (ACPressing[i] != null) { AddRemove(ACPressing[i]); } } Array.Clear(ACPressing, 0, ACPressing.Length); } else { if (ChangeCombo != null) { ChangeCombo.Invoke(false, new Vector2(mk.Position.X + 10, mk.Position.Y - 60)); } } if (!fadeout && result != EffectType.Pressing && result != EffectType.PressReleased) { if (EvaluateCount != null) { EvaluateCount.Invoke((int)result - 1, false); } } } if (remove) { AddRemove(mk); } } foreach (Mark mk in removemarks) { marks.Remove(mk); } if (marks.Count > 0 && !gameutility.Auto) { int iter = 0; for (int i = 0; i < 10; i++) { if (b[i]) { Mark mk = null; while (iter < marks.Count) { mk = marks[iter] as Mark; ExMark exmk = mk as ExMark; if (exmk != null && exmk.ExMarkState != ExMark.ExState.waitingpress) { iter++; } else { break; } } if (iter >= marks.Count || mk == null) { break; } if (mk.AC) { int eval = mk.Evaluate(time); if (eval > 0) { if (ChangeCombo != null) { ChangeCombo(false, new Vector2(mk.Position.X + 10, mk.Position.Y - 60)); } EvaluateCount.Invoke(eval - 1, true); marks.Remove(mk); CheckConnection(mk); } } } } } removemarks.Clear(); }