public void Use(int charToUseOn) { CharStas selectedChar = GameManager.instance.playerstats[charToUseOn]; if (isItem) { if (affectHp) { selectedChar.currentHP += amountToChange; if (selectedChar.currentHP > selectedChar.maxHP) { selectedChar.currentHP = selectedChar.maxHP; } } if (affectMp) { selectedChar.currentMP += amountToChange; if (selectedChar.currentMP > selectedChar.maxMP) { selectedChar.currentMP = selectedChar.maxMP; } } if (affectStr) { selectedChar.strength += amountToChange; } } if (isWeapon) { if (selectedChar.equippedWpn != "") { GameManager.instance.AddItem(selectedChar.equippedWpn); } selectedChar.equippedWpn = itemName; selectedChar.wpnPwr = weaponStrength; } if (isArmor) { if (selectedChar.equippedArmr != "") { GameManager.instance.AddItem(selectedChar.equippedArmr); } selectedChar.equippedArmr = itemName; selectedChar.armrPwr = armorStrength; } GameManager.instance.RemoveItem(itemName); }
public void BattleStart(string[] enemiesToSpawn, bool setcannotFlee) { if (!battleActive) { cannotFlee = setcannotFlee; battleActive = true; GameManager.instance.battleActive = true; transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, transform.position.z); battleScene.SetActive(true); AudioManager.instance.PlayBGM(0); for (int i = 0; i < playerPosition.Length; i++) { if (GameManager.instance.playerstats[i].gameObject.activeInHierarchy) { for (int j = 0; j < playerPrefab.Length; j++) { if (playerPrefab[j].charName == GameManager.instance.playerstats[i].charName) { BattleChar newPlayer = Instantiate(playerPrefab[j], playerPosition[i].position, playerPosition[i].rotation); newPlayer.transform.parent = playerPosition[i]; activeBattler.Add(newPlayer); CharStas thePlayer = GameManager.instance.playerstats[i]; activeBattler[i].currentHP = thePlayer.currentHP; activeBattler[i].MaxHP = thePlayer.maxHP; activeBattler[i].currentMP = thePlayer.currentMP; activeBattler[i].maxMP = thePlayer.maxMP; activeBattler[i].strength = thePlayer.strength; activeBattler[i].defence = thePlayer.defence; activeBattler[i].wpnPower = thePlayer.wpnPwr; activeBattler[i].armrPower = thePlayer.armrPwr; } } } } for (int i = 0; i < enemiesToSpawn.Length; i++) { if (enemiesToSpawn[i] != "") { for (int j = 0; j < enemyPrefab.Length; j++) { if (enemyPrefab[j].charName == enemiesToSpawn[i]) { BattleChar newEnemy = Instantiate(enemyPrefab[j], enemyPosition[i].position, enemyPosition[i].rotation); newEnemy.transform.parent = enemyPosition[i]; activeBattler.Add(newEnemy); Debug.Log("done"); } } } } turnWaiting = true; currentTurn = Random.Range(0, activeBattler.Count); UpdateUIStats(); } }