public void PlaceTilesInWorldSpace(Vector3Int position, Grid grid, Tilemap tileMap) { if (hasTile) { if (tile != null) { if (CanBePlaced(tile, position)) { gameManager.ProceedToNextGamePhase(); currentTileMap.SetTile(position, tile); deckManager.RefreshHand(currentHandChoice.GetComponent <HandTile>().myIndex); Vector3 nextPos = grid.GetCellCenterWorld(position); nextPos.x += 0.0f; nextPos.y += 0.5f; nextPos.z = 0; boardManager.aStarGrid.SetVariables(nextPos); boardManager.Pathfinding(playerIcon.transform.position, nextPos); List <Vector3> path = new List <Vector3>(); foreach (Node n in boardManager.aStarGrid.path) { path.Add(n.worldPosition); } StartCoroutine(playerIcon.GetComponent <PartyBehaviour>().MoveParty(path.ToArray())); if (tile.GetType() == typeof(VariantTiles)) { VariantTiles vTile = tile as VariantTiles; if (vTile.variantType == VariantTiles.VariantType.Enemy) { nextPos.y -= 0.25f; Instantiate(gameManager.enemyPartyTemplate, nextPos, Quaternion.identity); Instantiate(gameManager.combatPositions, nextPos, Quaternion.identity); } else if (vTile.variantType == VariantTiles.VariantType.Boss) { nextPos.y -= 0.25f; Instantiate(gameManager.enemyPartyTemplate, nextPos, Quaternion.identity); Instantiate(gameManager.combatPositions, nextPos, Quaternion.identity); } } } } hasTile = false; tile = null; previewSprite.sprite = null; } }
public IEnumerator MoveParty(Vector3[] path) { if (path == null) { Vector3Int intPos = grid.WorldToCell(this.transform.position); currentTile = tilemap.GetTile(intPos); if (currentTile.GetType() == typeof(VariantTiles)) { VariantTiles tile = currentTile as VariantTiles; Debug.Log("Event Tile"); gameManager.ProceedToNextGamePhase(); if (gameManager.currentGamePhase == GameManager.GamePhase.Event) { if (currentTile.GetType() == typeof(VariantTiles)) { VariantTiles currentEventTile = currentTile as VariantTiles; switch (currentEventTile.variantType) { case VariantTiles.VariantType.Town: shopManager.promptPanel.SetActive(true); break; case VariantTiles.VariantType.Enemy: gameManager.ProceedToNextGamePhase(true); break; } } } } else { gameManager.ProceedToNextGamePhase(); gameManager.ProceedToNextGamePhase(); } } else { heroParty[0].GetComponent <Animator>().SetBool("isWalking", true); for (int i = 0; i < path.Length; i++) { while (this.transform.position != path[i]) { float step = boardMovementSpeed * Time.deltaTime; this.transform.position = Vector3.MoveTowards(this.transform.position, path[i], step); yield return(new WaitForSeconds(step / 2)); } yield return(new WaitForSeconds(Time.deltaTime)); } heroParty[0].GetComponent <Animator>().SetBool("isWalking", false); this.transform.position = path[path.Length - 1]; Vector3Int intPos = grid.WorldToCell(this.transform.position); currentTile = tilemap.GetTile(intPos); foreach (HeroClass hero in heroParty) { hero.XP += 1; if (hero.CanLevelUp()) { hero.LevelUp(hero.Level + 1); } } if (currentTile.GetType() == typeof(VariantTiles)) { VariantTiles tile = currentTile as VariantTiles; Debug.Log("Event Tile"); gameManager.ProceedToNextGamePhase(); if (gameManager.currentGamePhase == GameManager.GamePhase.Event) { if (currentTile.GetType() == typeof(VariantTiles)) { VariantTiles currentEventTile = currentTile as VariantTiles; switch (currentEventTile.variantType) { case VariantTiles.VariantType.Town: foreach (HeroClass hero in heroParty) { hero.currentHealth = hero.Health; } shopManager.promptPanel.SetActive(true); break; case VariantTiles.VariantType.Enemy: case VariantTiles.VariantType.Boss: gameManager.ProceedToNextGamePhase(true); break; } } } } else { gameManager.ProceedToNextGamePhase(); gameManager.ProceedToNextGamePhase(); } } }
public void GenerateEnemyParty(int partyLevel) { if (partyBehaviour.currentTile.GetType() == typeof(VariantTiles)) { VariantTiles variantTile = partyBehaviour.currentTile as VariantTiles; if (variantTile.variantType == VariantTiles.VariantType.Boss) { GameObject bossObj = gameManager.AllBosses[Random.Range(0, gameManager.AllBosses.Count)]; enemyParty.Add(bossObj); return; } } int combatDifficulty = GenerateDifficulty(); double enemyGenerationPoints = partyBehaviour.heroParty.Count + combatDifficulty; GameObject startingEnemy = null; int currentTier = new int(); switch (partyLevel) { case 1: case 2: currentTier = 1; startingEnemy = GetEnemy(currentTier); break; case 3: case 4: currentTier = 2; startingEnemy = GetEnemy(currentTier); break; case 5: case 6: case 7: case 8: case 9: case 10: currentTier = 3; startingEnemy = GetEnemy(currentTier); break; default: currentTier = 3; startingEnemy = GetEnemy(currentTier); Debug.LogError("Party's Average Level is above level max."); break; } enemyParty.Add(startingEnemy); enemyGenerationPoints -= startingEnemy.GetComponent <Enemy>().CombatSize; //Skip while loop if possible if (enemyGenerationPoints > 0 && enemyParty.Count < gameManager.enemyPartySizeLimit) { while (enemyGenerationPoints > 0 && enemyParty.Count < gameManager.enemyPartySizeLimit) { int randInt = Random.Range(0, 100); GameObject nextEnemy = null; switch (currentTier) { case 1: currentTier = 1; nextEnemy = GetEnemy(1); if (nextEnemy.GetComponent <Enemy>().CombatSize >= enemyGenerationPoints) { enemyGenerationPoints -= nextEnemy.GetComponent <Enemy>().CombatSize; } else { GetEnemy(1); } break; case 2: nextEnemy = GetEnemy(2); enemyGenerationPoints -= nextEnemy.GetComponent <Enemy>().CombatSize; if (enemyGenerationPoints >= 2) { currentTier = 2; } else if (enemyGenerationPoints <= 1 && enemyGenerationPoints > 0) { currentTier = 1; } break; case 3: nextEnemy = GetEnemy(3); enemyGenerationPoints -= nextEnemy.GetComponent <Enemy>().CombatSize; if (enemyGenerationPoints >= 3) { currentTier = 3; } else if (enemyGenerationPoints == 2) { currentTier = 2; } else if (enemyGenerationPoints <= 1 && enemyGenerationPoints > 0) { currentTier = 1; } break; } enemyParty.Add(nextEnemy); if (enemyParty.Count == gameManager.enemyPartySizeLimit) { if (enemyGenerationPoints > 0) { LevelUpEnemyParty((int)enemyGenerationPoints, partyLevel); return; } else { LevelUpEnemyParty(0, partyLevel); return; } } } } else if (enemyGenerationPoints == 0) { LevelUpEnemyParty(0, partyLevel); return; } }