using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class screensize
{
 [RuntimeInitializeOnLoadMethod]
 static void OnRuntimeMethodLoad()
 {
  Screen.SetResolution(1280,720,false);
 }
}
public class kabu_baibai : MonoBehaviour
{
 int flg=-1;int count=0;int spacewait=0;int spacecount=0;int gamemode=0;
 int money=10000;int nichime=0;
 int[] kabuka=new int[5];int[] zenhi=new int[5];int[] kabus=new int[5];int[] nps=new int[100];
 int[] newscount=new int[2];
 int i;int j;int k;int z;int zx;int zy;int r;int ee;int a;int aa;int aaa;int x;int y;int r1;int r2;int r3;int ax;int ay;
 int xx;int yy;int ii;int jj;int kk;int a1;int a2;int a3;int a4;
 int e;int e1;int moves;int mousex;int mousey;
 float pxf;float pxxf;float pyf;float pyyf;
 float stimef;float ntimef;float stime2f;float ntime2f;float stime3f;float ntime3f;float stime4f;float ntime4f;
 float xf;float yf;float af;float kakuf;float axf;float ayf;
 string c1;string c2;string c3;string c4;
 string d;string dd;string d1;string d2;string d3;string d4;
 GUIStyle style1;GUIStyle style2;GUIStyle style3;
 GameObject[] obj=new GameObject[2000];
 AudioSource[] bgm=new AudioSource[20];

 void Start()
 {
  style1=new GUIStyle();style1.fontSize=40;
  style2=new GUIStyle();style2.fontSize=16;
  style3=new GUIStyle();style3.fontSize=24;style3.normal.textColor=Color.red;
  obj[0]=GameObject.Find("ng-mes"); // 0  ng-mes
  for (i=0;i<=4;i++)
  {
   for (j=0;j<=3;j++) {obj[i*4+j+1]=GameObject.Find("kabu-house-"+(i+1)+"-"+(j+4));} // 1-20  face
  }
  for (i=1;i<=2;i++) {obj[i+20]=GameObject.Find("kabu-ya-"+i);} // 21-22  ya-uri-kai
  obj[23]=GameObject.Find("button-esc"); // 23  button-esc
  for (i=1;i<=5;i++) {obj[i+23]=GameObject.Find("kabu-shamei-"+i);} // 24-28  shamei
  obj[30]=GameObject.Find("kabu-news-waku"); // 30  news-waku
  for (i=1;i<=30;i++) {obj[i+30]=GameObject.Find("kabu-news-"+i);} // 31-60  news
  for (i=0;i<=2;i++)
  {
   obj[i*5+65]=GameObject.Find("num-16a-m"+(i+6)); // 65 70 75  moji-pm-moto
   for (j=1;j<=4;j++) {obj[i*5+j+65]=Object.Instantiate(obj[i*5+65]) as GameObject;} // 66-69 71-74 76-79  moji-pm-copy
  }
  obj[80]=GameObject.Find("num-16a-m4"); // 80  moji-oku-moto
  for (i=1;i<=9;i++) {obj[i+80]=Object.Instantiate(obj[80]) as GameObject;} // 81-89  moji-oku-copy
  obj[90]=GameObject.Find("num-16a-m3"); // 90  moji-man-moto
  for (i=1;i<=9;i++) {obj[i+90]=Object.Instantiate(obj[90]) as GameObject;} // 91-99  moji-man-copy
  for (i=0;i<=9;i++)
  {
   obj[i+200]=GameObject.Find("num-16a-"+i); // 200-209  nums-moto
   for (j=1;j<=129;j++) {obj[j*10+i+200]=Object.Instantiate(obj[i+200]) as GameObject;} // 210-1499  nums-copy
  }
  obj[1900]=GameObject.Find("kabu-titleback"); // 1900  titleback
  for (i=1;i<=9;i++) {obj[i+1900]=GameObject.Find("kabu-mes-"+i);} // 1901-1909  mes
  obj[1991]=GameObject.Find("gameend-mes-1"); // 1991  gameend-blue
  obj[1992]=GameObject.Find("gameend-mes-4"); // 1992  gameend-orange
  obj[1993]=GameObject.Find("gameclear-mes-1"); // 1993  gameclear-blue
  obj[1994]=GameObject.Find("gameclear-mes-4"); // 1994  gameclear-orange
  obj[1999]=GameObject.Find("ya-r-25x25"); // 1999  ya-r-25x25

  z=0;zx=0;zy=0;objput();
  for (i=1;i<=12;i++) {bgm[i]=obj[i].GetComponent();}
  count=500;flg=-1;
 }

 void Update()
 {
  if (flg==-1)
  {
   count=count-1;
   if (Input.GetKeyDown(KeyCode.Space)) {count=0;spacewait=2;}
   if (count<=0)
   {
    titleput();flg=0;
   }
  }
  if (flg==0)
  {
   ntime2f=Time.time;
   if (ntime2f-stime2f>=1f)
   {
    gamemode=gamemode+1;if (gamemode>7) {gamemode=1;}
    z=1999;zx=-190;zy=142-gamemode*32;objput();
    if (gamemode<1) {z=1999;zx=-2000;zy=0;objput();}
    stime2f=Time.time;
   }
   if (spacewait>0) {spacewait=spacewait-1;}
   if (spacewait<=0)
   {
    if (Input.GetKeyDown(KeyCode.Space))
    {
     if (gamemode>0) {gamestart();}
    }
   }
  }
  if (flg==1)
  {
   if (spacewait>0) {spacewait=spacewait-1;}
   if (spacewait<=0)
   {
    if (Input.GetKeyDown(KeyCode.Space)) {spacecount=spacecount+1;}
   }
   if (spacecount>=4) {titleput();}
   ntime2f=Time.time;
   if (ntime2f-stime2f>=5f)
   {
    z=1909;zx=-2000;zy=0;objput();z=1908;zx=-360;zy=-172;objput();
    for (i=30;i<=60;i++) {z=i;zx=-2000;zy=0;objput();}
    for (i=24;i<=28;i++) {z=i;objput();}
    z=21;zx=-440;zy=220;objput();
    bgm[1].Play();flg=2;count=1;spacewait=2;stime2f=Time.time;
   }
  }
  if (flg==2)
  {
   if (spacewait>0) {spacewait=spacewait-1;}
   if (spacewait<=0)
   {
    if (Input.GetKeyDown(KeyCode.Space))
    {
     if (count<=5) // kabu-kau
     {
      a=count-1;
      if (kabus[a]<999 && money>=kabuka[a])
      {
       kabus[a]=kabus[a]+1;money=money-kabuka[a];
       miniscoreput(a);
      }
     }
     else // kabu-uru
     {
      a=count-6;
      if (kabus[a]>0)
      {
       kabus[a]=kabus[a]-1;money=money+kabuka[a];
       if (money>999999999) {money=999999999;}
       miniscoreput(a);
      }
     }
    }
   }
   ntime2f=Time.time;
   if (ntime2f-stime2f>=1f)
   {
    stime2f=Time.time;
    z=21;zx=-2000;zy=0;objput();z=22;objput();
    count=count+1;
    if (count<=10)
    {
     bgm[count].Play();
     zx=count*220-660;zy=220;
     if (count<=5) {z=21;zx=count*220-660;zy=220;objput();}
     if (count>=6) {z=22;zx=(count-5)*220-660;zy=220;objput();}
    }
    else
    {
     z=1908;zx=-2000;zy=0;objput();
     newkabuka();hantei();
    }
   }
  }
  if (flg==8 || flg==9)
  {
   ntime2f=Time.time;
   if (ntime2f-stime2f>=0.5f)
   {
    stime2f=stime2f+0.5f;count=count+1;
    for (i=1991;i<=1994;i++) {z=i;zx=-2000;zy=0;objput();}
    z=(flg-8)*2+count%2+1991;;zx=0;zy=0;objput();
    if (count>=12) {titleput();}
   }
  }
 }

 void gamestart()
 {
  z=1900;zx=-2000;zy=0;objput();z=1999;objput();
  z=gamemode+1900;zx=-360;zy=-140;objput();
  money=10000;nichime=0;
  for (i=0;i<=4;i++)
  {
   kabuka[i]=100;zenhi[i]=0;kabus[i]=0;
   for (j=0;j<=19;j++) {nps[i*20+j]=0;}
  }
  if (a1>999999999) {a1=999999999;}
  if (a1<0) {a1=0;}
  scoreput();
  newscount[0]=0;newscount[1]=0;newnews();
 }

 void newnews()
 {
  for (i=30;i<=60;i++) {z=i;zx=-2000;zy=0;objput();}
  for (i=24;i<=28;i++) {z=i;objput();}
  for (i=1420;i<=1459;i++) {z=i;objput();}
  nichime=nichime+1;if (nichime>9999) {nichime=9999;}
  a1=nichime;aa=0;zy=-142; // nichi-me
  a=a1/1000;if (a>0 || aa>0) {aa=1;z=a+1420;zx=8;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1430;zx=24;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1440;zx=40;objput();}
  a=a1%10;z=a+1450;zx=56;objput();
  z=30;zx=0;zy=235;objput();
  r1=Random.Range(0,10);if (r1>9) {r1=0;}
  r2=Random.Range(0,5);if (r2>4) {r2=0;}
  r3=Random.Range(5,11);if (r3>10) {r3=5;}
  if (r1<=7)
  {
   ee=-1;
   for (i=0;i<=19;i++)
   {
    if (nps[r2*20+i]==0) {ee=r2*20+i;break;}
   }
   if (ee>=0)
   {
    z=r2+24;zx=-130;zy=250;objput();
    if (r1<=3)
    {
     z=newscount[0]+31;zx=50;zy=235;objput();
     newscount[0]=newscount[0]+1;if (newscount[0]>9) {newscount[0]=0;}
     nps[ee]=r3;
    }
    else
    {
     z=newscount[1]+41;zx=50;zy=235;objput();
     newscount[1]=newscount[1]+1;if (newscount[1]>9) {newscount[1]=0;}
     nps[ee]=r3*-1;
    }
    karizenhi();
   }
   else {r1=9;}
  }
  if (r1>=8)
  {
   r2=Random.Range(0,5);if (r2>4) {r2=0;}
   if (r2<4)
   {
    r3=Random.Range(0,5);if (r3>4) {r3=0;}
    z=r3+51;zx=50;zy=235;objput();
   }
   else
   {
    r3=Random.Range(0,41);if (r3>4) {r3=0;}
    z=(r3/10)+56;zx=50;zy=235;objput();
   }
  }
  z=1909;zx=-360;zy=-172;objput();
  flg=1;spacewait=2;spacecount=0;
  bgmstop();bgm[11].Play();stime2f=Time.time;
 }

 void karizenhi()
 {
  for (i=1;i<=20;i++) {z=i;zx=-2000;zy=0;objput();}
  for (i=0;i<=4;i++)
  {
   zenhi[i]=0;
   for (j=0;j<=19;j++)
   {
    zenhi[i]=zenhi[i]+nps[i*20+j];
    if (nps[i*20+j]>0) {nps[i*20+j]=nps[i*20+j]-1;}
    if (nps[i*20+j]<0) {nps[i*20+j]=nps[i*20+j]+1;}
   }
   if (kabuka[i]+zenhi[i]>999) {zenhi[i]=999-kabuka[i];}
   if (kabuka[i]+zenhi[i]<1) {zenhi[i]=kabuka[i]-1;}
   if (zenhi[i]<2 && zenhi[i]>-3) {z=i*4+1;zx=i*220-440;zy=100;objput();z=i*4+4;objput();}
   if (zenhi[i]>=2) {z=i*4+2;zx=i*220-440;zy=100;objput();z=i*4+4;objput();}
   if (zenhi[i]<=-3) {z=i*4+3;zx=i*220-440;zy=100;objput();z=i*4+4;objput();}
  }
 }

 void newkabuka()
 {
  for (i=0;i<=4;i++)
  {
   r1=Random.Range(-2,4);if (r1>3) {r1=0;}
   zenhi[i]=zenhi[i]+r1;
   a=kabuka[i]/10;if (a<1) {a=1;}
   if (zenhi[i]>a) {zenhi[i]=a;}
   if (zenhi[i]999) {zenhi[i]=999-kabuka[i];}
   if (kabuka[i]+zenhi[i]<1) {zenhi[i]=kabuka[i]-1;}
   kabuka[i]=kabuka[i]+zenhi[i];
  }
  scoreput();
 }

 void hantei()
 {
  ee=0;
  a1=money;
  for (i=0;i<=4;i++) {a1=a1+kabuka[i]*kabus[i];}
  if (gamemode==1 && nichime>=30) {ee=1;}
  if (gamemode==2 && nichime>=100) {ee=1;}
  if (gamemode==3 && nichime>=365) {ee=1;}
  if (gamemode==4 && a1>=20000) {ee=2;}
  if (gamemode==5 && a1>=50000) {ee=2;}
  if (gamemode==6 && a1>=100000) {ee=2;}
  if (ee>0) {flg=ee+7;gameend();} else {newnews();}
 }

 void gameend()
 {
  z=(flg-8)*2+1991;zx=0;zy=0;objput();
  z=1908;zx=-2000;zy=0;objput();z=1909;objput();
  stime2f=Time.time;count=0;
  bgmstop();bgm[12].Play();
 }

 void scoreput()
 {
  zx=-2000;zy=0;
  for (i=65;i<=99;i++) {z=i;objput();}
  for (i=200;i<=1499;i++) {z=i;objput();}
  for (i=0;i<=4;i++)
  {
   a1=kabuka[i];aa=0;zy=-23; // kabu-tanka
   if (a1>999) {a1=999;}
   if (a1<1) {a1=1;}
   a=a1/100;if (a>0 || aa>0) {aa=1;z=i*180+a+200;zx=i*220-404;objput();}
   a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=i*180+a+210;zx=i*220-388;objput();}
   a=a1%10;z=i*180+a+220;zx=i*220-372;objput();
   a1=zenhi[i];a2=1;a3=-388;aa=0;zy=-48; // zenjitsu-hi
   if (a1>99) {a1=99;}
   if (a1<-99) {a1=-99;}
   if (a1<0) {a2=2;a1=a1*-1;}
   if (a1==0) {a2=3;}
   a=a1/10;if (a>0 || aa>0) {aa=1;a3=-404;z=i*180+a+230;zx=i*220-388;objput();}
   a=a1%10;z=i*180+a+240;zx=i*220-372;objput();
   z=a2*5+i+60;zx=i*220+a3;objput();
   a1=kabus[i];aa=0;zy=-73; // mochi-kabu
   if (a1>9999) {a1=9999;}
   if (a1<0) {a1=0;}
   a=a1/1000;if (a>0 || aa>0) {aa=1;z=i*180+a+250;zx=i*220-420;objput();}
   a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=i*180+a+260;zx=i*220-404;objput();}
   a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=i*180+a+270;zx=i*220-388;objput();}
   a=a1%10;z=i*180+a+280;zx=i*220-372;objput();
   a1=kabuka[i]*kabus[i];aa=0;zy=-98; // sougaku
   a=a1/10000000;if (a>0 || aa>0) {aa=1;z=i*180+a+290;zx=i*220-484;objput();}
   a=(a1%10000000)/1000000;if (a>0 || aa>0) {aa=1;z=i*180+a+300;zx=i*220-468;objput();}
   a=(a1%1000000)/100000;if (a>0 || aa>0) {aa=1;z=i*180+a+310;zx=i*220-452;objput();}
   a=(a1%100000)/10000;if (a>0 || aa>0) {aa=1;z=i*180+a+320;zx=i*220-436;objput();}
   a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=i*180+a+330;zx=i*220-420;objput();}
   a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=i*180+a+340;zx=i*220-404;objput();}
   a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=i*180+a+350;zx=i*220-388;objput();}
   a=a1%10;z=i*180+a+360;zx=i*220-372;objput();
  }
  a1=money;aa=0;zy=-144; // genkin
  if (a1>999999999) {a1=999999999;}
  if (a1<0) {a1=0;}
  a=a1/100000000;if (a>0 || aa>0) {aa=1;z=a+1100;zx=344;objput();}
  if (a1>99999999) {z=81;zx=364;objput();}
  a=(a1%100000000)/10000000;if (a>0 || aa>0) {aa=1;z=a+1110;zx=380;objput();}
  a=(a1%10000000)/1000000;if (a>0 || aa>0) {aa=1;z=a+1120;zx=396;objput();}
  a=(a1%1000000)/100000;if (a>0 || aa>0) {aa=1;z=a+1130;zx=412;objput();}
  a=(a1%100000)/10000;if (a>0 || aa>0) {aa=1;z=a+1140;zx=428;objput();}
  if (a1>9999) {z=91;zx=444;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=a+1150;zx=460;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1160;zx=476;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1170;zx=492;objput();}
  a=a1%10;z=a+1180;zx=508;objput();
  a1=0;
  for (i=0;i<=4;i++) {a1=a1+kabus[i];}
  aa=0;zy=-169; // kabu-sousuu
  a=a1/10000;if (a>0 || aa>0) {aa=1;z=a+1190;zx=428;objput();}
  if (a1>9999) {z=92;zx=444;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=a+1200;zx=460;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1210;zx=476;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1220;zx=492;objput();}
  a=a1%10;z=a+1230;zx=508;objput();
  a1=0;
  for (i=0;i<=4;i++) {a1=a1+kabuka[i]*kabus[i];}
  if (a1>999999999) {a1=999999999;}
  if (a1<0) {a1=0;}
  aa=0;zy=-194; // kabu-sougaku
  a=a1/100000000;if (a>0 || aa>0) {aa=1;z=a+1240;zx=344;objput();}
  if (a1>99999999) {z=83;zx=364;objput();}
  a=(a1%100000000)/10000000;if (a>0 || aa>0) {aa=1;z=a+1250;zx=380;objput();}
  a=(a1%10000000)/1000000;if (a>0 || aa>0) {aa=1;z=a+1260;zx=396;objput();}
  a=(a1%1000000)/100000;if (a>0 || aa>0) {aa=1;z=a+1270;zx=412;objput();}
  a=(a1%100000)/10000;if (a>0 || aa>0) {aa=1;z=a+1280;zx=428;objput();}
  if (a1>9999) {z=93;zx=444;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=a+1290;zx=460;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1300;zx=476;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1310;zx=492;objput();}
  a=a1%10;z=a+1320;zx=508;objput();
  a1=a1+money;aa=0;zy=-219; // sou-shisan
  if (a1>999999999) {a1=999999999;}
  if (a1<0) {a1=0;}
  a=a1/100000000;if (a>0 || aa>0) {aa=1;z=a+1330;zx=344;objput();}
  if (a1>99999999) {z=84;zx=364;objput();}
  a=(a1%100000000)/10000000;if (a>0 || aa>0) {aa=1;z=a+1340;zx=380;objput();}
  a=(a1%10000000)/1000000;if (a>0 || aa>0) {aa=1;z=a+1350;zx=396;objput();}
  a=(a1%1000000)/100000;if (a>0 || aa>0) {aa=1;z=a+1360;zx=412;objput();}
  a=(a1%100000)/10000;if (a>0 || aa>0) {aa=1;z=a+1370;zx=428;objput();}
  if (a1>9999) {z=94;zx=444;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=a+1380;zx=460;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1390;zx=476;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1400;zx=492;objput();}
  a=a1%10;z=a+1410;zx=508;objput();
  a1=nichime;aa=0;zy=-142; // nichi-me
  if (a1>9999) {a1=9999;}
  a=a1/1000;if (a>0 || aa>0) {aa=1;z=a+1420;zx=8;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1430;zx=24;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1440;zx=40;objput();}
  a=a1%10;z=a+1450;zx=56;objput();
 }

 void miniscoreput(int n)
 {
  zx=-2000;zy=0;
  for (i=n*180+250;i<=n*180+369;i++) {z=i;objput();}
  for (i=1100;i<=1329;i++) {z=i;objput();}
  z=81;objput();z=83;objput();z=91;objput();z=93;objput();
  a1=kabus[n];aa=0;zy=-73; // mochi-kabu
  if (a1>9999) {a1=9999;}
  if (a1<0) {a1=0;}
  a=a1/1000;if (a>0 || aa>0) {aa=1;z=n*180+a+250;zx=n*220-420;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=n*180+a+260;zx=n*220-404;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=n*180+a+270;zx=n*220-388;objput();}
  a=a1%10;z=n*180+a+280;zx=n*220-372;objput();
  a1=kabuka[n]*kabus[n];aa=0;zy=-98; // sougaku
  a=a1/10000000;if (a>0 || aa>0) {aa=1;z=n*180+a+290;zx=n*220-484;objput();}
  a=(a1%10000000)/1000000;if (a>0 || aa>0) {aa=1;z=n*180+a+300;zx=n*220-468;objput();}
  a=(a1%1000000)/100000;if (a>0 || aa>0) {aa=1;z=n*180+a+310;zx=n*220-452;objput();}
  a=(a1%100000)/10000;if (a>0 || aa>0) {aa=1;z=n*180+a+320;zx=n*220-436;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=n*180+a+330;zx=n*220-420;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=n*180+a+340;zx=n*220-404;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=n*180+a+350;zx=n*220-388;objput();}
  a=a1%10;z=n*180+a+360;zx=n*220-372;objput();
  a1=money;aa=0;zy=-144; // genkin
  if (a1>999999999) {a1=999999999;}
  if (a1<0) {a1=0;}
  a=a1/100000000;if (a>0 || aa>0) {aa=1;z=a+1100;zx=344;objput();}
  if (a1>99999999) {z=81;zx=364;objput();}
  a=(a1%100000000)/10000000;if (a>0 || aa>0) {aa=1;z=a+1110;zx=380;objput();}
  a=(a1%10000000)/1000000;if (a>0 || aa>0) {aa=1;z=a+1120;zx=396;objput();}
  a=(a1%1000000)/100000;if (a>0 || aa>0) {aa=1;z=a+1130;zx=412;objput();}
  a=(a1%100000)/10000;if (a>0 || aa>0) {aa=1;z=a+1140;zx=428;objput();}
  if (a1>9999) {z=91;zx=444;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=a+1150;zx=460;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1160;zx=476;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1170;zx=492;objput();}
  a=a1%10;z=a+1180;zx=508;objput();
  a1=0;
  for (i=0;i<=4;i++) {a1=a1+kabus[i];}
  aa=0;zy=-169; // kabu-sousuu
  a=a1/10000;if (a>0 || aa>0) {aa=1;z=a+1190;zx=428;objput();}
  if (a1>9999) {z=92;zx=444;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=a+1200;zx=460;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1210;zx=476;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1220;zx=492;objput();}
  a=a1%10;z=a+1230;zx=508;objput();
  a1=0;
  for (i=0;i<=4;i++) {a1=a1+kabuka[i]*kabus[i];}
  if (a1>999999999) {a1=999999999;}
  if (a1<0) {a1=0;}
  aa=0;zy=-194; // kabu-sougaku
  a=a1/100000000;if (a>0 || aa>0) {aa=1;z=a+1240;zx=344;objput();}
  if (a1>99999999) {z=83;zx=364;objput();}
  a=(a1%100000000)/10000000;if (a>0 || aa>0) {aa=1;z=a+1250;zx=380;objput();}
  a=(a1%10000000)/1000000;if (a>0 || aa>0) {aa=1;z=a+1260;zx=396;objput();}
  a=(a1%1000000)/100000;if (a>0 || aa>0) {aa=1;z=a+1270;zx=412;objput();}
  a=(a1%100000)/10000;if (a>0 || aa>0) {aa=1;z=a+1280;zx=428;objput();}
  if (a1>9999) {z=93;zx=444;objput();}
  a=(a1%10000)/1000;if (a>0 || aa>0) {aa=1;z=a+1290;zx=460;objput();}
  a=(a1%1000)/100;if (a>0 || aa>0) {aa=1;z=a+1300;zx=476;objput();}
  a=(a1%100)/10;if (a>0 || aa>0) {aa=1;z=a+1310;zx=492;objput();}
  a=a1%10;z=a+1320;zx=508;objput();
 }
 void titleput()
 {
  alldel();bgmstop();flg=0;spacewait=2;z=1;zx=0;zy=0;objput();
  z=1900;zx=0;zy=0;objput();z=1999;zx=-2000;zy=0;objput();
  gamemode=0;
  for (i=0;i<=4;i++)
  {
   z=i*4+1;zx=i*220-440;zy=100;objput();z=i*4+4;objput();
  }
  stime2f=Time.time;
  bgmstop();flg=0;spacewait=2;gamemode=0;
 }

 void OnGUI()
 {
  GUI.Label (new Rect (300,80,100,30),c1,style1);
  GUI.Label (new Rect (300,160,100,30),c2,style2);
  GUI.Label (new Rect (300,240,100,30),c3,style1);
  GUI.Label (new Rect (300,320,100,30),c4,style3);
 }

 void objput()
 {
  Vector3 pos=obj[z].transform.position;
  pos.x=zx*0.01f;pos.y=zy*0.01f;
  obj[z].transform.position=pos;
 }

 void bgmstop()
 {
  for (i=1;i<=12;i++) {bgm[i].Stop();}
 }

 void alldel()
 {
  zx=-2000;zy=0;
  for (i=0;i<=28;i++) {z=i;objput();}
  for (i=30;i<=60;i++) {z=i;objput();}
  for (i=65;i<=99;i++) {z=i;objput();}
  for (i=200;i<=1499;i++) {z=i;objput();}
  for (i=1900;i<=1909;i++) {z=i;objput();}
  for (i=1991;i<=1994;i++) {z=i;objput();}
  z=1999;objput();
 }
}