Esempio n. 1
0
    public void Undo()
    {
        Debug.Log("Calling Undo");
        // check that there is at least one line in goStack to undo
        if (goStack.Count > 0)
        {
            Debug.Log("Stack Count: " + goStack.Count);
            Debug.Log("List Count: " + SaveManager.listSavedLines.Count);
            // take off last item in listSavedLines
            SaveLine line = SaveManager.listSavedLines[SaveManager.listSavedLines.Count - 1];
            SaveManager.listSavedLines.RemoveAt(SaveManager.listSavedLines.Count - 1);

            // add to undoneLines
            SaveManager.undoneLines.Add(line);

            // get the game object and destroy it
            GameObject destroyTarget = goStack.Pop();
            GameObject.Destroy(destroyTarget);
        }
        else
        {
            Debug.Log("No lines to undo!!!");
        }
        // sm.PrintContentsExternal();
    }
Esempio n. 2
0
    public void loadStrokeData()
    {
        // loading part, might need to move this bit somewhere later
        // also i foresee this part taking a long ass time to do.
        for (int i = 0; i < listSavedLines.Count; i++)
        {
            // create a line
            GameObject lineGameObj = Instantiate(linePrefab);
            Line       currentLine = lineGameObj.GetComponent <Line>();

            // update line order...
            currentLine.lineRenderer.sortingOrder = LayerOrder.Order;

            // get the saved line data
            SaveLine currentSavedLine  = listSavedLines[i];
            Color    currentSavedColor = new Color(currentSavedLine.serColor._r,
                                                   currentSavedLine.serColor._g,
                                                   currentSavedLine.serColor._b,
                                                   currentSavedLine.serColor._a);
            currentLine.SetColor(currentSavedColor);
            currentLine.SetWidth(currentSavedLine.width);
            currentLine.SetTexture(currentSavedLine.texture);

            // setting the vector2 data
            currentLine.CreateLineBeforeLoadPoint();
            foreach (SerializableVector2 point in currentSavedLine.points)
            {
                Vector2 tempPoint = new Vector2(point.x, point.y);
                currentLine.SetPoint(tempPoint);
            }
        }
    }
Esempio n. 3
0
    public void Redo()
    {
        Debug.Log("Calling Redo");
        // Check that there is at least one line in undoneLines to redo
        if (SaveManager.undoneLines.Count > 0)
        {
            // take off last item in undoneLines
            SaveLine line = SaveManager.undoneLines[SaveManager.undoneLines.Count - 1];
            SaveManager.undoneLines.RemoveAt(SaveManager.undoneLines.Count - 1);

            // add to listSavedLines
            SaveManager.listSavedLines.Add(line);

            // create line and load in the stroke
            GameObject lineGameObj = Instantiate(linePrefab);
            Line       currentLine = lineGameObj.GetComponent <Line>();
            // update line order
            currentLine.lineRenderer.sortingOrder = LayerOrder.Order;
            goStack.Push(lineGameObj);

            // get the saved line data
            Color currentSavedColor = new Color(line.serColor._r,
                                                line.serColor._g,
                                                line.serColor._b,
                                                line.serColor._a);
            currentLine.SetColor(currentSavedColor);
            currentLine.SetWidth(line.width);
            currentLine.SetTexture(line.texture);
            // setting the vector2 data
            currentLine.CreateLineBeforeLoadPoint();
            foreach (SerializableVector2 point in line.points)
            {
                Vector2 tempPoint = new Vector2(point.x, point.y);
                currentLine.SetPoint(tempPoint);
            }

            // done?
        }
        else
        {
            Debug.Log("No lines to redo!!!");
        }
        sm.PrintContentsExternal();
    }
Esempio n. 4
0
    // TESTING FUNCTIONS

    // test local dat files
    void loadTest()
    {
        string          path = "saveTEST.dat";
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      fs   = new FileStream(path, FileMode.Open);

        List <SaveLine> listLoadLines = bf.Deserialize(fs) as List <SaveLine>;

        fs.Close();

        // set the savedlines as the loaded in lines
        listSavedLines = listLoadLines;

        // loading part, might need to move this bit somewhere later
        // also i foresee this part taking a long ass time to do.
        for (int i = 0; i < listSavedLines.Count; i++)
        {
            // create a line
            GameObject lineGameObj = Instantiate(linePrefab);
            Line       currentLine = lineGameObj.GetComponent <Line>();

            // get the saved line data
            SaveLine currentSavedLine  = listLoadLines[i];
            Color    currentSavedColor = new Color(currentSavedLine.serColor._r,
                                                   currentSavedLine.serColor._g,
                                                   currentSavedLine.serColor._b,
                                                   currentSavedLine.serColor._a);
            currentLine.SetColor(currentSavedColor);
            currentLine.SetWidth(currentSavedLine.width);
            currentLine.SetTexture(currentSavedLine.texture);

            // setting the vector2 data
            currentLine.CreateLineBeforeLoadPoint();
            foreach (SerializableVector2 point in currentSavedLine.points)
            {
                Vector2 tempPoint = new Vector2(point.x, point.y);
                currentLine.SetPoint(tempPoint);
            }
        }
    }