void UpdateTile(CheckPathResult result) { ResetTile(); foreach (Vector2 pos in result.neighbors) { GameObject tile = GetTileByPosition(pos); tile.GetComponent <Tile> ().SetEnable(true); } foreach (Vector2 pos in result.path) { GameObject tile = GetTileByPosition(pos); tile.GetComponent <Tile> ().SetUsed(true); } selfTile.GetComponent <Tile> ().SetShape(result.shape); trackingCubes = ModelToTrack(result.path); }
// Update is called once per frame void Update() { if (isTrack) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.RaycastAll(ray).Length > 0) { /* * if (AddToTrack (Physics.RaycastAll (ray) [0].transform.name)) { * resultPath = model.CheckPath (TrackToModel (trackingCubes)); * UpdateTile ( resultPath ); * } */ switch (AddToTrack(Physics.RaycastAll(ray) [0].transform.name)) { case "new": resultPath = model.CheckPath(TrackToModel(trackingCubes)); UpdateTile(resultPath); break; case "back": resultPath = model.CheckPath(TrackToModel(trackingCubes)); UpdateTile(resultPath); break; case "none": break; default: break; } } } }