NEW Project .boss

윤재학·2022년 7월 12일

Project ( RRD )

목록 보기
1/4

BOSS Attack

 보스의 공격 코드

IEnumerator DestroyRuneSkill()
    {
        yield return new WaitForSeconds(Constant.BOSS_SKILL_COOL_TIME);

            for (int i = 0; i < Constant.BOSS_SKILL_COUNT; ++i)
            {
                 Board.Inst.DestroyRune();

                 if (Board.Inst.RunePosition != Vector3.zero)
                 {
                     var bulletEffect = Instantiate(bossBullet, Board.Inst.RunePosition, Quaternion.identity);
                     Destroy(bulletEffect, 2f);
                     yield return new WaitForEndOfFrame();
                 }
                 else
                 {
                     yield break;
                 }

            }      
    }

공격방식은 보드에서 각라인의 배열안에 룬이 있는지 확인을 하고 50퍼센트 확률로 룬을 파괴한다.

보드에 파괴 코드

public void DestroyRune()
    {     
        for (int i = 0; i < lines.Length; i++)
        {           
            if (lines[i].CurrentIndex > 0)
            {
                // 50 퍼 확률로 룬 파괴 (0 , 1)
                int onDestroy = Random.Range(0 , 2);

                if (onDestroy == 0)
                {
                    Debug.Log(lines[i].name + "파괴");
                    lines[i].DestroyRune();

                    //해당 타일 위치에 룬 포지션
                    var RuneIndex = lines[i].DestroyIndex;
                    RunePosition = lines[i].tiles[RuneIndex].rune.transform.position;
                    break;
                }               
            }    
        }
    }
profile
노력하자 즐겁게 개발할수 있는 환경을 위해

0개의 댓글