private IEnumerator EnemySearch() { while (!isDead) { if (tilePosition != null) { if (_operatorData.isHealAttack) { wichOperatorHeal = ChooseOperatorWithLowerHP(operatorInRange); } else { wichEnemyAttack = ChooseClosesEnemy(enemyInRange); } int curHP = operatorHpComponent.GetHPValue(); if (_operatorData.curHP != curHP && _operatorData.curHP > 0) { float newPosition = Mathf.SmoothDamp(curHP, (int)_operatorData.curHP, ref velocityHP, 0.03f); SetHP((int)newPosition); } } yield return(new WaitForSeconds(0.03f)); } yield return(null); }
private IEnumerator HealthChange() { while (!isDead) { if (HPdamage > 0 && HP > 0) { int curHP = uiOperatorHp.GetHPValue(); float newPosition = Mathf.SmoothDamp(curHP, HP, ref velocityHP, 0.3f); uiOperatorHp.SetHP((int)newPosition); HPdamage -= (curHP - newPosition); } yield return(new WaitForSeconds(0.03f)); } yield return(null); }