Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     tmanager=GameObject.Find("Tmanager").GetComponent<Texturemanager>();
     _camera = Camera.main;
     screenWidth = _camera.pixelWidth;
     screenHeight = _camera.pixelHeight;
     StreamReader sw= new StreamReader("battleinfo\\box.txt");
     cardnumber=int.Parse(sw.ReadLine());
     while (ind<cardnumber) {
         try{tstr=sw.ReadLine();
             tobj=Instantiate (mcard,
                               mcard.transform.position,
                               this.gameObject.transform.localRotation);
             tobj.name="tcard"+ind.ToString();
             tcard = GameObject.Find("tcard"+ind.ToString()).GetComponent<card>();
             tcard.assigncard(tstr);
             tcard.updateTexture(tmanager);
             cardbox[ind]=tcard;
             ind++;
         }
         catch{break;}
     }
     sw.Close ();
     sw= new StreamReader("battleinfo\\playerinfo.txt");
     money = int.Parse(sw.ReadLine ());
     nowdeck = int.Parse(sw.ReadLine ());
     sw.Close ();
 }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     ai = new AI ();
     for (int i=0; i<6; i++) {
         pdeck[i]=new card();
             }
     tmanager=GameObject.Find("Tmanager").GetComponent<Texturemanager>();
     _camera = Camera.main;
     screenWidth = _camera.pixelWidth;
     screenHeight = _camera.pixelHeight;
     StreamReader sw= new StreamReader("battleinfo\\playerinfo.txt");
     money = int.Parse(sw.ReadLine ());
     nowdeck = int.Parse(sw.ReadLine ());
     sw.Close ();
     sw= new StreamReader("battleinfo\\battle.txt");
     while (ind<14) {
         try{tstr=sw.ReadLine();
             if (tstr=="e"){
                 ecard=true;
                 ind++;
                 tstr=sw.ReadLine();
             }
             if(ecard){
                 tobj=Instantiate (mcard,
                                   mcard.transform.position,
                                   this.gameObject.transform.localRotation);
                 tobj.name="tcard"+ind.ToString();
                 tcard = GameObject.Find("tcard"+ind.ToString()).GetComponent<card>();
                 tcard.assigncard(tstr);
                 tcard.isfrontcard=false;
                 tcard.ismycard=false;
                 tcard.position0=13-ind;
                 tcard.updateTexture(tmanager);
                 edeck[13-ind]=tcard;
             }
             ind++;
         }
         catch{break;}
         }
     edeckcnumber = 6;//TODO : 적의 덱 수를 알 수 있으면 지울것
     sw.Close ();
     StreamReader sw2 = new StreamReader ("battleinfo\\deck" + nowdeck.ToString () + ".txt");
     ind=0;
     pdeckcnumber=int.Parse(sw2.ReadLine());
     while (ind<pdeckcnumber) {
         try {
             tstr = sw2.ReadLine ();
             tobj = Instantiate (mcard,
                                 mcard.transform.position,
                                 this.gameObject.transform.localRotation);
             tobj.name = "tcard" + (ind).ToString ();
             tcard = GameObject.Find ("tcard" + (ind).ToString ()).GetComponent<card> ();
             tcard.assigncard (tstr);
             tcard.position0=ind;
             tcard.updateTexture (tmanager);
             pdeck [ind] = tcard;
             ind++;
         } catch {
             break;
         }
     }
     sw2.Close ();
 }
Beispiel #3
0
 void OnGUI()
 {
     GUIStyle mgui = new GUIStyle ();
     mgui.fontSize = 50;
     if (mode == "menu") {
         GUI.DrawTexture (getRect (0, 0, 1, 1), rectt);
         GUI.DrawTexture (getRect (0.53, 0.02, 0.1, 0.1), moneyt);
         GUI.Label (getRect (0.1, 0.022, 0.5, 0.1), "SHOP", mgui);
         GUI.Label (getRect (0.65, 0.022, 0.5, 0.1), "X " + money.ToString () + "D", mgui);
         if (GUI.Button (getRect (0.3, 0.3, 0.4, 0.15), "구매")) {
             mode = "buy1";
         }
         if (GUI.Button (getRect (0.3, 0.55, 0.4, 0.15), "판매")) {
             mode = "sale";
         }
         if (GUI.Button (getRect (0.3, 0.8, 0.4, 0.15), "메인으로")) {
             Application.LoadLevel ("mainscreen");
         }
     } else if (mode == "sale") {
         GUI.DrawTexture (getRect (0, 0, 1, 1), basedeck);
         GUI.Label (getRect (0.65, 0.022, 0.5, 0.1), money.ToString () + "D", mgui);
         GUI.color = Color.gray;
         GUI.DrawTexture (getRect (0, 0.092 + 0.0456 * page, 0.085, 0.092), rectt);
         GUI.color = Color.white;
         for (int i=0; i<6; i++) {
             if (page * 6 + i < cardnumber) {
                 if (GUI.Button (getpostition (i), "")) {
                     if (state == "see")
                         state = "change";
                     else
                         state = "see";
                     changecard = i;
                 }
                 if (state == "change" && i != changecard)
                     GUI.color = Color.gray;
                 drawcard (i, cardbox [page * 6 + i], "front");
                 if (state == "change" && i == changecard) {
                     cardbox [page * 6 + i].drawCard (0.62, 0.12, 0.22, 0.35, "front");
                     mgui.fontSize = 50;
                     GUI.Label (getRect (0.67, 0.565, 0.3, 0.1), cardbox [page * 6 + i].money.ToString () + "D", mgui);
                 }
                 GUI.color = Color.white;
             }
         }
         if (GUI.Button (getRect (0, 0, 0.085, 0.092), "")) {
             page--;
             state = "see";
             if (page < 0) {
                 page = 16;
             }
         }
         if (GUI.Button (getRect (0, 0.908, 0.085, 0.092), "")) {
             page++;
             state = "see";
             if (page > 16) {
                 page = 0;
             }
         }
         if (GUI.Button (getRect (0.52, 0.79, 0.164, 0.054), "")) {
             salecard (changecard);
             savedata ();
         }
         if (GUI.Button (getRect (0.766, 0.79, 0.164, 0.054), "")) {
             state = "see";
         }
         if (GUI.Button (getRect (0.52, 0.919, 0.164, 0.054), "")) {
         }
         if (GUI.Button (getRect (0.766, 0.919, 0.164, 0.054), "")) {
             Application.LoadLevel ("mainscreen");
         }
     }
     else if (mode == "buy1") {
         GUI.DrawTexture (getRect (0, 0, 1, 1), basebuy1);
         GUI.Label (getRect (0.65, 0.022, 0.5, 0.1), money.ToString () + "D", mgui);
         if (GUI.Button (getRect (0.8, 0.2, 0.1, 0.1), "구매")) {
             buyq=1;
             mode="buy2";
             state="case";
         }
         if (GUI.Button (getRect (0.8, 0.355, 0.1, 0.1), "구매")) {
             buyq=2;
             mode="buy2";
             state="case";
         }
         if (GUI.Button (getRect (0.8, 0.51, 0.1, 0.1), "구매")) {
             buyq=3;
             mode="buy2";
             state="case";
         }
         if (GUI.Button (getRect (0.8, 0.665, 0.1, 0.1), "구매")) {
             buyq=4;
             mode="buy2";
             state="case";
         }
         if (GUI.Button (getRect (0.41, 0.86, 0.164, 0.054), "")) {
             Application.LoadLevel ("mainscreen");
         }
     }
     else if (mode == "buy2") {
         mgui.fontSize=40;
         GUI.DrawTexture (getRect (0, 0, 1, 1), basebuy2);
         GUI.Label (getRect (0.65, 0.022, 0.5, 0.1), money.ToString () + "D", mgui);
         mgui.fontSize=35;
         if(state=="case"){
             if (GUI.Button(getRect (0.3, 0.2, 0.32, 0.5), "")&&money>=buycard(buyq)&&cardnumber<101){
                 state="card";
                 tstr=getcard(buyq);
                 tobj=Instantiate (mcard,
                                   mcard.transform.position,
                                   this.gameObject.transform.localRotation);
                 tobj.name="tcard";
                 tcard = GameObject.Find("tcard").GetComponent<card>();
                 tcard.assigncard(tstr);
                 tcard.updateTexture(tmanager);
                 money-=buycard(buyq);
                 savedata();
             }
             GUI.color=Color.yellow;
             GUI.DrawTexture (getRect (0, 0.72, 1, 0.28), rectt);
             GUI.color=Color.white;
             GUI.Label (getRect (0.3, 0.1, 0.5, 0.1), "카드를 클릭하세요", mgui);
             GUI.DrawTexture (getRect (0.3, 0.2, 0.32, 0.5), aoh);
             if (GUI.Button (getRect (0.4, 0.8, 0.2, 0.1), "취소")){
                 mode="buy1";
             }
             mgui.fontSize=50;
         }
         else if(state=="card"){
             tcard.drawCard(0.34, 0.2, 0.32, 0.5,"front");
             mgui.fontSize=50;
             GUI.Label (getRect (0.45, 0.785, 0.3, 0.1), tcard.money.ToString () + "D", mgui);
             mgui.fontSize=30;
             GUI.Label (getRect (0.15, 0.86, 0.3, 0.1), buycard(buyq).ToString () + "D", mgui);
             mgui.fontSize=50;
             if (GUI.Button (getRect (0.048, 0.925, 0.145, 0.042), "")) {
                 cardbox[cardnumber]=tcard;
                 cardnumber++;
                 tobj.name="aftercard";
                 savedata();
                 state="case";
             }
             if (GUI.Button (getRect (0.237, 0.925, 0.145, 0.042), "")) {
                 money+=tcard.money;
                 GameObject.Destroy(tobj);
                 savedata();
                 state="case";
             }
             if (GUI.Button (getRect (0.425, 0.925, 0.145, 0.042), "")) {
                 cardbox[cardnumber]=tcard;
                 cardnumber++;
                 tobj.name="aftercard";
                 savedata();
                 mode="buy1";
             }
             if (GUI.Button (getRect (0.612, 0.925, 0.145, 0.042), "")) {
                 money+=tcard.money;
                 GameObject.Destroy(tobj);
                 savedata();
                 mode="buy1";
             }
             if (GUI.Button (getRect (0.800, 0.925, 0.145, 0.042), "")) {
                 cardbox[cardnumber]=tcard;
                 cardnumber++;
                 tobj.name="aftercard";
                 savedata();
                 Application.LoadLevel ("mainscreen");
             }
         }
     }
 }