public void changepositionoftwo(GameStone g1,GameStone g2) { int[] gfirst = getcoordinatesofgamestone(g1); int[] gsecond = getcoordinatesofgamestone(g2); int[] temp = new int[2] { g1.Gamestonepositionfinal[0], g1.Gamestonepositionfinal[1]}; GameStone ttemp = g1; if(searchifchangeisokay(g1,g2)) { //update position gamematrix[gfirst[0], gfirst[1]].Gamestonepositionfinal = g2.Gamestonepositionfinal; gamematrix[gsecond[0], gsecond[1]].Gamestonepositionfinal = temp; //changegamestonesingrid gamematrix[gfirst[0], gfirst[1]] = g2; gamematrix[gsecond[0], gsecond[1]] = ttemp; spielzuege--; spielzug.text = "Moves: " + System.Convert.ToString(spielzuege); } else { _a = null; _b = null; Debug.Log("kein nachbar"); } }
public void usedGameStones(object[] clicked) { GameStone ggamestone = (GameStone)clicked[0]; int richtung = (int)clicked[1]; if (checkiffull()) { _a = ggamestone; int[] position = getcoordinatesofgamestone(ggamestone); if (richtung == 0) _b = gamematrix[position[0], position[1] - 1]; //....................y x if (richtung == 1) _b = gamematrix[position[0], position[1] + 1]; //....................y x if (richtung == 2) _b = gamematrix[position[0] + 1, position[1]]; //....................y x if (richtung == 3) _b = gamematrix[position[0] - 1, position[1]]; if (spielzuege > 0) { StartCoroutine(changeitwithdelay()); } else { StartCoroutine(gameov()); } //....................y x /* if (_a == null) { _a = ggamestone; Debug.Log("a ausgewählt"); //_a.gameObject.GetComponent<Image>().color = Color.black;// .CrossFadeAlpha(0.3f, 2f, true); } else { _b = ggamestone; Debug.Log("b ausgewählt"); //_b.gameObject.GetComponent<Image>().color = Color.black; //methode zum vertauschen ********************* } */ } }
private IEnumerator waitformouseinput() { yield return new WaitForSeconds(1); if(_b == null) { _a = null; } }
private bool searchifchangeisokay(GameStone g1, GameStone g2) { int[] gfirst = getcoordinatesofgamestone(g1); int[] gsecond = getcoordinatesofgamestone(g2); if (gsecond[0] == gfirst[0] + 1 && gsecond[1] == gfirst[1] || gsecond[0] == gfirst[0] - 1 && gsecond[1] == gfirst[1] || gsecond[0] == gfirst[0] && gsecond[1] == gfirst[1] + 1 || gsecond[0] == gfirst[0] && gsecond[1] == gfirst[1] - 1) { return true; } return false; }
private int[] getcoordinatesofgamestone(GameStone getcoordinate) { for (int i = 0; i < row; i++) { for (int x = 0; x < 9; x++) { if(gamematrix[i,x] == getcoordinate) { try { return new int[2] {i,x}; } catch { Debug.LogError("Object is null"); } } } } return null; }
private IEnumerator changeitwithdelay() { if (checkiffull()) { changepositionoftwo(_a, _b); _a = null; _b = null; yield return new WaitForSeconds(0.1f); if(spielzuege <= 0) { StartCoroutine(gameov()); } //StartCoroutine(updatematrix()); StartCoroutine(Checkthreealgorithm()); } }
public void changepositionoftwo(GameStone g1,GameStone g2) { int[] p1 = g1.Gamestonepositionfinal; g1.Gamestonepositionfinal = g2.Gamestonepositionfinal; g2.Gamestonepositionfinal = p1; }