Exemplo n.º 1
0
 private void swapAnchor(RaycastHit hit){
     // les info de la pièce en déplacement
     EditorInfo editorInfoActuel = selectedPart.GetComponent<EditorInfo>();
     // la position avant déplacement de la pièce
     int oldAnchorPos = editorInfoActuel.linkedAnchor.GetComponent<AnchorPlace>().infos.anchorPos;
     // L'ancre avant déplacement de la pièce
     AnchorPlace editorInfoActAnchor = editorInfoActuel.linkedAnchor.GetComponent<AnchorPlace>();
     // On réinitialise l'ancre précédente a une ancre libre
     editorInfoActAnchor.infos = new AnchorInfo();
     editorInfoActAnchor.infos.anchorPos = oldAnchorPos;
     editorInfoActAnchor.isOccupied = false;
     // on lie la nouvelle ancre a la pièce (_dans son Editor Info)
     editorInfoActuel.linkedAnchor = hit.transform.gameObject;
     // on va re-chercher les info de cette nouvelle ancre
     AnchorPlace aPActuel = editorInfoActuel.linkedAnchor.GetComponent<AnchorPlace>();
     // l'ancre sait sa position reste seulement a la pièce de s'identifier
     aPActuel.infos.itemName = editorInfoActuel.nomItem;
     aPActuel.isOccupied=true;
     //solution pour le moment: désacitver la pièce, effectuer la permutation puis réactiver la pièce -- marche bien en fin de compte
     selectedPart.SetActive(false);
     selectedPart.transform.position = hit.transform.position;
     selectedPart.transform.rotation = hit.transform.rotation;
     selectedPart.SetActive(true);
     hasChangedSinceLastSave = true;
 }
Exemplo n.º 2
0
    public string[] saveBotPieces()
    {
        List <AnchorPlace> temp = new List <AnchorPlace>()
        {
        };

        foreach (GameObject ancre in  _ancres.anchorsList)
        {
            AnchorPlace anchorPlaceAct = ancre.GetComponent <AnchorPlace>();
            if (anchorPlaceAct.isOccupied)
            {
                temp.Add(anchorPlaceAct);
            }
        }

        List <string> listJsonPieces = new List <string>();

        temp.ForEach((x) => listJsonPieces.Add(JsonUtility.ToJson(x.infos)));
        string jsonPieces = "[";

        for (int i = 0; i < listJsonPieces.Count; i++)
        {
            jsonPieces += listJsonPieces[i];
            jsonPieces += (i != listJsonPieces.Count - 1)?",":"";
        }
        jsonPieces += "]";
        return(new string [2] {
            jsonPieces, _baseName
        });
    }
Exemplo n.º 3
0
 private void trashItem() {
     hasChangedSinceLastSave = true;
     EditorInfo editorInfoActuel = selectedPart.GetComponent<EditorInfo>();
     removeFromLimit(editorInfoActuel.nomItem);
     showLimit();
     // la position avant déplacement de la pièce
     int oldAnchorPos = editorInfoActuel.linkedAnchor.GetComponent<AnchorPlace>().infos.anchorPos;
     // L'ancre avant déplacement de la pièce
     AnchorPlace editorInfoActAnchor = editorInfoActuel.linkedAnchor.GetComponent<AnchorPlace>();
     // On réinitialise l'ancre précédente a une ancre libre
     editorInfoActAnchor.infos = new AnchorInfo();
     editorInfoActAnchor.infos.anchorPos = oldAnchorPos;
     editorInfoActAnchor.isOccupied = false;
     Destroy(selectedPart);
     selectedPart = null;
     cameraMenu.blockCam = false;
     trashUI.fingerid=0;
     trashUI.isSelecting = false;
     
 }