private void SelectMachine() { Vector2 position = RoundVector(MouseWorldPosition()); Machine machine = Machines.At(position); if (machine.wasPlaced) { UI.Select.Select(machine); } }
public bool CanRotate(Vector3 spin) { // List<Vector2> toCheck = Rotator.GetSquaresToCheck(this.xy, spin); // foreach (Vector2 p in toCheck) { // // Debug.Log(p); // } // ------testing: // spin = new Vector3 (10, 10, 1); // Vector2 pos = new Vector3 (10, 20); // Debug.Log("GROUP:::::::"); // foreach (Crate crate in this.group.crates) { // Debug.Log(crate.xy); // } List <Vector2> toCheck = Rotator.GetSquaresToCheck(this.xy, spin); if (dot) { foreach (Vector2 v in toCheck) { GameObject dotGO = Instantiate(dotPrefab); dotGO.transform.position = v; } } // Debug.LogFormat("Crate: Can Rotate {0}", this.xy); foreach (Vector2 target in toCheck) { // Debug.LogFormat("Checking {0}",target); Machine targetMachine = Machines.At(target); bool blockedByObstacle = targetMachine && targetMachine.isObstacle; if (blockedByObstacle) { Debug.Log("blockedByObstacle"); return(false); } bool blockedByPusherArm = CheckPusherArms(target); if (blockedByPusherArm) { Debug.Log("blockedByPusherArm"); return(false); } Crate targetCrate = Crates.At(target); if (targetCrate) { if (targetCrate && !group.crates.Contains(targetCrate)) { Debug.Log("blockedByOtherCrateGroup"); return(false); } } } return(true); }
private void Connect() { foreach (Vector2 cardinal in cardinalDirections) { bool offGrid = !Machines.InBounds(xy + cardinal); if (offGrid) { continue; } Machine machine = Machines.At(xy + cardinal); if (machine is Wire) { Wire other = (Wire)machine; group.Merge(other.group); } } }
public bool CanMove(Vector2 direction) { if (hasMoved) { return(false); } Vector2 target = xy + direction; bool offGrid = !Crates.InBounds(target); if (offGrid) { return(true); } Machine targetMachine = Machines.At(target); bool blockedByObstacle = targetMachine && targetMachine.isObstacle; if (blockedByObstacle) { return(false); } bool blockedByPusherArm = CheckPusherArms(target); if (blockedByPusherArm) { return(false); } Crate targetCrate = Crates.At(target); if (!targetCrate) { return(true); } if (group.crates.Contains(targetCrate)) { return(true); } return(targetCrate.group.CanMove(direction)); }
public List <Sensor> GetSensors() { List <Sensor> sensors = new List <Sensor>(); foreach (Vector2 cardinal in cardinalDirections) { if (cardinal == direction) { continue; } if (!Machines.InBounds(xy + cardinal)) { continue; } Machine machine = Machines.At(xy + cardinal); if (machine && machine is Wire) { Wire wire = (Wire)machine; sensors.AddRange(wire.group.Sensors()); } } return(sensors); }