2016-07-22 1 views
-1

私はターンベースのゲームで3回同時に表示しようとしています。 最初にカウントダウンされる合計時間です。 他の2つのタイマーには、各プレーヤーのカウントダウン時間が表示されます。 別のクラスからブール値をチェックして、それがどのターンであるかを調べる(myplayer urn)デルタタイムを停止する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; 
} 

:次のようになり 。

関連する問題