//-----------------------------------------------------------------------------------------------------------// /// <summary> /// We check if the neighbour tiles are allowed in this machine and if it does /// then we add that to the machineBlocks list and call this function for the neighbours /// </summary> /// <param name="_tile"></param> private void TileCheck(MachineBlock _tile) { if (_tile == null || _tile.type == TileType.Empty || machineBlocks.Contains(_tile)) { return; } if (allowedTypes.Contains(_tile.type) || _tile == this) { machineBlocks.Add(_tile); _tile.core = machineBlocks[0]; TileCheckNeighbours <MachineBlock>(_tile, TileCheck); } }
private bool HasCore(MachineBlock machineBlock) { if (machineBlock == null) { return(false); } MachineBlock _core = machineBlock.core; if (_core.allowedTypes.Contains(this.type)) { this.core = _core; _core.machineBlocks.Add(this); return(true); } return(false); }
private void CheckDirections() { if (allowedCores.Contains(Up().type) || Up().GetComponent <MachineBlock>() != null && !Up().GetComponent <MachineBlock>().isCoreless) { core = Up().GetComponent <MachineBlock>().core; isCoreless = false; } if (allowedCores.Contains(Left().type) || Left().GetComponent <MachineBlock>() != null && !Left().GetComponent <MachineBlock>().isCoreless) { core = Left().GetComponent <MachineBlock>().core; isCoreless = false; } if (allowedCores.Contains(Down().type) || Down().GetComponent <MachineBlock>() != null && !Down().GetComponent <MachineBlock>().isCoreless) { core = Down().GetComponent <MachineBlock>().core; isCoreless = false; } if (allowedCores.Contains(Right().type) || Right().GetComponent <MachineBlock>() != null && !Right().GetComponent <MachineBlock>().isCoreless) { core = Right().GetComponent <MachineBlock>().core; isCoreless = false; } }