public void Damage(float hp) { currHp = Mathf.Clamp(currHp - hp, 0, maxHp); // RootContext.Instance.Player.HpMax = maxHp; // RootContext.Instance.Player.HpPct = currHp / (float)maxHp; //if (hp > 0) // GameObjectPoolManager.Spawn<BloodEffect>(transform.position, Quaternion.identity); var guiLbl = GuiPoolManager.Spawn <GuiLbl>(transform.position + Vector3.up * (50 + Random.Range(0, 50)), Quaternion.identity).GetComponent <GuiLbl>(); guiLbl.Init(Color.white, ((int)hp).ToString()); if (currHp == 0) { TargetManager.DestroyUnit(this); //световой эффект for (int i = 0; i < 5; i++) { var point = IgoPoolManager.Spawn <LightPointEffect>(transform.position, Quaternion.identity) .GetComponent <LightPointEffect>(); point.Init(5, Random.Range(0.2f, 0.7f), Random.Range(-0.4f, -0.1f), new Vector2(Random.Range(-2f, 2), Random.Range(5f, 2))); } //GameObjectPoolManager.Spawn<BloodDeadEffect>(transform.position, Quaternion.identity); var dead = GameObject.Instantiate(DeadObj, transform.position, Quaternion.identity); var parent = GameObject.Find("Units"); dead.transform.parent = parent.transform; } }