public void SetHealthSystem(healthSystemB hs) { //this.healthSystem1 = hs; //a //i think this line no need (use for private) this.hs = hs; HealthSystem = hs; List <healthSystemB.HeartB> heartList = hs.GetHeartList(); int row = 0; int col = 0; int colMax = 10; float rowColSize = 30f; for (int i = 0; i < heartList.Count; i++) { healthSystemB.HeartB 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 <healthSystemB.HeartB> heartList = HealthSystem.GetHeartList(); //a for (int i = 0; i < heartImageList.Count; i++) { HeartImage heartImage = heartImageList[i]; healthSystemB.HeartB heart = heartList[i]; heartImage.SetHeartFraments(heart.GetFragmentAmount()); } }