private void InstantiateMovesDisplay(List <GridPosition> moves) { int count = 0; foreach (GridPosition pos in moves) { count++; GameObject go = null; UnitGroup unitGroup = unitData.getUnitAt(pos); if (unitGroup == null) { go = (GameObject)Instantiate(Resources.Load("Possible Move")); } else { if (unitGroup.isEnemy) { go = (GameObject)Instantiate(Resources.Load("Enemy Present")); } else { go = (GameObject)Instantiate(Resources.Load("Possible Move")); } } go.transform.SetParent(movesContainer.transform); go.transform.position = IsometricHelper.gridToGamePostion(pos); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(pos); go.name = "Move " + count; } }
public void instantiateUnitGroups() { UnitGroup playerGroup = battleData.playerGroup; UnitGroup enemyGroup = battleData.enemyGroup; foreach (UnitPosition up in playerGroup.unitList) { GridPosition unitPos = IsometricHelper.battleCoordToPostion(up.position, true); Debug.Log("Position " + unitPos.x + ", " + unitPos.y); GameObject go = (GameObject)Instantiate(Resources.Load("Monk")); go.transform.SetParent(GameObject.Find("Player Units").transform); go.transform.position = IsometricHelper.gridToGamePostion(unitPos); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(unitPos); go.name = up.unit.unitName; go.GetComponent <CombatUnitController>().facing = Facing.Back; } foreach (UnitPosition up in enemyGroup.unitList) { GridPosition unitPos = IsometricHelper.battleCoordToPostion(up.position, false); Debug.Log("Position " + (int)unitPos.x + ", " + (int)unitPos.y); GameObject go = (GameObject)Instantiate(Resources.Load("Monk")); go.transform.SetParent(GameObject.Find("Enemy Units").transform); go.transform.position = IsometricHelper.gridToGamePostion(unitPos); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(unitPos); go.name = up.unit.unitName; go.GetComponent <CombatUnitController>().facing = Facing.Forward; } }
public void createTileFromTileSave(TileSave ts) { GridPosition pos = new GridPosition(ts.position.x, ts.position.y, ts.position.elevation); GameObject go = (GameObject)Instantiate(Resources.Load("Tile")); go.name = "x" + pos.x + "y" + pos.y; go.transform.position = IsometricHelper.gridToGamePostion(pos); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(pos); go.transform.SetParent(GameObject.Find("Tiles").transform); }
private void ExportLevelMap() { int count = 0; foreach (MapTile mt in levelData.map) { count++; GameObject go = (GameObject)Instantiate(Resources.Load("Grass Tile")); go.transform.SetParent(GameObject.Find("Tiles").transform); go.transform.position = IsometricHelper.gridToGamePostion(mt.position); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(mt.position); go.name = "Tile " + count; } }
private void InstantiateTargetsDisplay(List <GridPosition> targets) { int count = 0; foreach (GridPosition pos in targets) { count++; GameObject go = (GameObject)Instantiate(Resources.Load("Possible Move")); go.transform.SetParent(targetsContainer.transform); go.transform.position = IsometricHelper.gridToGamePostion(pos); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(pos); go.name = "Target " + count; } }
// Update is called once per frame void Update() { int sortingOrder = IsometricHelper.getTileSortingOrder(position); GetComponent <SpriteRenderer>().sortingOrder = sortingOrder; shadow.GetComponent <SpriteRenderer>().sortingOrder = sortingOrder - 1; if (!placingUnits) { foreach (Transform spawn in transform) { if (spawn.gameObject.tag.Equals("Spawn Point")) { spawn.gameObject.SetActive(false); } } } }
public void UpdateLevelMap() { foreach (Transform child in GameObject.Find("Tiles").transform) { Destroy(child.gameObject); } int count = 0; foreach (MapTile mt in levelData.map) { count++; GameObject go = (GameObject)Instantiate(Resources.Load("Pixel Tile")); go.transform.SetParent(GameObject.Find("Tiles").transform); go.transform.position = IsometricHelper.gridToGamePostion(mt.position); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(mt.position); go.name = "Tile " + count; } }
private void InstantiateLevelMap() { int count = 0; foreach (MapTile mt in battleData.battleMapData.map) { count++; GameObject go = (GameObject)Instantiate(Resources.Load("Grass Tile")); if (mt.position.x < 4 && mt.position.y < 3) { go.transform.SetParent(GameObject.Find("Player Tiles").transform); } else { go.transform.SetParent(GameObject.Find("Enemy Tiles").transform); } go.transform.position = IsometricHelper.gridToGamePostion(mt.position); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(mt.position); go.name = "Tile " + count; } }
public void PopulateLevelFromFile() { if (!hasPopulated) { if (csvFile != null) { int y = 0; _lines = Regex.Split(csvFile.text, "\n"); foreach (string _line in _lines) { int x = 0; string[] _tiles = _line.Split(','); foreach (string _tile in _tiles) { if (_tile != null && !_tile.Equals("")) { GameObject go = InitGameObjectFromKey(_tile); if (go.tag.Equals("Enemy")) { go.transform.position = IsometricHelper.gridToGamePostionUnit(x, y); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(x, y); GameObject floor = Instantiate(baseTile); floor.transform.position = IsometricHelper.gridToGamePostionTile(x, y); floor.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(x, y); floor.transform.SetParent(tiles.transform); string name = floor.name.Replace("(Clone)", ""); floor.name = name; go.transform.SetParent(hazards.transform); } else { go.transform.SetParent(tiles.transform); go.transform.position = IsometricHelper.gridToGamePostionTile(x, y); go.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(x, y); } if (_tile.Contains("enter")) { GameObject _player = Instantiate(player); string name = _player.name.Replace("(Clone)", ""); _player.name = name; _player.transform.position = IsometricHelper.gridToGamePostionUnit(x, y); _player.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(x, y); } } else if (_tile.Equals("")) { GameObject floor = Instantiate(baseTile, IsometricHelper.gridToGamePostionTile(x, y), Quaternion.identity); floor.GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(x, y); floor.transform.SetParent(tiles.transform); string name = floor.name.Replace("(Clone)", ""); floor.name = name; } x++; } y++; } hasPopulated = true; } } }
protected virtual void doUpdateTasks() { GetComponent <SpriteRenderer>().sortingOrder = IsometricHelper.getTileSortingOrder(position); }