Пример #1
0
    // Update is called once per frame
    void Update()
    {
        //GameObject[] Bear_1_Tag = GameObject.FindGameObjectsWithTag("Bear_1");
        coolTime1 -= Time.deltaTime; //공격 시간 깍음
        if (coolTime1 < 0)
        {
            for (int i = 0; i < collBear_1.Count; i++)
            {
                SoundManager.PlaySound("rab1");
                if (collBear_1[i] != null && collBear_1[i].tag == "Bear_1")
                {
                    Bear target = collBear_1[i].GetComponent <Bear>();
                    target.Bear1_HP -= 42;
                    LR_Trun(collBear_1[i]);    //좌우 회전(아래 메소드 만들어둠)
                    animator.Play("R3Attack"); //애니메이션 실행. R1Attack 모션이 끝나면 자동으로 R1Stand로 돌아가는 것은 애니메이터에서 구현해둠.
                }
                if (collBear_1[i] != null && collBear_1[i].tag == "Bear_2")
                {
                    Bear_2 target = collBear_1[i].GetComponent <Bear_2>();
                    target.Bear2_HP -= 42;
                    LR_Trun(collBear_1[i]);
                    animator.Play("R3Attack");
                }
                if (collBear_1[i] != null && collBear_1[i].tag == "Bear_3")
                {
                    Bear_3 target = collBear_1[i].GetComponent <Bear_3>();
                    target.Bear3_HP -= 42;
                    LR_Trun(collBear_1[i]);
                    animator.Play("R3Attack");
                }
                if (collBear_1[i] != null && collBear_1[i].tag == "Bear_4")
                {
                    Bear_4 target = collBear_1[i].GetComponent <Bear_4>();
                    target.Bear4_HP -= 42;
                    LR_Trun(collBear_1[i]);
                    animator.Play("R3Attack");
                }
                if (collBear_1[i] != null && collBear_1[i].tag == "Bear_boss")
                {
                    Bear_boss target_4 = collBear_1[i].GetComponent <Bear_boss>();
                    LR_Trun(collBear_1[i]);
                    animator.Play("R3Attack");
                    target_4.Bear_boss_HP -= 42; //토끼 공격력

                    i = collBear_1.Count;
                    continue;
                }
            }
            coolTime1 = GameManager.instance.Rabbit3_attack_speed;// 토끼 공격속도
            Debug.Log("공격 초기화");
        }
    }
Пример #2
0
 private IEnumerator Attack()
 {
     if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1f)
     {
         for (int i = 0; i < collBear_1.Count; i++)
         {
             try
             {
                 if (collBear_1[i].tag == "Bear_1")
                 {
                     if (collBear_1[i] == null)
                     {
                         continue;
                     }
                     if ((collBear_1[i]).GetComponent <Bear>() == null)
                     {
                         continue;
                     }
                     Bear target = collBear_1[i].GetComponent <Bear>();
                     target.Bear1_HP -= 160;
                     Debug.Log("딜박힘");
                 }
                 if (collBear_1[i].tag == "Bear_2")
                 {
                     if (collBear_1[i] == null)
                     {
                         continue;
                     }
                     if ((collBear_1[i]).GetComponent <Bear_2>() == null)
                     {
                         continue;
                     }
                     Bear_2 target_2 = collBear_1[i].GetComponent <Bear_2>();
                     target_2.Bear2_HP -= 160;
                     Debug.Log("딜박힘");
                 }
                 if (collBear_1[i].tag == "Bear_3")
                 {
                     if (collBear_1[i] == null)
                     {
                         continue;
                     }
                     if ((collBear_1[i]).GetComponent <Bear_3>() == null)
                     {
                         continue;
                     }
                     Bear_3 target = collBear_1[i].GetComponent <Bear_3>();
                     target.Bear3_HP -= 160;
                     Debug.Log("딜박힘");
                 }
                 if (collBear_1[i].tag == "Bear_4")
                 {
                     if (collBear_1[i] == null)
                     {
                         continue;
                     }
                     if ((collBear_1[i]).GetComponent <Bear_4>() == null)
                     {
                         continue;
                     }
                     Bear_4 target = collBear_1[i].GetComponent <Bear_4>();
                     target.Bear4_HP -= 160;
                     Debug.Log("딜박힘");
                 }
                 if (collBear_1[i].tag == "Bear_boss")
                 {
                     if (collBear_1[i] == null)
                     {
                         continue;
                     }
                     if ((collBear_1[i]).GetComponent <Bear_boss>() == null)
                     {
                         continue;
                     }
                     Bear_boss target = collBear_1[i].GetComponent <Bear_boss>();
                     target.Bear_boss_HP -= 160;
                     Debug.Log("딜박힘");
                 }
             }
             catch (MissingReferenceException)
             {
             }
         }
         GameManager.instance.skill = false;
         Destroy(gameObject);
         yield return(new WaitForEndOfFrame());
     }
 }