求高手把下面这段js转换成C#
varscore=0;vartextureToDisplay:Texture2D;varscores:Texture2D[];vartimeLife=60;varcurr...
var score=0;
var textureToDisplay:Texture2D;
var scores:Texture2D[];
var timeLife=60;
var currentDate;
var currentScore;
var now:Date;
var tempTexture;
var wbili=1.0f;
var hbili=1.0f;
function Awake () {
currentDate=PlayerPrefs.GetString("date");
currentScore=PlayerPrefs.GetString("score");
}
function OnTriggerEnter () {
score++;
}
daojishi();
function daojishi(){
while(timeLife>=-2){
yield new WaitForSeconds(1);
timeLife--;
}
}
function OnGUI(){
wbili=Screen.width/540.0;
hbili=Screen.height/960.0;
GUI.DrawTexture(Rect(0,0,540*wbili,150*hbili),textureToDisplay);
if(score<=9){
tempTexture = scores[score];
GUI.DrawTexture(Rect(100*wbili,48*hbili,22*wbili,80*hbili),tempTexture);
}else{
GUI.DrawTexture(Rect(100*wbili,48*hbili,22*wbili,80*hbili),scores[(score%10)]);
GUI.DrawTexture(Rect(60*wbili,48*hbili,22*wbili,80*hbili),scores[(score-score%10)/10]);
}
if(timeLife<=0){
GUI.DrawTexture(Rect(460*wbili,48*hbili,22*wbili,80*hbili),scores[(0)]);
}else if(timeLife<=9&&timeLife>0){
GUI.DrawTexture(Rect(460*wbili,48*hbili,22*wbili,80*hbili),scores[(timeLife)]);
}else{
GUI.DrawTexture(Rect(460*wbili,48*hbili,22*wbili,80*hbili),scores[(timeLife%10)]);
GUI.DrawTexture(Rect(420*wbili,48*hbili,22*wbili,80*hbili),scores[(timeLife-timeLife%10)/10]);
}
if(timeLife==0){
timeLife=-3;
now=System.DateTime.Now;
var temps=((now.Month+"").Length==1?("0"+now.Month):(""+now.Month))+"-"+((now.Day+"").Length==1?("0"+now.Day):(""+now.Day))+" "+((now.TimeOfDay.Hours+"").Length==1?("0"+now.TimeOfDay.Hours):(""+now.TimeOfDay.Hours))+":"
+((now.TimeOfDay.Minutes+"").Length==1?("0"+now.TimeOfDay.Minutes):(""+now.TimeOfDay.Minutes));
var tempdate="*"+temps+currentDate;
PlayerPrefs.SetString("date",tempdate);
var tempscoe="*"+((score<=9)?" "+score:""+score)+currentScore;
PlayerPrefs.SetString("score",tempscoe);
}
} 展开
var textureToDisplay:Texture2D;
var scores:Texture2D[];
var timeLife=60;
var currentDate;
var currentScore;
var now:Date;
var tempTexture;
var wbili=1.0f;
var hbili=1.0f;
function Awake () {
currentDate=PlayerPrefs.GetString("date");
currentScore=PlayerPrefs.GetString("score");
}
function OnTriggerEnter () {
score++;
}
daojishi();
function daojishi(){
while(timeLife>=-2){
yield new WaitForSeconds(1);
timeLife--;
}
}
function OnGUI(){
wbili=Screen.width/540.0;
hbili=Screen.height/960.0;
GUI.DrawTexture(Rect(0,0,540*wbili,150*hbili),textureToDisplay);
if(score<=9){
tempTexture = scores[score];
GUI.DrawTexture(Rect(100*wbili,48*hbili,22*wbili,80*hbili),tempTexture);
}else{
GUI.DrawTexture(Rect(100*wbili,48*hbili,22*wbili,80*hbili),scores[(score%10)]);
GUI.DrawTexture(Rect(60*wbili,48*hbili,22*wbili,80*hbili),scores[(score-score%10)/10]);
}
if(timeLife<=0){
GUI.DrawTexture(Rect(460*wbili,48*hbili,22*wbili,80*hbili),scores[(0)]);
}else if(timeLife<=9&&timeLife>0){
GUI.DrawTexture(Rect(460*wbili,48*hbili,22*wbili,80*hbili),scores[(timeLife)]);
}else{
GUI.DrawTexture(Rect(460*wbili,48*hbili,22*wbili,80*hbili),scores[(timeLife%10)]);
GUI.DrawTexture(Rect(420*wbili,48*hbili,22*wbili,80*hbili),scores[(timeLife-timeLife%10)/10]);
}
if(timeLife==0){
timeLife=-3;
now=System.DateTime.Now;
var temps=((now.Month+"").Length==1?("0"+now.Month):(""+now.Month))+"-"+((now.Day+"").Length==1?("0"+now.Day):(""+now.Day))+" "+((now.TimeOfDay.Hours+"").Length==1?("0"+now.TimeOfDay.Hours):(""+now.TimeOfDay.Hours))+":"
+((now.TimeOfDay.Minutes+"").Length==1?("0"+now.TimeOfDay.Minutes):(""+now.TimeOfDay.Minutes));
var tempdate="*"+temps+currentDate;
PlayerPrefs.SetString("date",tempdate);
var tempscoe="*"+((score<=9)?" "+score:""+score)+currentScore;
PlayerPrefs.SetString("score",tempscoe);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询