Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
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
Tags
more
Archives
Today
Total
관리 메뉴

pais

[unity] Stage Mgr 본문

카테고리 없음

[unity] Stage Mgr

SKIAP 2020. 10. 21. 20:41
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StageMgr : MonoBehaviour
{

    public CameraMovement cameramovement;
    public static StageMgr Instance // singlton     
    {
        get
        {
            if (instance == null)
            {
                instance = FindObjectOfType<StageMgr>();
                if (instance == null)
                {
                    var instanceContainer = new GameObject("StageMgr");
                    instance = instanceContainer.AddComponent<StageMgr>();
                }
            }
            return instance;
        }
    }
    private static StageMgr instance;

    public GameObject Player;

    [System.Serializable]
    public class StartPositionArray
    {
        public List<Transform> StartPosition = new List<Transform>();
    }

    public StartPositionArray[] startPositionArrays;    // 0 1 2

    //방 20개 만들어서 각 방의 시작위치를 입력한다.

    public List<Transform> StartPositionAngel = new List<Transform>();
    // 천사방 3개 
    public List<Transform> StartPositionBoss = new List<Transform>();
    // 보스 1개
    public Transform StartPositionLastBoss;
    // 막보 하나

    public int currentStage = 0;  //현재 방위치
    

    // Start is called before the first frame update
    void Start()
    {
        Player = GameObject.FindGameObjectWithTag("Player");
    }

    private void Update()
    {

        if (currentStage == 20)
        {
            currentStage = 0;
        }
    }

    public void NextStage()
    {

        currentStage++;

        if (currentStage % 10 != 5 && currentStage % 10 != 0)  //Normal Stage
        {

            int arrayIndex = currentStage;
            Player.transform.position = startPositionArrays[0].StartPosition[arrayIndex].position;

            Debug.Log("arrayIndex 값은?" + arrayIndex);
            //return;
        }
        //BossRoom or Angel
        else if (currentStage % 10 == 5)   // Angel 5단위
        {
            int randomIndex = Random.Range(0, StartPositionAngel.Count);
            Player.transform.position = StartPositionAngel[randomIndex].position;
        }
        else if (currentStage % 10 == 0)  //LastBoss 10단위
        {
            Player.transform.position = StartPositionLastBoss.position;
        }
        cameramovement.CarmeraNextRoom();

    }//NextStage
}
Comments