public void SetHealthSystem(healthSystem hs) { //this.healthSystem1 = hs; //a //i think this line no need (use for private) this.hs = hs; HealthSystem = hs; List <healthSystem.Heart> heartList = hs.GetHeartList(); int row = 0; int col = 0; int colMax = 10; float rowColSize = 30f; for (int i = 0; i < heartList.Count; i++) { healthSystem.Heart heart = heartList[i]; Vector2 hap = new Vector2(col * rowColSize, -row * rowColSize); //heartAnchoredPosition CreateHeartImage(hap).SetHeartFraments(heart.GetFragmentAmount()); col++; if (col >= colMax) { row++; col = 0; } } hs.OnDamaged += healthSystem_OnDamaged; hs.OnDead += healthSystem_OnDead; hs.OnHeal += healthSystem_OnHeal; }
private void RefreshAllHearts() ///// make the health can be decrease /// if delete this it will always be full health { List <healthSystem.Heart> heartList = HealthSystem.GetHeartList(); //a for (int i = 0; i < heartImageList.Count; i++) { HeartImage heartImage = heartImageList[i]; healthSystem.Heart heart = heartList[i]; heartImage.SetHeartFraments(heart.GetFragmentAmount()); } }