public PATile[] GetOtherTiles(PATileTerrain tileTerrain) { if (keyTile == null) { return(null); } PATile[] otherTiles = new PATile[3]; otherTiles[0] = tileTerrain.GetTile(keyTile.x, keyTile.y + 1); otherTiles[1] = tileTerrain.GetTile(keyTile.x + 1, keyTile.y + 1); otherTiles[2] = tileTerrain.GetTile(keyTile.x + 1, keyTile.y); return(otherTiles); }
public static PABuildingTile GetByTile(PATileTerrain tileTerrain, PATile tile) { PABuildingTile buildingTile = new PABuildingTile(); int x = tile.x / 2; int y = tile.y / 2; buildingTile.keyTile = tileTerrain.GetTile(x * 2, y * 2); return(buildingTile); }
bool CheckCrystalDistance(PATileTerrain.PATile newTile, Shuijing shuijing) { float minDistance = GetMinDistanceOfCrystal(); foreach (var crystal in tileTerrain.settings.crystals) { if (crystal.shuijing.elementType == shuijing.elementType) { continue; } PATileTerrain.PATile tile = tileTerrain.GetTile(crystal.id); float distance = tile.Distance(newTile); if (distance < minDistance) { return(false); } } return(true); }
public override TaskStatus OnUpdate() { GameObject terrainGo = GameObject.FindGameObjectWithTag("SurfaceTerrain"); PATileTerrain tileTerrain = terrainGo.GetComponent <PATileTerrain>(); Vector3 pos = tileTerrain.transform.InverseTransformPoint(storeHitPoint.Value); int x = (int)Mathf.Abs(pos.x / tileTerrain.tileSize); int y = (int)Mathf.Abs(pos.z / tileTerrain.tileSize); PATileTerrain.PATile tile = tileTerrain.GetTile(x, y); var currentGameObject = GetDefaultGameObject(targetGameObject.Value); if (currentGameObject != prevGameObject) { prevGameObject = currentGameObject; } animals = currentGameObject.GetComponent <Animals>(); if (animals == null) { return(TaskStatus.Failure); } if (animals.elementType == Animals.ElementType.Fire) { if (tile.element.IsFire()) { return(TaskStatus.Success); } else { return(TaskStatus.Failure); } } else if (animals.elementType == Animals.ElementType.Wood) { if (tile.element.IsWood()) { return(TaskStatus.Success); } else { return(TaskStatus.Failure); } } return(TaskStatus.Success); }
PATileTerrain.PATile GetTileByPoint(PATileTerrain tileTerrain, Transform vPointTrans) { RaycastHit hit; Ray ray = new Ray(new Vector3(vPointTrans.position.x, vPointTrans.position.y + 100, vPointTrans.position.z), Vector3.down); Physics.Raycast(ray, out hit, Mathf.Infinity, TerrainManager.instance.terrainChunkLayermask); //PATileTerrain tt = tileTerrain.IsTerrain(hit.transform); //if (tt == null) // return null; if (hit.transform == null) { return(null); } Vector3 pos = tileTerrain.transform.InverseTransformPoint(hit.point); int x = (int)Mathf.Abs(pos.x / tileTerrain.tileSize); int y = (int)Mathf.Abs(pos.z / tileTerrain.tileSize); PATileTerrain.PATile tile = tileTerrain.GetTile(x, y); return(tile); }