using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class main : MonoBehaviour {
public GameObject o1;
public GameObject o2;
public GameObject o3;
public GameObject o4;
public GameObject o5;
public GameObject o6;
public GameObject o7;
public GameObject o8;
public GameObject o9;
public GameObject o10;
public GameObject o11;
public GameObject end;
public float[] values;
private int pos;
public int nn = 0;
public bool ifwin = false;
public int zzz;
public GameObject gui;
public string s = "Лог: \n";
public int ii = 0;
// Use this for initialization
void Start () {
ii = 1;
pos = Random.Range(1,12);
values = new float[10000];
}
// Update is called once per frame
void Update () {
if(!ifwin){
ifclicked num1 = o1.GetComponent<ifclicked>();
ifclicked num2 = o2.GetComponent<ifclicked>();
ifclicked num3 = o3.GetComponent<ifclicked>();
ifclicked num4 = o4.GetComponent<ifclicked>();
ifclicked num5 = o5.GetComponent<ifclicked>();
ifclicked num6 = o6.GetComponent<ifclicked>();
ifclicked num7 = o7.GetComponent<ifclicked>();
ifclicked num8 = o8.GetComponent<ifclicked>();
ifclicked num9 = o9.GetComponent<ifclicked>();
ifclicked num10 = o10.GetComponent<ifclicked>();
ifclicked num11 = o11.GetComponent<ifclicked>();
if(num1.ifclick == 1){
num1.ifclick = 0;
zzz = 1;
doMove(zzz);
}
if(num2.ifclick == 1){
num2.ifclick = 0;
zzz = 2;
doMove(zzz);
}
if(num3.ifclick == 1){
num3.ifclick = 0;
zzz = 3;
doMove(zzz);
}
if(num4.ifclick == 1){
num4.ifclick = 0;
zzz = 4;
doMove(zzz);
}
if(num5.ifclick == 1){
num5.ifclick = 0;
zzz = 5;
doMove(zzz);
}
if(num6.ifclick == 1){
num6.ifclick = 0;
zzz = 6;
doMove(zzz);
}
if(num7.ifclick == 1){
num7.ifclick = 0;
zzz = 7;
doMove(zzz);
}
if(num8.ifclick == 1){
num8.ifclick = 0;
zzz = 8;
doMove(zzz);
}
if(num9.ifclick == 1){
num9.ifclick = 0;
zzz = 9;
doMove(zzz);
}
if(num10.ifclick == 1){
num10.ifclick = 0;
zzz = 10;
doMove(zzz);
}
if(num11.ifclick == 1){
num11.ifclick = 0;
zzz = 11;
doMove(zzz);
}
}
}
//pos
//hod
void doMove(int hod){
Debug.Log(pos);
if(nn>5){
s="";
nn=0;
}
if(hod == pos){
Debug.Log("Победа!!!");
ifwin=true;
s=s+"Победа! Ходы зайца:\n";
for(int k = 1; k<ii+1; k++){
s=s+values[k]+"-";
}
s=s+"\n Новая игра: \n";
pos=Random.Range(1,12);
ifwin=false;
ii=0;
gui.GetComponent<Text>().text = s;
} else{
s=s+"Промах номер "+ii+"! \n";
gui.GetComponent<Text>().text = s;
ii=ii+1;
if(pos == 0){
pos=pos+1;
} else if(pos==10){
pos=pos-1;
} else{
if(Random.Range(0,2)==0){
pos=pos+1;
}else{
pos=pos-1;
}
}
values[ii] = pos;
}
nn++;
}
}