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 void HealOperator(OperatorController _operatorController, OperatorData operatorData = null)
 {
     if (HealLoopCoroutine != null)
     {
         StopCoroutine(HealLoopCoroutine);
     }
     isAttackLoop      = true;
     HealLoopCoroutine = StartCoroutine(AnimationHealLoopOperator(_operatorController));
 }
        IEnumerator AnimationHealLoopOperator(OperatorController _operatorController = null)
        {
            isAttacking = true;
            while (isAttackLoop)
            {
                if (operatorObject._armature.animation.HasAnimation("Attack"))
                {
                    operatorObject._armature.animation.Play("Attack", 1);
                }
                else
                {
                    if (operatorObject._armature.animation.HasAnimation("Attack_Loop"))
                    {
                        operatorObject._armature.animation.Play("Attack_Loop", 1);
                    }
                    else
                    {
                        operatorObject._armature.animation.Play("Idle", 1);
                    }
                }
                yield return(new WaitForSeconds(_operatorData.ASPD));

                if (_operatorController != null)
                {
                    if (!_operatorController.Heal(_operatorData.Attack))
                    {
                        isAttackLoop = false;
                    }
                    if (wichOperatorHeal.healSelfParticle != null)
                    {
                        wichOperatorHeal.healSelfParticle.gameObject.SetActive(false);
                        wichOperatorHeal.healSelfParticle.gameObject.SetActive(true);
                    }
                }
                else
                {
                    isAttackLoop = false;
                }
            }
            isAttacking = false;

            if (!isAttackLoop)
            {
                operatorObject._armature.animation.Play("Idle", 0);
            }
            yield return(null);
        }
        private OperatorController ChooseOperatorWithLowerHP(List <OperatorController> enemyControllers)
        {
            operatorInRange.Clear();

            operatorInRange.Add(this);

            foreach (RangeTile operatorList in rangeTiles)
            {
                foreach (OperatorController oper in operatorList.operatorInTile)
                {
                    if (!operatorInRange.Contains(oper))
                    {
                        operatorInRange.Add(oper);
                    }
                }
            }
            if (operatorInRange.Count != 0)
            {
                OperatorController minHPOperator = null;
                float minHP = 0f;
                for (int i = 0; i < operatorInRange.Count; i++)
                {
                    if (operatorInRange[i]._operatorData.curHP < operatorInRange[i]._operatorData.maxHP)
                    {
                        if (minHP == 0f)
                        {
                            minHP         = operatorInRange[i]._operatorData.curHP;
                            minHPOperator = operatorInRange[i];
                        }
                        else
                        {
                            float curHP = operatorInRange[i]._operatorData.curHP;
                            if (curHP < minHP)
                            {
                                minHP         = curHP;
                                minHPOperator = operatorInRange[i];
                            }
                        }
                    }
                }
                return(minHPOperator);
            }

            return(null);
        }
Пример #5
0
 public void SkillActivate(OperatorController operatorController)
 {
     skill.SkillActivate(operatorController);
 }