커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
숙제 질문
undefined주차
북마크
김*진
댓글
2
추천
0
조회수
3
조회수
3
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


GameManager 코드입니다. 시간 제한 로직을 update()에 넣어도 유니티로 실행했을 때 반영이 되지 않습니다.. 이유와 해결 방법이 궁금합니다






using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;


public class GameManager : MonoBehaviour

{

  public static GameManager Instance;


  public Card firstCard;

  public Card secondCard;


  public int cardCount = 0;

  public Text timeTxt;

  public GameObject endTxt;


  float time = 0.0f;


  private void Awake()

  {

    if(Instance == null)

    {

      Instance = this;

    }

  }


  // Start is called before the first frame update

  void Start()

  {

    Time.timeScale = 1.0f;

  }


  // Update is called once per frame

  void Update()

  {

    time += Time.deltaTime;

    timeTxt.text = time.ToString("N2");

  }


  public void Matched()

  {

    if(firstCard.idx== secondCard.idx)

    {

      //파괴

      firstCard.DestroyCard();

      secondCard.DestroyCard();

      cardCount -= 2;

      if (cardCount == 0)

      {

        EndGame();

      }

      if (time >= 30.0f)

      {

        EndGame();

      }

    }

    else

    {

      //닫기

      firstCard.CloseCard();

      secondCard.CloseCard();

    }

    firstCard = null;

    secondCard = null;

  }

  private void EndGame()

  {

    Time.timeScale = 0.0f;

    endTxt.SetActive(true);

  }

}





취소
 공유
취소
댓글 0
댓글 알림
나의얼굴