public override void OnExit() { GateObject gateObject = _selectedGate.GetComponent <GateObject>(); gateObject.Deselect(); context.ShowActionsGatePanel(false); }
public SelectGateAction(Editor context, GateObject selectedGate, EditorState previousState) : base(context) { //_nextGate = nextGate; _selectedGate = selectedGate; _previousState = previousState; }
/// <summary> /// </summary> /// <param name="context">Le SandBoxManager qui est le contexte du jeu</param> /// <param name="row">Numero de la ligne où l'evaluation du circuit s'arrete</param> /// <param name="previousState">Etat precedent</param> public ShowResult(Editor context, int row, int col, EditorState previousState, GateObject selectedGate) : base(context) { _row = row; _col = col; _previousState = previousState; _selectedGate = selectedGate; }
public GateTaskObject(FileStream file, GateObject gate, uint send_block_size, uint send_delay) { file_ = file; gate_ = gate; send_block_size_ = send_block_size; send_block_delay_ = send_delay; }
public void DeselectRow(int row) { for (int i = 0; i < _circuit.NbCol; i++) { GateObject gateObject = GetGateObject(row, i); gateObject.Deselect(); } }
public override void OnGridClick(Tuple <int, int, Editor.ClickPosition> infos) { int row = infos.Item1; int col = infos.Item2; GateObject selectedGate = context.gridBoard.GetGateObject(row, col); context.CurrentState = new SelectGateAction(context, selectedGate, context.CurrentState); }
/// <summary> /// Détruis le GameObject correspondant à une porte et retire leur association du dictionnaire. /// </summary> /// <param name="gateStruct"></param> private void RemoveGate(Circuit.GateStruct gateStruct) { GateObject gateObject = gateObjects[gateStruct]; gateObjects.Remove(gateStruct); gateObject.FadeOutAndDestroy(); }
/// <summary> /// Crée le GameObject correspondant à une porte. /// </summary> /// <param name="gateStruct"></param> private GateObject CreateGateObject(Circuit.GateStruct gateStruct) { Gate gate = gateStruct.gate; GateObject gateObject = ObjectFactory.Build(gate, _gridGame.transform); gateObject.gateStruct = gateStruct; return(gateObject); }
private void SelectGate(GateObject g) { if (g.BodySelected) { if (selectedGate != null) { selectedGate.Selected = false; } selectedGate = g; dragGate = true; cursorOffset = g.Position - InputController.MouseManager.Position; currentConnection = null; } else if (g.SelectedPin.IsSet) { if (currentConnection == null) { if (g.SelectedPin.IsInput) { currentConnection = new ConnectionObject(null, 0, g, g.SelectedPin.PinIndex); } else { currentConnection = new ConnectionObject(g, g.SelectedPin.PinIndex, null, 0); } connectionStart = g.SelectedPin.PinPosition; } else { if (g.SelectedPin.IsInput) { currentConnection.Inputee = g; currentConnection.InputPin = g.SelectedPin.PinIndex; currentConnection.Connect(); } else { currentConnection.Outputee = g; currentConnection.OutputPin = g.SelectedPin.PinIndex; currentConnection.Connect(); } Gate.Update(currentConnection.Inputee, () => { }); gameMenu.Connections.Add(currentConnection); gameMenu.Connections.RemoveAll(c => c.Connected); currentConnection = null; } } else { currentConnection = null; } }
public void SelectCol(int col) { EntryObject entryObject = GetEntryObject(col); entryObject.Select(); Debug.Log("saluttttt"); for (int i = 0; i < _circuit.NbRow; i++) { GateObject gateObject = GetGateObject(i, col); gateObject.Select();//aaaaaaaaaaaaaaaaaaaaaaaaa } }
public void DeselectCol(int col) { EntryObject entryObject = GetEntryObject(col); entryObject.Deselect(); for (int i = 0; i < _circuit.NbRow; i++) { GateObject gateObject = GetGateObject(i, col); gateObject.Deselect(); } }
/** * ###################################################################################################### * ################################################ GATE ################################################ * ###################################################################################################### */ /// <summary> /// Calcule la position que doit occuper l'objet représentant la porte correspondante. /// </summary> /// <param name="gateObject"></param> private Vector3 ComputeGatePosition(GateObject gateObject) { Circuit.GateStruct gateStruct = gateObject.gateStruct; int row = gateStruct.row; int col = gateStruct.col; int nbEntries = gateStruct.gate.NbEntries; float col_offset = (nbEntries - 1) / 2f; Vector3 newPosition = new Vector3(-((_circuit.NbCol - 1) * localColWidth / 2) + localColWidth * (col + col_offset), 0, -localRowHeight * row + localRowHeight / 2 - gateHeightRatio * localRowHeight / 2); return(newPosition); }
/// <summary> /// Calcule et fait transiter les tuyaux d'une porte vers leurs nouvelles positions. /// </summary> /// <param name="gateStruct"></param> private void TransitionPipes(Circuit.GateStruct gateStruct) { GateObject gateObject = gateObjects[gateStruct]; int row = gateStruct.row; int col = gateStruct.col; for (int i = 0; i < gateObject.pipes.Count; i++) { Vector3 newPosition = ComputeGridPosition(row, col + i); AnimationManager.Move(gateObject.pipes[i], newPosition, animationTime); } }
/** * ###################################################################################################### * ############################################### PIPES ################################################ * ###################################################################################################### */ /// <summary> /// Calcule et positionne les tuyaux d'une porte à leurs nouvelles positions /// </summary> /// <param name="gateStruct"></param> private void PositionPipes(Circuit.GateStruct gateStruct) { GateObject gateObject = gateObjects[gateStruct]; int row = gateStruct.row; int col = gateStruct.col; for (int i = 0; i < gateObject.pipes.Count; i++) { Vector3 newPosition = ComputeGridPosition(row, col + i); gateObject.pipes[i].transform.localPosition = newPosition; } }
/// <summary> /// Calcule et fait transiter une porte vers sa nouvelle position. /// </summary> /// <param name="gateStruct"></param> private void TransitionGate(Circuit.GateStruct gateStruct) { GateObject gateObject = gateObjects[gateStruct]; GameObject gateGameObject = gateObject.body; if (gateGameObject == null) { return; } Vector3 newPosition = ComputeGatePosition(gateObject); AnimationManager.Move(gateGameObject, newPosition, animationTime); }
/// <summary> /// Calcule et positionne une porte vers sa nouvelle position. /// </summary> /// <param name="gateStruct"></param> private void PositionGate(Circuit.GateStruct gateStruct) { GateObject gateObject = gateObjects[gateStruct]; GameObject gateGameObject = gateObject.body; if (gateGameObject == null) { return; } Vector3 newPosition = ComputeGatePosition(gateObject); gateGameObject.transform.localPosition = newPosition; }
/// <summary> /// Construit un Objet unity représentant une porte identité. /// </summary> /// <param name="parent">Parent de l'objet qui doit être créé</param> public static GateObject IDENTITY_GATE(Transform parent) { GameObject pipe = PIPE(parent); GateObject gateObject = pipe.AddComponent <GateObject>(); gateObject.body = null; gateObject.pipes = new List <GameObject>() { pipe }; return(gateObject); }
private void MouseManager_LeftButtonUp(object sender, MouseEventArgs e) { dragGate = false; if (selectedGate != null && selectedGate.BodySelected) { selectedGate.Selected = true; } else { if (selectedGate != null) { selectedGate.Selected = false; } selectedGate = null; } }
private Image GetGateStatusImage(GateObject gate) { var image = Ratatoskr.Resource.Images.connect_off; if (gate != null) { switch (gate.ConnectStatus) { case ConnectState.Connected: image = Ratatoskr.Resource.Images.connect_on; break; case ConnectState.Disconnected: image = Ratatoskr.Resource.Images.connect_off; break; default: image = Ratatoskr.Resource.Images.connect_busy; break; } } return(image); }
/// <summary> /// Construit dynamiquement une porte de la scène unity. /// </summary> /// <param name="parent">Parent de l'objet qui doit être créé</param> public static GateObject DYNAMIC_GATE(QCS.Gate gate, Transform parent) { GameObject gateGameObject = GATE(gate, parent); /* bind gateObject */ GateObject gateObject = gateGameObject.AddComponent <GateObject>(); gateObject.body = gateGameObject; gateObject.pipes = new List <GameObject>(); /* gate pipes */ for (int i = 0; i < gate.NbEntries; i++) { GameObject pipe = PIPE(parent); gateObject.pipes.Add(pipe); } return(gateObject); }
public override void OnDragStart(Vector3 position) { GameObject gameObject = context.GetOnScreenObject(position); if (gameObject.tag == "gate") { GateObject gateObject = gameObject.GetComponent <GateObject>(); context.CurrentState = new DragGate(context, gateObject, context.CurrentState); } if (gameObject.tag == "pipe") { Vector3 gridBoardPosition = context.GetGridBoardPosition(position); Tuple <int, int> coordinates = context.gridBoard.GetGridCoordinates(gridBoardPosition); int row = coordinates.Item1; context.CurrentState = new ShowResult(context, row, context.CurrentState); } }
private void MouseManager_LeftButtonDown(object sender, MouseEventArgs e) { if (componentMenu.Selected && !componentMenu.Bounds.Contains(e.MouseState.Position)) { IGate gate = componentMenu.NewGate(); GateObject go; if (gate is Switch) { go = new SwitchObject(gate.Outputs.Length, e.MouseState.Position); } else { go = new GateObject(gate, GateTextureMap[gate.GetType().FullName], e.MouseState.Position); } go.Defcous(); Gates.Add(go); gateControl.AddClick(go); Console.WriteLine(gate); } }
public override void OnDragStart(Vector3 position) { GameObject gameObject = context.GetOnScreenObject(position); if (gameObject == null) { return; } if (gameObject.tag == "gate") { GateObject gateObject = gameObject.GetComponent <GateObject>(); context.CurrentState = new DragGate(context, gateObject, context.CurrentState); } if (gameObject.tag == "pipe") { /*GateObject gateObject = gameObject.GetComponent<GateObject>(); * int col = gateObject.gateStruct.col; * context.CurrentState = new DragCol(context, col, context.CurrentState);*/ } }
public void AddClick(GateObject gate) { gate.OnLeftClickDown = SelectGate; }
public DragGate(Editor context, GateObject selectedGate, EditorState previousState) : base(context) { _draggedGate = selectedGate; _previousState = previousState; _previousPosition = selectedGate.body.transform.localPosition; }
public MainWindow_Gate(GateObject gate) : this() { Gate = gate; }
public Tuple <int, int, Editor.ClickPosition> GetOnScreenGridPosition(Vector3 onScreenPosition) { GameObject gameObject = null; RaycastHit hitInfo; Ray ray = cam.ScreenPointToRay(onScreenPosition); if (Physics.Raycast(ray, out hitInfo)) { gameObject = hitInfo.collider.gameObject; } if (gameObject == null) { return(null); } if (gameObject.tag != "pipe" && gameObject.tag != "gate") { return(null); } GateObject gateObject = gameObject.GetComponent <GateObject>(); QCS.Circuit.GateStruct gateStruct = gateObject.gateStruct; int row = gateStruct.row; int col = gateStruct.col; int nb_entries = gateStruct.gate.NbEntries; Editor.ClickPosition position; Vector3 posOnCase = hitInfo.point - hitInfo.collider.transform.position; // if the gate has many entries we need to do some modulos .. if (nb_entries > 1) { posOnCase.x += (nb_entries / 2f) * GridBoard.realColumnWidth; col += (int)(posOnCase.x / GridBoard.realColumnWidth); posOnCase.x %= GridBoard.realColumnWidth; posOnCase.x -= GridBoard.realColumnWidth / 2; } if (posOnCase.y > 0) { if (posOnCase.x < 0) { position = Editor.ClickPosition.TopLeft; } else { position = Editor.ClickPosition.TopRight; } } else if (posOnCase.x < 0) { position = Editor.ClickPosition.BotLeft; } else { position = Editor.ClickPosition.BotRight; } return(Tuple.Create(row, col, position)); }
/// <summary> /// Crée le GameObject correspondant à une porte, l'ajoute au dictionnaire associant les entrées et leur object et met à jour sa position. /// </summary> /// <param name="gateStruct"></param> private void AddGate(Circuit.GateStruct gateStruct) { GateObject gateObject = CreateGateObject(gateStruct); gateObjects.Add(gateStruct, gateObject); }
public MoveGate(Editor context, GateObject selectedGate, EditorState previousState) : base(context) { _selectedGate = selectedGate; _previousState = previousState; }