// Start is called before the first frame update void Start() { scheduler.Start(() => { var edges = graph.GetEdges(current.id); Node ret; if (edges.Count == 0) { ret = graph.GetRoot(); } else { if (edges.Count == 1) { ret = graph.GetNode(edges.ElementAt(0)); } else { ret = graph.GetNode(edges.ElementAt(rng.Next(edges.Count))); } } current = ret; EffectController.GetInstance().OnActivateNode(current); return(ret); }); is_playing = true; }
public void SetState(State s) { state = s; if (state == State.MENU_INPUT) { menu.SetActive(true); EffectController.GetInstance().OnEnterMenu(); } else { menu.SetActive(false); EffectController.GetInstance().Clear(); } }
void OnEnd(Touch t) { //Debug.Log(input_state.state); Ray ray = ScreenToRay(t.position); RaycastHit hit; switch (input_state.state) { case InputState.State.NODE_SELECT: //Node selected : go to menu GetComponent <InputManager>().SetState(InputManager.State.MENU_INPUT); break; case InputState.State.NODE_DRAG: //delete node dragged to border Vector3 pos = ClampPosition(selection.transform.position); bool is_root = (selection == GetComponent <GameController>().GetRootNode()); bool drag_to_border = (selection.transform.position - pos).sqrMagnitude > 1e-3; if (drag_to_border && !is_root) { GetComponent <GameController>().RemoveNode(selection); selection = null; } else { selection.transform.position = pos; } break; case InputState.State.EDGE_DRAG: dummy_node.SetActive(false); dummy_edge.SetActive(false); // avoid raycast hit itself selection.GetComponent <ArrowMove>().gameObject.SetActive(false); if (Physics.Raycast(ray, out hit)) { GameObject from = dummy_edge.GetComponent <Edge>().origin.gameObject; GameObject to = hit.transform.gameObject; if (from != to && isNode(to)) { GetComponent <GameController>().CreateEdge(from, to); } } else { GameObject from = dummy_edge.GetComponent <Edge>().origin.gameObject; GetComponent <GameController>().CreateEdge(from, dummy_node.transform.position); } selection.GetComponent <ArrowMove>().MoveToOrigin(); selection.GetComponent <ArrowMove>().gameObject.SetActive(true); dummy_edge.GetComponent <Edge>().origin = null; break; case InputState.State.SLIDER_DRAG: break; case InputState.State.DECORATION_DRAG: selection.transform.parent.GetComponent <DecorationPallete>().SetLayer(0); //Needed to avoid raycast on itself dummy_decor.SetActive(false); if (Physics.Raycast(ray, out hit)) { GameObject o = hit.transform.gameObject; var socket = o.GetComponent <DecorationSocket>(); var decor = dummy_decor.GetComponent <Decoration>(); dummy_decor.layer = 0; if (socket != null) { if (socket.Set(decor)) { dummy_decor.SetActive(true); //Debug.Log(string.Format("Decoration placed({0})!", decor.id)); } else { Destroy(dummy_decor); } } else { Destroy(dummy_decor); } } else { Destroy(dummy_decor); } //selection.SetActive(true); EffectController.GetInstance().Clear(); break; } input_state.Clear(); }
void OnBegin(Touch t, GameObject obj) { if (obj != null) { if (obj.name.Contains("EdgeLink")) { input_state.SetEdgeDrag(); Vector3 position = ScreenToRay(t.position).origin; position.z = 0; dummy_edge.GetComponent <Edge>().origin = obj.transform.parent.GetComponent <Node>(); dummy_node.transform.position = position; dummy_node.SetActive(true); dummy_edge.SetActive(true); } else if (obj.name.Contains("TimeSlider")) { input_state.SetSliderDrag(); } else if (obj.name.Contains("Decoration")) { input_state.SetDecorationDrag(); Decoration dec = obj.GetComponent <Decoration>(); dummy_decor = DecorationInstancer.GetInstance().Create(dec.type, dec.id); dummy_decor.transform.position = obj.transform.position; dummy_decor.layer = 8; obj.transform.parent.GetComponent <DecorationPallete>().SetLayer(8); EffectController.GetInstance().OnDecorationDrag(); } else if (obj.name.Contains("BPM")) { obj.GetComponent <BpmController>().Click(); } else if (obj.name.Contains("Play")) { obj.GetComponent <PlayController>().Click(); } else if (obj.name.Contains("Reload")) { GameController.GetInstance().Reload(); } else if (obj.name.Equals("Help")) { obj.GetComponent <HelpController>().Enable(); } else if (obj.name.Contains("HelpPlane")) { obj.transform.parent.gameObject.GetComponent <HelpController>().Next(); } else if (isNode(obj)) { input_state.SetNodeSelect(); GetComponent <InputManager>().menu.GetComponent <SliderMenu>().Centralized(obj.GetComponent <Node>().note); } else { input_state.Clear(); } } else { input_state.Clear(); } }