void SelectAbility(Ability ability) { state = State.inGame; GameObject playerObject = null; foreach (PlayerObjectPrefabs playerPrefab in playerPrefabs) { if (playerPrefab.ability == ability) { playerObject = playerPrefab.player; } } player = Instantiate(playerObject, Vector3.zero, Quaternion.identity); player.GetComponent <Player>().ability = ability; player.GetComponent <Player>().PlayerDiedCallback += PlayerDied; CameraFollow.instance.target = player.transform; for (int i = 0; i < abilityPool.Count; i++) { if (abilityPool[i].ability == ability) { abilityPool[i] = new PlayerCounts { ability = ability, count = abilityPool[i].count - 1 }; } } choosePanel.SetActive(false); Cursor.visible = false; }
public void SetAbility(PlayerCounts ability) { image.sprite = ability.ability.sprite; counter.SetText(ability.count.ToString()); }