Unity/2D RPG

보스 등장 인트로 by Unity

YunSeong 2021. 11. 14. 21:12
728x90
반응형

여기서 만든 보스 인트로 과정을 나누어본다면

player가 자동으로 보스룸으로 걸어온다. 

철창이 올라오면서 player을 가둔다.

보스가 표효하면서 보스 이름이 떨어지듯이 뜬다로 나눌 수 있다.

GatekeeperIntro.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class GatekeeperIntro : MonoBehaviour
{
    private GameObject player, camera, cage, boss, bossName;
 
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player"); //플레이어
        camera = GameObject.FindGameObjectWithTag("MainCamera"); //카메라
        cage = GameObject.Find("cage"); //올라오는 철창
        bossName = GameObject.FindGameObjectWithTag("BossName"); //보스 이름
        boss = GameObject.Find("gatekeeper"); //보스
 
        camera.GetComponent<CameraController>().stop = true//카메라를 못 움직이게 한다.
 
        camera.GetComponent<Transform>().position = new Vector3(0.5f, -5-10); //정해진 위치로 카메라를 옮긴다.
        camera.GetComponent<Camera>().orthographicSize = 10//카메라 크기(시아범위)를 넓게 정한다.
        player.GetComponent<PMC>().stop = true//플레이어가 못 움직이게 한다.
        cage.GetComponent<Transform>().position = new Vector3(1-20, cage.GetComponent<Transform>().position.z); 
        StartCoroutine(intro());
    }
 
    IEnumerator intro()
    {
        player.GetComponent<Transform>().position = new Vector2(-21-12); 
        
        while (player.GetComponent<Transform>().position.x < -10// 지정된 위치까지 올때까지 플레이어가 걷게한다.
        {
            player.GetComponent<PMC>().Walk(1);
            yield return new WaitForSeconds(0.01f); 
        }
        player.GetComponent<PMC>().Walk(0);
        boss.GetComponent<gatekeeper>().animator.SetTrigger("growl"); //보스가 포효하게한다.
        yield return new WaitForSeconds(0.35f);
        cage.GetComponent<Rigidbody2D>().velocity = new Vector2(040); //철창이 올라오게한다.
        while (cage.GetComponent<Transform>().position.y < -6)
        {
            yield return new WaitForSeconds(0.001f);
        }
        camera.GetComponent<cameraShake>().shakeCamera(0.5f); //철창이 올라올 때 진동이 울리도록한다.
        cage.GetComponent<Rigidbody2D>().velocity = new Vector2(00); // 적당히 철창이 올라왔을 때 멈추게 한다.
 
        yield return new WaitForSeconds(1);
 
        bossName.GetComponent<BossNameShower>().showBossTitel(); //보스 이름이 떨어지듯 나타나도록한다.
        yield return new WaitForSeconds(3);
 
 
        bossName.GetComponent<Transform>().localScale = new Vector3(000); //보스 이름을 안 보이도록한다.
        boss.GetComponent<gatekeeper>().animator.SetTrigger("ready"); // 보스전이 시작하도록한다.
 
        yield return new WaitForSeconds(1);
        boss.GetComponent<gatekeeper>().nextPatternPlay();
        player.GetComponent<PMC>().stop = false//플레이어를 움직이게 한다.
    }
}
 
cs

 

결과

 

 

728x90
반응형

'Unity > 2D RPG' 카테고리의 다른 글

점프 공격 패턴 by Unity  (0) 2021.08.28
다중 투사체 패턴 by Unity  (0) 2021.08.28
돌진 공격 패턴 by Unity  (0) 2021.08.28
보스 공격 패턴 by Unity  (0) 2021.08.28
키 배치 설정 by Unity  (0) 2021.08.18