2016-07-22 3 views
-1

차례를 기준으로 한번에 3 번 표시하려고합니다. 첫 번째 시간은 카운트 다운되는 총 시간입니다. 다른 두 개의 타이머는 각 플레이어의 카운트 다운 시간을 보여줍니다. 다른 클래스에서 확인 된 부울 값이 있습니다 (myplayerturn)델타 시간 중지 C#

지금은 총 시간과 플레이어 시간을 모두 효과적으로 표시 할 수 있지만 플레이어 시간이 실행될 때마다 다른 플레이어 타이머를 일시 중지하십시오. }

public class countDown : MonoBehaviour { 

public Text timerText; 
public Text PlayerTime; 
public Text OpponentTime; 
public float myTimer = 3600; 



// Use this for initialization 
void Start() { 
    timerText = GetComponent<Text>(); 
    PlayerTime = GetComponent<Text>(); 
    OpponentTime = GetComponent<Text>(); 

} 

// Update is called once per frame 
void Update() { 

    if (GetComponent<differentclass>().myplayerturn) 
    { 
     //I'm gueussing this is where i need to pause OpponentTime; 
     // and start PlayerTime 
    } 
    else{ 
     // pause PlayerTime 
     } 

    int minutes = Mathf.FloorToInt(myTimer/60F); 
    int seconds = Mathf.FloorToInt(myTimer - minutes * 60); 
    string rTime = string.Format("{0:00}:{1:00}", minutes, seconds); 

    myTimer -= Time.deltaTime; 
    timerText.text = rTime; 
    PlayerTime.text = rTime; 
    OpponentTime.text = rTime; 


} 

을 다음과

답변

0

난 작은 클래스 분, 초를 저장하고 모든 선수에게 클래스를 제공하고 일시 정지 할 때 단지 시간을 증가 해달라고하는 것처럼 지금까지 내 코드입니다. 난 그냥 사람 클래스 변수를 사용하는 것이 업데이트의 내부 그리고

public class PlayerTime { 
    public int seconds = 0; 
    public int minutes = 0; 
    public float myTimer = 3600; 
} 

을이 같을 것이다 .