public void Start() { // creer et construire l'arbre this.nodeCourant = new Node(instance); this.nodeCourant.Recursivite(); // selectionner le centre Select(instance); }
public void doAction() { //Desactivated the object /** We can not destroy the object because we are an ref in Action Objects. So we desacived the object to used it after. **/ this.gameObject.SetActive(false); this.nodeSelect = this.nodeCourant.GetCurrentNode(); this.node = this.nodeCourant.Remove(); }
public void Recursivite() { foreach (Transform t in this.gameobject.transform) { if (t.gameObject.name.Contains("Sub_subject")) { Node nodefils = new Node(t.gameObject); Add(nodefils); nodefils.Recursivite(); } } }
public void onKeyboardEvent(ref Event e) { if (writeMode) { updateWriteMode(ref e); print("writemode"); return; } // Rename Action else if (UnityEngine.Input.GetKey(KeyCode.F2)) { textMesh = select.GetComponentInChildren<TextMesh>(); renameAction = new RenameAction(textMesh); writeMode = true; } // Action avec la touche "Controle" else if (UnityEngine.Input.GetKey(KeyCode.LeftControl)) { // Selection des objets avec les fleches directionnelles InputLeftControlAction(); } // Action sans la touche "Controle" else { // A: AddAction if (UnityEngine.Input.GetKeyDown(KeyCode.A)) { addObject(); print("action: add"); } // D: RemoveAction else if (UnityEngine.Input.GetKeyDown(KeyCode.D) && !deleteMode) { // Remove Action /*RemoveAction removeAction = new RemoveAction(this.select); base.managerListener.doAction(removeAction); print("action: remove"); // Supprimer de l'arbre pour ne plus pouvoir le selectionner this.nodeCourant = this.nodeCourant.Remove(); */ // Remove Action RemoveAction removeAction = new RemoveAction(ref this.nodeCourant); base.managerListener.doAction(removeAction); print("action: remove"); this.nodeCourant = removeAction.NodeCourant; // Selectionner le precedent if (this.nodeCourant == null) { Select(instance); } else { Select(nodeCourant.Gameobject); } deleteMode = true; } else if (UnityEngine.Input.GetKeyUp(KeyCode.D) && deleteMode) { deleteMode = false; } // U: UndoAction else if (UnityEngine.Input.GetKeyDown(KeyCode.U)) { base.managerListener.undoAction(); print("action: undo"); } // R: RedoAction else if (UnityEngine.Input.GetKeyDown(KeyCode.R)) { base.managerListener.redoAction(); print("action: redo"); } // Deplacer un objet selectionne avec les fleches directionnelles else { InputMoveAction(); } } }
private void InputLeftControlAction() { // Selectionner le ROOT if (UnityEngine.Input.GetKey(KeyCode.M)) { Select(instance); } // Selectionner le compo PRECEDENT if (UnityEngine.Input.GetKey(KeyCode.LeftArrow)) { Select(this.nodeCourant.Previous().Gameobject); } // Selectionner le compo SUIVANT if (UnityEngine.Input.GetKey(KeyCode.RightArrow)) { Select(this.nodeCourant.Next().Gameobject); } // Selectionner le compo PARENT if (UnityEngine.Input.GetKey(KeyCode.UpArrow)) { // cas special : user monte alors que Center ROOT select if (this.nodeCourant.GetParent().GetSize() != 0) { Select(this.nodeCourant.GetParent().list[0].Gameobject); // Remonter dans l'arbre this.nodeCourant = this.nodeCourant.GetParent(); } } // Selectionner le compo FILS if (UnityEngine.Input.GetKey(KeyCode.DownArrow)) { // cas special : user descend alors que Center ROOT n'a pas de fils if(this.nodeCourant.GetSon() != null) { Select(this.nodeCourant.GetSon().list[0].Gameobject); // Descendre dans l'arbre this.nodeCourant = this.nodeCourant.GetSon(); } } }
public void Add(Node node) { node.Parent = this; this.list.Add(node); }
public Node(GameObject instance) { this.gameobject = instance; this.parent = null; this.list = new List<Node>(); }
public RemoveAction(ref Node node) { this.nodeCourant = node; this.gameObject = node.GetCurrentNode().Gameobject; }
public void onGamePadEvent(ref Event e) { if (writeMode) { updateWriteMode(ref e); print("writemode"); return; } // Rename Action else if (UnityEngine.Input.GetKey(KeyCode.Joystick1Button1)) // A button { textMesh = select.GetComponentInChildren<TextMesh>(); renameAction = new RenameAction(textMesh); writeMode = true; } else if (UnityEngine.Input.GetKey(KeyCode.Joystick1Button6)) { // LT button InputLeftControlAction(); } else { if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button3)) // Y button { AddAction addAction = new AddAction(PrimitiveType.Cube, new Vector3(0, 0, -8)); base.managerListener.doAction(addAction); print("action: add"); this.nodeCourant.Add(new Node(addAction.GameObject)); } else if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button2) && !deleteMode) // B button { RemoveAction removeAction = new RemoveAction(ref this.nodeCourant); base.managerListener.doAction(removeAction); print("action: remove"); this.nodeCourant = removeAction.NodeCourant; if (this.nodeCourant == null) { Select(instance); } else { Select(nodeCourant.Gameobject); } deleteMode = true; } else if (UnityEngine.Input.GetKeyUp(KeyCode.Joystick1Button2) && deleteMode) // B button { deleteMode = false; } else if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button5)) // RB button { base.managerListener.undoAction(); print("action: undo"); } else if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button4)) // LB button { base.managerListener.redoAction(); print("action: redo"); } else { InputMoveAction(); } } }
public void Start() { this.nodeCourant = new Node(instance); this.nodeCourant.Recursivite(); Select(instance); }
private void InputLeftControlAction() { // Selectionner le ROOT if (UnityEngine.Input.GetKey(KeyCode.Joystick1Button0)) // X button { Select(instance); } // Selectionner le compo PRECEDENT if (UnityEngine.Input.GetAxis("Horizontal") == 1) { Select(this.nodeCourant.Previous().Gameobject); } // Selectionner le compo SUIVANT if (UnityEngine.Input.GetAxis("Horizontal") == -1) { Select(this.nodeCourant.Next().Gameobject); } // Selectionner le compo PARENT if (UnityEngine.Input.GetAxis("Vertical") == 1) { // cas special : user monte alors que Center ROOT select if (this.nodeCourant.GetParent().GetSize() != 0) { Select(this.nodeCourant.GetParent().list[0].Gameobject); // Remonter dans l'arbre this.nodeCourant = this.nodeCourant.GetParent(); } } // Selectionner le compo FILS if (UnityEngine.Input.GetAxis("Vertical") == -1) { // cas special : user descend alors que Center ROOT n'a pas de fils if(this.nodeCourant.GetSon() != null) { Select(this.nodeCourant.GetSon().list[0].Gameobject); // Descendre dans l'arbre this.nodeCourant = this.nodeCourant.GetSon(); } } }