Ejemplo n.º 1
0
    protected void GenerateJeton(int x, int y)
    {
        GameObject gameObject = Instantiate(whiteJetonPrefab) as GameObject;

        gameObject.transform.SetParent(transform);
        Jeton j = gameObject.GetComponent <Jeton>();

        jetons[x, y] = j;
        j.GetComponent <MeshRenderer>().enabled = false;
    }
Ejemplo n.º 2
0
    protected void TryMovePiece(int x1, int y1, int x2, int y2)
    {
        startDrag     = new Vector2(x1, y1);
        stopDrag      = new Vector2(x2, y2);
        selectedPiece = pieces[x1, y1];

        if (x2 < 0 || x2 >= pieces.Length || y2 < 0 || y2 >= pieces.Length)
        {
            if (selectedPiece != null)
            {
                MovePiece(selectedPiece, x1, y1, x2, y2, true);
            }
            startDrag     = Vector2.zero;
            selectedPiece = null;
            return;
        }

        if (selectedPiece != null)
        {
            // la piece n'a pas bouger
            if (stopDrag == startDrag)
            {
                MovePiece(selectedPiece, x1, y1, x2, y2, true);
                startDrag     = Vector2.zero;
                selectedPiece = null;
                return;
            }
            if (IA.ValidMove(pieces, jetons, x1, y1, x2, y2))
            {
                pieces[x2, y2] = selectedPiece;
                selectedPiece.setPositionX(x2);
                selectedPiece.setPositionY(y2);
                pieces[x1, y1] = null;
                MovePiece(selectedPiece, x1, y1, x2, y2, false);

                GenerateJeton(x2, y2);
                Jeton j = jetons[x2, y2];
                selectedJeton = j;
                selectedJeton.GetComponent <MeshRenderer>().enabled = false;
                startDrag = mouseOver;
                EndTurn();
            }
            else
            {
                MovePiece(selectedPiece, x1, y1, x2, y2, true);
                startDrag     = Vector2.zero;
                selectedPiece = null;
            }
        }
    }
Ejemplo n.º 3
0
    protected void selectJeton(int x, int y)
    {
        if (x < 0 || x >= pieces.Length || y < 0 || y >= pieces.Length)
        {
            return;
        }

        Jeton j = jetons[x, y];

        if (j != null)
        {
            selectedJeton = j;
            startDrag     = mouseOver;
        }
    }
Ejemplo n.º 4
0
    protected void updateJetonDrag(Jeton j)
    {
        if (!Camera.main)
        {
            Debug.Log("Unable to find main camera");
            return;
        }

        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 25.0f, LayerMask.GetMask("Board")))
        {
            j.transform.position = hit.point + Vector3.up;
        }
    }
Ejemplo n.º 5
0
 protected void EndTurn()
 {
     if (etat == 0 || etat == 2)
     {
         etat++;
     }
     else if (etat == 1)
     {
         etat++;
         selectedJeton = null;
         StartCoroutine(ChangeCameraTurn());
     }
     else
     {
         etat          = 0;
         selectedJeton = null;
         StartCoroutine(ChangeCameraTurn());
     }
     miseAJourPlateau();
     checkVictory();
 }
Ejemplo n.º 6
0
 protected void MoveJeton(Jeton j, int x, int y)
 {
     j.transform.position = (Vector3.right * x) + (Vector3.forward * y) + boardOffset + pieceOffset;
 }