private void HealhBarManagment() { if (EnemyHPMax < 1000) { if (enemyHP == EnemyHPMax) { LifeBar.GetComponent <RectTransform>().sizeDelta = new Vector2(30, 2.5f); } else { LifeBar.GetComponent <RectTransform>().sizeDelta = new Vector2(((enemyHP * 100 / EnemyHPMax) / 100) * 30, 2.5f); } } else { if (enemyHP == EnemyHPMax) { LifeBar.GetComponent <RectTransform>().sizeDelta = new Vector2(60, 3.5f); } else { LifeBar.GetComponent <RectTransform>().sizeDelta = new Vector2(((enemyHP * 100 / EnemyHPMax) / 100) * 60, 3.5f); } } LifeBar.transform.position = cameraMain.GetComponent <Camera>().WorldToScreenPoint(transform.position) + new Vector3(0, -10, 0); if (enemyHP <= 0) { GameManager.argent++; Destroy(LifeBar); Outils.Destroyed(gameObject, DyingParticule, 0f); return; } }
// Update is called once per frame private void Update() { if (target == null) { if (SiPasTouche == null) { Destroy(gameObject); return; } else { Outils.Destroyed(gameObject, SiPasTouche, tempApparition); return; } } Vector3 dir = target.position - transform.position; float distanceThisFrame = speed * Time.deltaTime; if (dir.magnitude <= distanceThisFrame) { HitTarget(); return; } transform.Translate(dir.normalized * distanceThisFrame, Space.World); }
protected void HealhBarManagment() { LifeBar.transform.position = Camera.main.WorldToScreenPoint(transform.position) + new Vector3(0, -10, 0); if (EnemyHP <= 0) { GameManager.Money += earningsOnDestroy; Destroy(LifeBar); Outils.Destroyed(gameObject, DyingParticule, 1f); // Destroyer.Destroy(gameObject); } }
private void HitTarget() { if (!degatfait) { target.GetComponent <Enemy>().enemyHP -= degat; Outils.Destroyed(gameObject, impactEffect, tempApparition); degatfait = true; //effectIns = Instantiate(impactEffect, transform.position, transform.rotation); //Destroy(effectIns, delaiApparition); //Destroy(gameObject, delaiApparition); } }