kwan's note

AR 게임 - 대학교에서 살아남기 본문

project/Game

AR 게임 - 대학교에서 살아남기

kwan's note 2022. 3. 14. 01:58
반응형

https://play.google.com/store/apps/details?id=com.ucm.EscapeFromUniv 

 

대학교에서 살아남기 AR - Google Play 앱

끝없는 과제, 코로나, 술... 목숨이 위협 받는 대학교에서 무사히 살아남아보자!

play.google.com

 

  • 끝없는 과제, 코로나, 술... 목숨이 위협 받는 대학교에서 무사히 살아남아보자!
  • 오징어 게임의 무궁화꽃이 피었습니다를 학교에서 교수님과 즐겨보세요
  • AR 기반 게임 플레이로 플레이어의 움직임을 제어하여 제한시간 내에 목표를 달성
  • 무사히 졸업하는 그날까지 플레이를 멈추지 마세요!

 

https://github.com/kwanyun/EscapeFromUniv-1#mortar_board-escapefromuniv

https://github.com/mooooh/EscapeFromUniv

간단 설명

-plane detection을 통해 물체, 배경을 증강시킬 바닥을 인식하고 해당 공간에 배경과 player, 교수님(avatar)를 증강시킨다.

-증강된 책을 획득하면 학점이 오르고 교수님이 바라보지 않는 동안 태그하면 해당 점수만큼 학점을 획득

-현재 학년, 평점등을 기록하고 공유할 수 있음.

 

 

<GameManager.cs> 소스코드 (import 및 선언 생략)

public class GameManager : MonoBehaviour
{
    static public GameManager instance;
    #region singleton
    void Awake()    //객체 생성시 최초 실행 
    {
        if (instance == null)
        {
            instance = this;
            //DontDestroyOnLoad(gameObject);
        }
        else
            Destroy(gameObject);

    }
    #endregion singleton
    //상태

    // Start is called before the first frame update
    void Start()
    {   //난이도  딕셔너리 초기화(Add)
        dictionaryInit(); 

        //ARSession 초기화
        GameObject.FindObjectOfType<ARSession>().Reset();

        //상태값 초기화
        _currentState = Status.READY;
        _currentDetailState = DetailStatus.Scan;

        //난이도 초기화
        LevelInitialized();
        if(DataController._selectedLevel.Equals("1-1"))
        {
            isTutorial = true;
        }
        else
        {
            isTutorial = false;
        }
    }

    // Update is called once per frame
    void Update()
    {
        _currentProgressValue = (float)_currentScore / _totalScore;
        UIManager.instance.gradeUpdate(_currentProgressValue);

        if (_currentState == Status.RUN)
        {
            //타이머 창 활성화 안되어있으면 다시 활성화함
            if (!timerText.gameObject.activeSelf) {
                timerText.gameObject.SetActive (true);
            }
            _currentTimer += Time.deltaTime;
            timerText.text = ((int)(_limitedTime-_currentTimer)).ToString();
            UIManager.instance.timerUpdate(_limitedTime,(int)(_limitedTime - _currentTimer));

            if (_currentDetailState == DetailStatus.Unsafe) {
                _currentUnsafeTimer += Time.deltaTime;
                if (_currentUnsafeTimer > _unsafeTime)
                {
                    SoundManager.instance.PlayProfessorSpeak(_currentLevel[0]);
                    _currentUnsafeTimer = 0.0f;
                }
            }

            if (_currentTimer > _limitedTime) {
                GameManager.instance._currentState = GameManager.Status.STOP;
                GameManager.instance._currentDetailState = GameManager.DetailStatus.GameOver;
                //SoundManager.instance.StopSE("Sound1");
                GameEndManager.instance.GameOver("자네는 수업이 끝날때까지 뭘 했나?");
                _currentTimer = 0.0f;
            }



        }
        else
        {
            _currentTimer = 0.0f;
            timerText.gameObject.SetActive(false);
        }
    }

    public void dictionaryInit()
    {
        _levelDcitionary.Add("1-1", insertDetailLevelDictionary(60, 0, 1));

        _levelDcitionary.Add("2-1", insertDetailLevelDictionary(60, 0, 3));
        _levelDcitionary.Add("2-2", insertDetailLevelDictionary(60, 0, 5));
        _levelDcitionary.Add("2-3", insertDetailLevelDictionary(60, 1, 5));
        _levelDcitionary.Add("2-4", insertDetailLevelDictionary(60, 1, 6));

        _levelDcitionary.Add("3-1", insertDetailLevelDictionary(45, 2, 5));
        _levelDcitionary.Add("3-2", insertDetailLevelDictionary(45, 2, 6));
        _levelDcitionary.Add("3-3", insertDetailLevelDictionary(45, 3, 6));
        _levelDcitionary.Add("3-4", insertDetailLevelDictionary(45, 3, 7));

        _levelDcitionary.Add("4-1", insertDetailLevelDictionary(40, 4, 6));
        _levelDcitionary.Add("4-2", insertDetailLevelDictionary(40, 4, 8));
        _levelDcitionary.Add("4-3", insertDetailLevelDictionary(40, 5, 8));
        _levelDcitionary.Add("4-4", insertDetailLevelDictionary(40, 5, 9));
                                                                
        _levelDcitionary.Add("1-2", insertDetailLevelDictionary(40, 5, 9));
        _levelDcitionary.Add("1-3", insertDetailLevelDictionary(40, 5, 9));
        _levelDcitionary.Add("1-4", insertDetailLevelDictionary(30, 5, 9));
    }
    public Dictionary<string, int> insertDetailLevelDictionary(int _limitedTime, int _bigBookNum, int _smallBookNum)
    {
        Dictionary<string, int> _detailLevelDcitionary = new Dictionary<string, int>();   //총시간, 큰책수, 작은책수 데이터
        _detailLevelDcitionary.Add("limitedTime", _limitedTime);
        _detailLevelDcitionary.Add("bigBookNum", _bigBookNum);
        _detailLevelDcitionary.Add("smallBookNum", _smallBookNum);
        return _detailLevelDcitionary;

    }
    public void Initialized()   //같은 레벨 초기화
    {
        //상태 초기화
        StatusInitialized();

        BtnController.instance.gameStart_SetActive_True_And_Interactive_False();

        //현재 레벨로 난이도 초기화
        LevelInitialized();

        //프로그래스바 및 성적 초기화
        UIManager.instance.gradeInitialized();

        //수강중인 과목 초기화
        UIManager.instance.initCurrentLevel_InGame();

        //책 초기화
        BookGenerator bookGenerator = GameObject.FindObjectOfType<BookGenerator>();
        bookGenerator.Initialized();

        //PickText 창 초기화
        TouchController touchController = GameObject.FindObjectOfType<TouchController>();
        touchController.Initialized();
    }

    public void Initialized_NextLevel()   //다음 레벨 초기화
    {
        //상태 초기화
        StatusInitialized();

        BtnController.instance.gameStart_SetActive_True_And_Interactive_False();

        //다음 레벨로 난이도 초기화
        LevelInitialized(_currentLevel);

        //책 초기화
        BookGenerator bookGenerator = GameObject.FindObjectOfType<BookGenerator>();
        bookGenerator.Initialized();

        //프로그래스바 및 성적 초기화
        UIManager.instance.gradeInitialized();

        //수강중인 과목 초기화
        UIManager.instance.initCurrentLevel_InGame();

        //PickText 창 초기화
        TouchController touchController = GameObject.FindObjectOfType<TouchController>();
        touchController.Initialized();


    }
    public void StatusInitialized()
    {
        //현재 상태 값 변경
        _currentState = Status.READY;
        _currentDetailState = DetailStatus.PrefabCreated;
        BtnController.instance.reset_setActiva_True();
    }
     public void LevelInitialized()  //레벨 초기화
    {
        _currentProgressValue = 0.0f;
        _currentSingleBookProgressValue = 0.0f;
        _currentBooksProgressValue = 0.0f;
        _currentScore = 0;
        _currentDetailScore_Book = 0;
        _currentDetailScore_Books = 0;
        _currentLevel = DataController._selectedLevel;
        _limitedTime = _levelDcitionary[_currentLevel]["limitedTime"];
        _bigBookNum = _levelDcitionary[_currentLevel]["bigBookNum"];
        _smallBookNum = _levelDcitionary[_currentLevel]["smallBookNum"];
        _totalScore = _smallBookNum * _smallBookScore+_bigBookNum * _bigBookScore ;
        }

    public void LevelInitialized(string _beforeLevel)
    {
        _currentProgressValue = 0.0f;
        _currentSingleBookProgressValue = 0.0f;
        _currentBooksProgressValue = 0.0f;
        _currentScore = 0;
        _currentDetailScore_Book = 0;
        _currentDetailScore_Books = 0;
        int _beforeIdx = Array.IndexOf(_levelDcitionary.Keys.ToArray(), _beforeLevel);
        _currentLevel = _levelDcitionary.Keys.ElementAt(_beforeIdx + 1);;
        DataController._selectedLevel = _currentLevel;
        _limitedTime = _levelDcitionary[_currentLevel]["limitedTime"];
        _bigBookNum = _levelDcitionary[_currentLevel]["bigBookNum"];
        _smallBookNum = _levelDcitionary[_currentLevel]["smallBookNum"];
        _totalScore = _smallBookNum * _smallBookScore + _bigBookNum * _bigBookScore;
    }

    public void OnDestroy()
    {
           // SoundManager.instance.StopAllSE();
    }
}
반응형