Esempio n. 1
0
    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");
        }
    }
Esempio n. 2
0
    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 *********************

            }
            */
        }
    }
Esempio n. 3
0
 private IEnumerator waitformouseinput()
 {
     yield return new WaitForSeconds(1);
     if(_b == null)
     {
         _a = null;
     }
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 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());
     }
 }
Esempio n. 7
0
 public void changepositionoftwo(GameStone g1,GameStone g2)
 {
     int[] p1 = g1.Gamestonepositionfinal;
     g1.Gamestonepositionfinal = g2.Gamestonepositionfinal;
     g2.Gamestonepositionfinal = p1;
 }