public override Draggable OnDragEvent(DragEventType type, int id, Draggable current, DraggableType target) { if (type == DragEventType.Over) { this.mouseOver = id; } else { if (type == DragEventType.Down) { if (this.contents[id].type != PType.Empty) { GameObject obj = new GameObject("Draggable"); Draggable_Nucleon dr = (Draggable_Nucleon)obj.AddComponent(typeof(Draggable_Nucleon)); dr.type = this.contents[id].type; this.contents[id].type = PType.Empty; this.mouseDown = id; return(dr); } } else { if (type == DragEventType.Up) { if (target && target.CanDrop(current)) { target.Drop(current); current.Die(); } else { if (current) { current.FailDrag(); this.Drop(current); } } this.mouseDown = -1; return(null); } else { if (type == DragEventType.Exit) { this.mouseOver = -1; } } } } return(current); }
public override Draggable OnDragEvent(DragEventType type, int id, Draggable current, DraggableType target) { if (type == DragEventType.Over) { this.mouseOver = id; this.Rebuild(); } else { if (type == DragEventType.Down) { int newp = this.p; int newn = this.n; if (this.points[id].state == PType.P) { newp--; } else { newn--; } if (newp > 0 && AtomChart.elements[newp - 1].nuclides[newn] != null) { this.p = newp; this.n = newn; GameObject obj = new GameObject("Draggable"); Draggable_Nucleon dr = (Draggable_Nucleon)obj.AddComponent(typeof(Draggable_Nucleon)); dr.type = this.points[id].state; this.randomizeOrder = Random.value; this.mouseDown = id; this.Rebuild(); return(dr); } } else { if (type == DragEventType.Up) { if (target && target.CanDrop(current)) { target.Drop(current); if ((target != this) && ((UserAtom.p + 1) <= UserAtom.e)) { Draggable_Nucleon nuc = current as Draggable_Nucleon; if (nuc.type == PType.P) { this.orbitals.RemoveElectron(false); if ((target as Orbitals) || ((target as CreatorBackground) && (this.background.mouseOver == 0))) { this.StartCoroutine(this.ElectronToProton()); } else { if (target as TrayGUI) { this.StartCoroutine(this.ElectronToTray()); } } } } current.Die(); } else { if (current) { current.FailDrag(); this.Drop(current); } } this.randomizeOrder = Random.value; this.mouseDown = -1; this.Rebuild(); return(null); } else { if (type == DragEventType.Exit) { this.mouseOver = -1; this.Rebuild(); } } } } return(current); }