void OnMouseDown() { ff.Grids g = (ff.Grids)parent.GetComponent("Grids"); if (!g.startGame) { g.gameTimer.Start(); g.startGame = true; } g.tapCount++; GameObject te = g.findObject( centV + new Vector3(0.1f, 0.0f, 0.0f), centV + new Vector3(-0.1f, 0.0f, 0.0f), centV + new Vector3(0.0f, 0.0f, -0.1f), centV + new Vector3(0.0f, 0.0f, 0.1f) ); if (te != null) { Vector3 temp = this.transform.localPosition; this.transform.localPosition = te.transform.localPosition; centV = te.transform.localPosition; ff.Touch t = (ff.Touch)te.GetComponent("Touch"); //g.setNewCoor (te.transform.localPosition, idO); te.transform.localPosition = temp; t.centV = temp; string SoundSettings = PlayerPrefs.GetString("SoundSettings"); bool IsOn = bool.Parse(SoundSettings); if (!IsOn) { AudioSource Asound = (AudioSource)g.GetComponent("AudioSource"); Asound.PlayOneShot(Asound.clip); //g.setNewCoor (temp, t.idO); } } g.checkFinal(); }
// Use this for initialization void Awake() { endGame = false; startGame = false; GameObject tapCountText = (GameObject)GameObject.Find("taps"); tapCountTextData = (Text)tapCountText.GetComponent("Text"); GameObject secondsText = (GameObject)GameObject.Find("seconds"); secondsTextData = (Text)secondsText.GetComponent("Text"); seconds = 0; tapCount = 0; gameTimer = new System.Timers.Timer(); gameTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimeIvent); gameTimer.Interval = 1000; //---------------------- // post score 12345 to leaderboard ID "CgkI7-Wxtb8NEAIQAQ") //@@@@@@@@@@@@@ Social.ReportScore(12345, "CgkI7-Wxtb8NEAIQAQ", (bool success) => { // handle success or failure //@@@@@@@@@@@@@ }); //---------------------- rand = new float[15]; randObj = new float[15]; // tiles = new List <GameObject> (); for (int i = 1; i < 16; i++) { tiles.Add(GameObject.Find(string.Format("Cube_{0}", i.ToString("00")))); } GameObject go = new GameObject(); tiles.Add(go); // gridPoint = new Vector3[16]; gridPoint [0].Set(0.0f, 0.1f, 0.0f); gridPoint [1].Set(0.0f, 0.1f, 0.1f); gridPoint [2].Set(0.0f, 0.1f, 0.2f); gridPoint [3].Set(0.0f, 0.1f, 0.3f); gridPoint [4].Set(0.1f, 0.1f, 0.0f); gridPoint [5].Set(0.1f, 0.1f, 0.1f); gridPoint [6].Set(0.1f, 0.1f, 0.2f); gridPoint [7].Set(0.1f, 0.1f, 0.3f); gridPoint [8].Set(0.2f, 0.1f, 0.0f); gridPoint [9].Set(0.2f, 0.1f, 0.1f); gridPoint [10].Set(0.2f, 0.1f, 0.2f); gridPoint [11].Set(0.2f, 0.1f, 0.3f); gridPoint [12].Set(0.3f, 0.1f, 0.0f); gridPoint [13].Set(0.3f, 0.1f, 0.1f); gridPoint [14].Set(0.3f, 0.1f, 0.2f); gridPoint [15].Set(0.3f, 0.1f, 0.3f); while (!GenerateLevel()) { } ; for (int i = 0; i < 15; i++) { ff.Touch h; Transform f; for (int j = 0; j < 15; j++) { if (randObj [i] == rand [j]) { f = tiles [j].transform; tiles [j].tag = "Player"; h = (ff.Touch)tiles [j].AddComponent("Touch"); h.setGridPoint(gridPoint [i], j, this.gameObject); f.localPosition = gridPoint [i]; } } } Transform f1 = tiles [15].transform; ff.Touch h1 = (ff.Touch)tiles [15].AddComponent("Touch"); tiles [15].tag = "Trat"; h1.setGridPoint(gridPoint [15], 15, this.gameObject); f1.localPosition = gridPoint [15]; state = State.Loaded; }