Exemplo n.º 1
0
    private void PiyonOlustur(int x, int y)
    {
        GameObject go = Instantiate(piyonPrefab) as GameObject;
        Piyon      p  = go.GetComponent <Piyon>();

        piyonlar[x, y] = p;
        PiyonTasi(p, x, y);
    }
Exemplo n.º 2
0
    private void TasimaDene(int x1, int y1, int x2, int y2)
    {
        startDrag    = new Vector2(x1, y1);
        endDrag      = new Vector2(x2, y2);
        secilenPiyon = piyonlar[x1, y1];

        //Out of bounds
        if (x2 < 0 || x2 >= 7 || y2 < 0 || y2 >= 7)
        {
            if (secilenPiyon != null)
            {
                PiyonTasi(secilenPiyon, x1, y1);
            }

            startDrag    = Vector2.zero;
            secilenPiyon = null;
            return;
        }

        if (secilenPiyon != null)
        {
            //Eğer aynı yere taşınmak isterse taşıma iptal edilir
            if (endDrag == startDrag)
            {
                PiyonTasi(secilenPiyon, x1, y1);

                startDrag    = Vector2.zero;
                secilenPiyon = null;
                return;
            }

            //Taşınabilir mi kontrol edilecek
            if (TasimaDogrula(x1, y1, x2, y2))
            {
                if (x1 == x2)
                {
                    Destroy(piyonlar[x1, (y1 + y2) / 2].gameObject);
                    piyonlar[x1, (y1 + y2) / 2] = null;
                }
                else
                {
                    Destroy(piyonlar[(x1 + x2) / 2, y1].gameObject);
                    piyonlar[(x1 + x2) / 2, y1] = null;
                }

                Debug.Log(PiyonSayac());

                piyonlar[x2, y2] = secilenPiyon;
                piyonlar[x1, y1] = null;
                PiyonTasi(secilenPiyon, x2, y2);
                secilenPiyon = null;
                startDrag    = Vector2.zero;
            }
        }
    }
Exemplo n.º 3
0
    private void UpdatePiyonDrag(Piyon p)
    {
        if (!Camera.main)
        {
            Debug.Log("Main camera bulunamadı!");
        }

        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 25.0f, LayerMask.GetMask("Tabla")))
        {
            p.transform.position = hit.point + (Vector3.up * 2);
        }
    }
Exemplo n.º 4
0
    private void PiyonSec(int x, int y)
    {
        //Out of bounds
        if (x < 0 || x >= 7 || y < 0 || y >= 7)
        {
            return;
        }

        Piyon p = piyonlar[x, y];

        if (p != null)
        {
            secilenPiyon = p;
            startDrag    = mouseOver;
        }
    }
Exemplo n.º 5
0
 private void PiyonTasi(Piyon p, int x, int y)
 {
     p.transform.position = (Vector3.forward * x) + (Vector3.right * y);
 }