コード例 #1
0
ファイル: Snake.cs プロジェクト: tdm1223/WildLife
    IEnumerator DamageOverTime(SurvivorStatus target, float timer) //지속데미지 입히는 함수
    {
        SurvivorStatus DOTTarget = target;

        DOTTarget.addtoHP((int)(-attackDamage), transform.position, gameObject.tag);                                                             //처음 맞을때 생명력 감소
        while (!target.transform.GetComponent <SurvivorStatus>().IsDead() && target.transform.GetComponent <SurvivorStatus>().Infection == true) // 죽지않고 감염되있을때
        {
            //타이머당 지속피해
            yield return(new WaitForSeconds(timer));

            if (target.transform.GetComponent <SurvivorStatus>().Infection == true)
            {
                DOTTarget.addtoHP((int)(-attackDamage * 0.2), gameObject.tag);
            }
            else if (target.transform.GetComponent <SurvivorStatus>().Infection == false)
            {
                yield break;
            }
        }
    }
コード例 #2
0
ファイル: Snake.cs プロジェクト: tdm1223/WildLife
    IEnumerator Attack()
    {
        if (Audio != null)
        {
            Audio.Play("Attack");
        }

        while (state == State.Attack)
        {
            //업데이트 할때
            if (Target.transform.root.GetComponent <SurvivorStatus>().IsDead())
            {
                state = State.Idle;
            }
            //공격범위 벗어나면 다시 추격
            if (!AttackRange.IsAttack)
            {
                animator.SetBool("Attack", false);
                state = State.Guard;
            }

            SurvivorStatus DOTTarget = Target.GetComponent <SurvivorStatus>();
            if (Target.transform.GetComponent <SurvivorStatus>().Infection == false)
            {
                GameController.GetInstance().ActionMessage("Wrong", "뱀에게 물렸습니다.", Target);
                Target.transform.GetComponent <SurvivorStatus>().Infection      = true;            // 감염상태 True로
                Target.transform.GetComponent <SurvivorStatus>().InfectionColor = getSnakeColor(); //감염된 뱀의 색깔 넘기기
                StartCoroutine(DamageOverTime(DOTTarget, DOTTimer));
            }
            else
            {
                DOTTarget.addtoHP((int)(-attackDamage), transform.position, gameObject.tag); //처음 맞을때 생명력 감소
            }

            state = State.Guard;
            yield return(new WaitForSeconds(4.0f));
        }
        //벗어날때
        GoToNextState();
    }