//Types: 0 = Normal Note (On top of and hit) 1 = Touch Note (Just on top of) 2 = Hold Note (On top of and hold) protected Note CreateNote(float time, int lane, float speed, char type, float holdtime, int specialnum) { Note note = new Note { Time = time, Lane = lane, Speed = speed, Currtime = time, SpecialNum = specialnum, HitTimeThreshold = HitTimeThreshold }; note.setType(type); GameObject noteObject = null; if (note.isTouchNote) { noteObject = Instantiate(TouchNotePrefab); } else if (note.isHoldNote) { noteObject = Instantiate(HoldNotePrefab); noteObject.GetComponent <HoldNoteScript>().speed = speed; noteObject.GetComponent <HoldNoteScript>().length = -speed * holdtime; note.setHoldLength(noteObject.GetComponent <HoldNoteScript>().length); //Debug.Log(1 / (BMReader.GetBps() * 2)); noteObject.GetComponent <HoldNoteScript>().interval = 1 / (BMReader.GetBps() * 2); HoldNoteScript holdscript = noteObject.GetComponent <HoldNoteScript>(); holdscript.NoteManager = this; holdscript.Note = note; } else if (note.isHitNote) { noteObject = Instantiate(NotePrefab); } else { //Do nothing } //Debug.Log("Lane:"+lane); if (noteObject) { noteObject.transform.position = new Vector2(LanePositions[lane], transform.position.y); NoteMovement noteMovement = noteObject.GetComponent <NoteMovement>(); noteMovement.NoteManager = this; noteMovement.Note = note; NoteJudgement noteJudgement = noteObject.GetComponent <NoteJudgement>(); noteJudgement.NoteManager = this; noteJudgement.Note = note; return(note); } return(null); }
void Update() { if (Note.Currtime < -Note.HitTimeThreshold * 4 / 3) { GameObject child = transform.GetChild(0).gameObject; float alpha = Mathf.Clamp(1 - (2 * timeafter / (3 * NoteManager.DisplayedTimeAfter)), 0, 255); try { child.GetComponent <Renderer>().material.color = new Color(1, 1, 1, alpha); } catch { } timeafter += Time.deltaTime; if (Note.isHoldNote && GetComponent <HoldNoteScript>()) { HoldNoteScript hnote = GetComponent <HoldNoteScript>(); if (hnote.top) { hnote.top.transform.GetChild(0).GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, alpha); } try { hnote.SetAlpha(alpha); /** * hnote.bottom.GetComponent<Renderer>().material.color = new Color(hnote.c.r, hnote.c.g, hnote.c.b, alpha); * hnote.top.GetComponent<Renderer>().material.color = new Color(hnote.c.r, hnote.c.g, hnote.c.b, alpha); * hnote.bottom.transform.GetChild(0).GetComponent<Renderer>().material.color = new Color(1, 1, 1, alpha); * hnote.top.transform.GetChild(0).GetComponent<Renderer>().material.color = new Color(1, 1, 1, alpha); * //hnote.lr.material.SetFloat("_Lightness", 1-alpha); * hnote.lr.material.SetColor("_Color", new Color(hnote.lr.material.color.r *(alpha), hnote.lr.material.color.g * (alpha), hnote.lr.material.color.b * ( alpha), alpha)); * hnote.lr.material.SetColor("_Outline", new Color(hnote.lr.material.color.r * (alpha), hnote.lr.material.color.g * (alpha), hnote.lr.material.color.b * (alpha), alpha)); * //hnote.lr.material.SetColor("_Color", new Color(0, 0, 0, alpha)); */ } catch { } } } }