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); } }
private void ProcessHit <T>(T damageHandler) where T : IDamageHandler { if (!playerStatus.getFreezePlayerControlStatus()) { RemovePlayerHealth(damageHandler.GetDamage()); playerSpritesManager.changeColor(0.25f); /* GameObject explosao_effect = Instantiate(damagedPrefab, transform.GetChild(3).position,Quaternion.identity); * explosao_effect.transform.parent = gameObject.transform; * Destroy(explosao_effect, 0.6f);*///mt feio, preferi deixar só que mude a cor if (playerHealthManager.GetPlayerHealth() <= 0 && !imortal) { explode(); } } }
public void UpdatePlayerlifeBarUI() { //Debug.LogWarning() float playerHealth = playerHealthManager.GetPlayerHealth(); float playerOriginalHealth = playerHealthManager.GetInicialAmountLife(); playerLifeBar.value = playerHealth; if (playerHealth < Constantes.AVERAGE_HEALTH * playerOriginalHealth) { playerLifeBarFill.color = Color.yellow; } if (playerHealth < Constantes.LOW_HEALTH * playerOriginalHealth) { playerLifeBarFill.color = Color.red; } if (playerHealth >= Constantes.AVERAGE_HEALTH * playerOriginalHealth) { playerLifeBarFill.color = Color.green; } }