private void HandleNoteOrbCollisionExit(Collider other) { NoteOrb otherOrb = other.gameObject.GetComponentInActor <NoteOrb>(); if (!otherOrb) { return; } if (IsAbsorbedOrb() || IsCopy(otherOrb)) { return; } if (foreignCores.ContainsKey(otherOrb)) { otherOrb.GiveCores(this, foreignCores[otherOrb]); otherOrb.MergeCores(this); for (int i = 0; i < foreignCores[otherOrb].Count; i++) { selectedNotes.Remove(foreignCores[otherOrb][i].Note); noteCores.Remove(foreignCores[otherOrb][i]); } UpdateCorePositions(); foreignCores.Remove(otherOrb); } }
public static NoteOrb DuplicateNoteOrb(NoteOrb sourceOrb) { //Create new orb with identical position, rotation, and scale NoteOrb copy = DefaultNoteOrb(sourceOrb.transform.position, sourceOrb.transform.rotation); copy.transform.localScale = sourceOrb.transform.localScale; Object.Destroy(copy.transform.Find("Cores").Find("InitialCore").gameObject); copy.NoteCores.Clear(); copy.SelectedNotes.Clear(); //Copy note cores List <NoteCore> sourceCores = sourceOrb.NoteCores; for (int i = 0; i < sourceCores.Count; i++) { NoteCore coreCopy = DuplicateNoteCore(sourceCores[i]); coreCopy.transform.SetParent(copy.transform); coreCopy.transform.localScale = sourceCores[i].transform.localScale; coreCopy.transform.localPosition = sourceCores[i].transform.localPosition; coreCopy.GetComponent <Scalable>().TargetScale = coreCopy.transform.localScale; copy.NoteCores.Add(coreCopy); } copy.SelectedNotes = new List <int>(sourceOrb.SelectedNotes); copy.GetComponent <VRTK_InteractableObject>().isGrabbable = true; return(copy); }
/// <summary> /// The NoteOrb receives cores from a foreign orb. It keeps track of which cores belong to which foreign orb in case it needs to return them. /// </summary> /// <param name="foreignOrb"></param> /// <param name="foreignOrbCores"></param> public void GiveCores(NoteOrb foreignOrb, List <NoteCore> foreignOrbCores) { List <NoteCore> coresCopy = new List <NoteCore>(foreignOrbCores); foreignCores.Add(foreignOrb, coresCopy); for (int i = 0; i < foreignOrbCores.Count; i++) { foreignOrbCores[i].transform.SetParent(coreContainer); noteCores.Add(foreignOrbCores[i]); selectedNotes.Add(foreignOrbCores[i].Note); } UpdateCorePositions(); foreignOrb.SelfDestruct += OnForeignOrbSelfDestruct; }
public void Display() { if (transform.parent.GetComponent <MenuCube>().PlayMode) { return; } gameObject.SetActive(true); NoteOrb noteMini = GetComponentInChildren <NoteOrb>(); if (noteMini != null) { noteMini.SetRootNote(LastSelectedNote.Value); } }
private bool IsCopy(NoteOrb other) { if (selectedNotes.Count != other.SelectedNotes.Count) { return(false); } for (int i = 0; i < selectedNotes.Count; i++) { if (other.SelectedNotes[i] != selectedNotes[i]) { return(false); } } return(true); }
private void HandleNoteOrbCollisionEnter(Collider other) { NoteOrb otherOrb = other.gameObject.GetComponentInActor <NoteOrb>(); if (!otherOrb) { return; } if (!IsAbsorbedOrb() || IsCopy(otherOrb)) { return; } otherOrb.GiveCores(this, noteCores); noteCores.Clear(); selectedNotes.Clear(); StopDisplayingNoteSelector(); }
private void OnDuplicateButtonPressed(object sender, ControllerInteractionEventArgs e) { //Bypass the normal Request/Release in order to seamlessly transfer the note selector to the duplicate orb displayingNoteSelector = false; noteSelector.NoteSelected -= OnNoteSelectionChanged; VRTK_InteractGrab grabber = e.controllerReference.scriptAlias.GetComponent <VRTK_InteractGrab>(); grabber.ForceRelease(); interactable.isGrabbable = false; NoteOrb orbCopy = NoteOrbFactory.DuplicateNoteOrb(this); orbCopy.displayingNoteSelector = true; orbCopy.SetNoteSelectorHand(e.controllerReference); noteSelector.NoteSelected += orbCopy.OnNoteSelectionChanged; grabber.ForceGrab(orbCopy.GetComponent <VRTK_InteractableObject>(), () => { interactable.isGrabbable = true; }, false); }
private void OnForeignOrbSelfDestruct(object sender, EventArgs args) { NoteOrb foreignOrb = sender as NoteOrb; MergeCores(foreignOrb); }
public void MergeCores(NoteOrb foreignOrb) { foreignOrb.SelfDestruct -= OnForeignOrbSelfDestruct; foreignCores.Remove(foreignOrb); }