private void SpritesManager() { try{ if (playerHealthManager.GetPlayerHealth() < Constantes.AVERAGE_HEALTH * playerHealthManager.GetInicialAmountLife() && playerHealthManager.GetPlayerHealth() >= Constantes.LOW_HEALTH * playerHealthManager.GetInicialAmountLife()) { if (smoke != null) { Destroy(smoke); } } if (playerHealthManager.GetPlayerHealth() < Constantes.LOW_HEALTH * playerHealthManager.GetInicialAmountLife()) { if (smoke == null) //se nao existir uma instancia (evitar criar varios clones) { smoke = Instantiate(damagedPrefab, smokeChild.position, Quaternion.identity); /* Instantiate(damagedPrefab, new Vector3( transform.GetChild(3).position.x, * transform.GetChild(3).position.y,explosionZpositon),Quaternion.identity);*/ smoke.transform.parent = gameObject.transform; } } if (playerHealthManager.GetPlayerHealth() >= Constantes.AVERAGE_HEALTH * playerHealthManager.GetInicialAmountLife()) { if (smoke != null) { Destroy(smoke); } } } catch (System.Exception e) { Debug.LogWarning(e); } }
/*reduzira a vida do player a uma portengaem */ public void ReducePlayerHealth(float reductionPercentage) { if (!playerStatus.getFreezePlayerControlStatus() && !imortal) { Debug.LogWarning("reduziu minha life por " + playerHealthManager.GetInicialAmountLife() * reductionPercentage); playerHealthManager.RemoveHealth(playerHealthManager.GetInicialAmountLife() * reductionPercentage); } }
//PLAYER UI: public void SetPlayerlifeBarUI() { /* NAO tire a chamada de referencias daqui, pois outras * classes referenciam essa classe, as vezes, antes do Awake daqui ser chamado... * (estranho, sei, mas testei com os debugs, apenas deixe ;) )*/ checkReferences(); playerLifeBar.maxValue = playerHealthManager.GetInicialAmountLife(); playerLifeBar.minValue = 0; playerLifeBarFill = playerLifeBar.transform.GetChild(1).transform.GetChild(0).GetComponent <Image>(); }