public void spawnLevel(int x, int y) { VRAR_Level currentLevel = GameStateManager.getInstance().getCurrentLevel(); List <VRAR_Tile> list; if (this.localPlayer == null) { MonoBehaviour.print("localPlayer null! ,spawning around 0,0 s5"); //list = currentLevel.selectRadius(0, 0, 3); list = currentLevel.selectRadius(x, y, 3); } else { list = currentLevel.selectRadius(x, y, this.localPlayer.GetSight()); //list = currentLevel.selectRadius(this.localPlayer.GetCurrentVec().x, this.localPlayer.GetCurrentVec().y, this.localPlayer.GetSight()); } foreach (VRAR_Tile tile in list) { this.updateTile(tile); //StartCoroutine(DropIn(tile, 2f, null)); } }
void Update() { if (brushTicking) { if (brushTickDivider-- == 0) { brushTickDivider = 4; //VRAR_Level lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(ingameCursor.position)); VRAR_Level lvl = TileRenderer.getCurrLVL(); VRAR_Tile tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y); if (tile != null) { List <VRAR_Tile> effectedTiles = lvl.selectRadius(tile.tileIndex_X, tile.tileIndex_Y, brushSize); //resetPrevous.Clear(); // resetPrevous.Add(lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y)); foreach (VRAR_Tile surroundTile in effectedTiles) { if (surroundTile != null) { switch (brushActionDropdown.value) { case 0: if (surroundTile.height_ < maxTileHeight) { surroundTile.setHeight(surroundTile.height_ + 0.05f); //Debug.Log(surroundTile); } //else { surroundTile.setHeight(minTileHeight); } break; case 1: if (surroundTile.height_ > minTileHeight) { surroundTile.setHeight(surroundTile.height_ - 0.05f); } //else { surroundTile.setHeight(maxTileHeight); } break; case 2: if (surroundTile.hexObject != null) { surroundTile.hexObject.gameObject.GetComponent <Renderer>().material = tileRenderer.defaultTileMaterial; } break; case 3: if (surroundTile.hexObject != null) { surroundTile.hexObject.gameObject.GetComponent <Renderer>().material = tileRenderer.waterTileMaterial; } break; case 4: if (surroundTile.hexObject != null) { surroundTile.hexObject.gameObject.GetComponent <Renderer>().material = tileRenderer.selectedTileMaterial; } break; } } else { Debug.Log("sur was null"); } } } } } }
public void EditTile(int num) { VRAR_Level lvl = GameStateManager.instance.getCurrentLevel(); VRAR_Tile tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y); currentBrush = num; if (brushTickDivider-- == 0) // || true) { brushTickDivider = 4; //VRAR_Level lvl = GameStateManager.instance.getCurrentLevel();//TileRenderer.getCurrLVL(); //VRAR_Tile tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y); if (tile != null) { //currentlySelected = tile; List <VRAR_Tile> effectedTiles = lvl.selectRadius(tile.tileIndex_X, tile.tileIndex_Y, brushSize); //resetPrevous.Clear(); // resetPrevous.Add(lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position).x, lvlManager.getTilePosFromWorldPos(leftHandCursor.position).y)); foreach (VRAR_Tile surroundTile in effectedTiles) { if (surroundTile.hexObject != null)//phantom tiles shouldn't be changed { switch (num) { case 0: if (surroundTile.height_ < maxTileHeight) { surroundTile.setHeight(surroundTile.height_ + 0.1f); TileRenderer.instance.updateTile(surroundTile); //todo only do this after the user stopped changing the height (for optimization) } //else { surroundTile.setHeight(minTileHeight); } break; case 1: if (surroundTile.height_ > minTileHeight) { surroundTile.setHeight(surroundTile.height_ - 0.1f); TileRenderer.instance.updateTile(surroundTile); //todo only do this after the user stopped changing the height (for optimization) } //else { surroundTile.setHeight(maxTileHeight); } break; case 3: { //remove tile VRAR_Tile remTile = lvl.removeTile(surroundTile.tileIndex_X, surroundTile.tileIndex_Y); var tileMessage = new TileMessage(remTile, true); NetworkServer.SendToAll(CustomNetMsg.Tile, tileMessage); TileRenderer.instance.updateTile(surroundTile); } break; case 4: if (surroundTile.hexObject != null) { //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.defaultTileMaterial; surroundTile.SetTerrain("Mountain"); TileRenderer.instance.updateTile(surroundTile); } break; case 5: if (surroundTile.hexObject != null) { //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.waterTileMaterial; surroundTile.SetTerrain("Water"); TileRenderer.instance.updateTile(surroundTile); } break; case 6: if (surroundTile.hexObject != null) { //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.selectedTileMaterial; surroundTile.SetTerrain("Grass"); TileRenderer.instance.updateTile(surroundTile); } break; } } else {//functions that run on both existing and phantom tiles but when the cursor is still on a existing tile! switch (num) { case 2: //if tile is phantom tile, create actual if (surroundTile.isPhantom) { TileRenderer.instance.updateTile(lvl.addNewTile(surroundTile.tileIndex_X, surroundTile.tileIndex_Y)); } break; } } } //lastSelectedTile = tile; } else {//cursor is not actually on a tile switch (num) { case 2: //spawn middle tile first (and the rest gets spawned in the next tick), and select amount around it TileRenderer.instance.updateTile(lvl.addNewTile(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y)); break; case 3: { VRAR_Tile middleTempTile = (lvl.addNewTile(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y)); List <VRAR_Tile> deletingTiles = lvl.selectRadius(middleTempTile.tileIndex_X, middleTempTile.tileIndex_Y, brushSize); foreach (VRAR_Tile surroundTile in deletingTiles) { TileRenderer.instance.updateTile(lvl.removeTile(surroundTile.tileIndex_X, surroundTile.tileIndex_Y)); } } break; } } } }
void Update() { //Debug.Log(brushTicking); if (brushTicking && GameStateManager.instance.getGlobalStateIndex() == GameStateManager.STATE_LEVEL_EDITOR) { if (brushTickDivider-- == 0) { brushTickDivider = 4; //VRAR_Level lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position)); VRAR_Level lvl = TileRenderer.getCurrLVL(); VRAR_Tile tile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y); if (tile != null) { currentlySelected = tile; List <VRAR_Tile> effectedTiles = lvl.selectRadius(tile.tileIndex_X, tile.tileIndex_Y, brushSize); if (!menuOpen) { OpenTileProperties(tile); menuOpen = true; } //resetPrevous.Clear(); // resetPrevous.Add(lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position).x, lvlManager.getTilePosFromWorldPos(leftHandCursor.position).y)); foreach (VRAR_Tile surroundTile in effectedTiles) { if (surroundTile != null) { switch (brushActionDropdown.value) { case 0: if (surroundTile.height_ < maxTileHeight) { surroundTile.setHeight(surroundTile.height_ + 0.05f); //Debug.Log(surroundTile); } //else { surroundTile.setHeight(minTileHeight); } break; case 1: if (surroundTile.height_ > minTileHeight) { surroundTile.setHeight(surroundTile.height_ - 0.05f); } //else { surroundTile.setHeight(maxTileHeight); } break; case 2: if (surroundTile.hexObject != null) { //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.defaultTileMaterial; surroundTile.SetTerrain("Mountain"); TileRenderer.instance.updateTile(surroundTile); } break; case 3: if (surroundTile.hexObject != null) { //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.waterTileMaterial; surroundTile.SetTerrain("Water"); TileRenderer.instance.updateTile(surroundTile); } break; case 4: if (surroundTile.hexObject != null) { //surroundTile.hexObject.gameObject.GetComponent<Renderer>().material = tileRenderer.selectedTileMaterial; surroundTile.SetTerrain("Grass"); TileRenderer.instance.updateTile(surroundTile); } break; } } else { Debug.Log("sur was null"); } } } } } }