void Update() { Vector3 newPosition = NewPosition(); Vector3 newPositionAfterX = NewPositionAfterX(); timeBetweenSteps = 1 / speed; if (newPositionAfterX != min) //if we did press X: { TileBase tileOnNewPosition = TileOnPosition(newPositionAfterX); if (tileOnNewPosition.Equals(mountains)) // pressed X at a mountain tile : { StartCoroutine(Example(newPositionAfterX)); } else if (tileOnNewPosition.Equals(grass)) //pressed X at a grass tile: { transform.position = newPositionAfterX; } } else { TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else { Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } } }
void Update() { Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else { // For quarrying mountains: if (tileOnNewPosition != null && tileOnNewPosition.name == "mountains") { if (Input.GetKey("x")) { Vector3Int newPositionV3 = tilemap.WorldToCell(newPosition); tilemap.SetTile(newPositionV3, tileOnQuarrying); } Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } if (tileOnNewPosition != null && tileOnNewPosition.name == tileOnQuarrying.name) { if (Input.GetKey("x")) { Vector3Int newPositionV3 = tilemap.WorldToCell(newPosition); tilemap.SetTile(newPositionV3, tileAfterQuarrying); transform.position = newPosition; } } // } }
void Update() { Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else { Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } if (Input.GetKeyDown(KeyCode.X)) { TileBase tileOnDirPosition = TileOnPosition(transform.position + saveStep); if (Time.time > curr + delay) //check if delay was completed. { curr = Time.time; flag = true; } else { flag = false; } if (AllowedCut.Contains(tileOnDirPosition) && flag) { Vector3 playerPos = transform.position + saveStep; tilemap.SetTile(tilemap.WorldToCell(playerPos), afterCut); } flag = false; //for the next frame, flag=false as default. } }
void Update() { Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else if (!allowedTiles.Contain(tileOnNewPosition) && tileOnNewPosition.Equals(oldTile) && Input.GetKey(KeyCode.A)) { tilemap.SetTile(tilemap.WorldToCell(newPosition), newTile); } else { Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } }
/** * check and change the tile **/ private void checkTile(Vector3 position) { TileBase tileOnNewPosition = TileOnPosition(position); if (!allowedTiles.Contain(tileOnNewPosition)) { tilemap.SetTile(tilemap.WorldToCell(position), changeTile); } }
void Update() { Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition) && !mine.PlayerMine) { //Checking if thr player mining transform.position = newPosition; } else { Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } }
void Update() { Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else { Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } }
void Update() { Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else if (!allowedTiles.Contain(tileOnNewPosition) && tileOnNewPosition.Equals(oldTile) && Input.GetKey(KeyCode.Space)) { tilemap.SetTile(tilemap.WorldToCell(newPosition), newTile); } else if (tileOnNewPosition.Equals(PlayerHome) && Input.GetKey(KeyCode.Space)) { Debug.Log("Home Sweet Home " + tileOnNewPosition + "!"); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } else { Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } }
// Checks for the Tile in the moving Direction and changing it to "ChangeToMiddle" Tile and then to "ChangeToFinal" . IEnumerator CheckTileAndCarve(Vector3 tile) { Vector3Int FutureMovePos = tileMap.WorldToCell(tile); yield return(new WaitForSeconds(CraveTime)); if (!allowedTiles.Contain(tileMap.GetTile(FutureMovePos))) { tileMap.SetTile(tileMap.WorldToCell(tile), ChangeToMiddle); MakeBoom(); yield return(new WaitForSeconds(CraveTime)); tileMap.SetTile(tileMap.WorldToCell(tile), ChangeToFinal); MakeBoom(); } }
void Update() { Vector3 newPositionX = NewPositionX(); TileBase tileOnNewXPosition = TileOnPosition(newPositionX); if (tileOnNewXPosition.name == "mountains") { StartCoroutine(Func(newPositionX)); } Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else { Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } }
void Update() { Vector3 newPosition = NewPosition(); TileBase tileOnNewPosition = TileOnPosition(newPosition); if (allowedTiles.Contain(tileOnNewPosition)) { transform.position = newPosition; } else //if the player hit a mountain, and also press both 'x' and arrow its break the tile into a grass and put the player on his position { if (twoButt && tileOnNewPosition.name.Equals("mountains")) { Vector3Int a = tilemap.WorldToCell(newPosition); tilemap.SetTile(a, allowedTiles.Get()[0]); twoButt = false; Thread.Sleep((int)(timeToDestoy * 1000)); transform.position = newPosition; } Debug.Log("You cannot walk on " + tileOnNewPosition + "!"); } }