Пример #1
0
        // ----- SETUP -----

        public void Setup()
        {
            _levelEditor = LevelEditor.Instance;
            _undoStack   = new FiniteStack <int[, , ]>();
            _redoStack   = new FiniteStack <int[, , ]>();
            SetupClickListeners();
        }
Пример #2
0
 // Method that resets the level and GameObject before a load
 private void ResetBeforeLoad()
 {
     // Destroy everything inside our currently level that's created dynamically
     foreach (Transform child in tileLevelParent.transform)
     {
         Destroy(child.gameObject);
     }
     level        = CreateEmptyLevel();
     layerParents = new Dictionary <int, GameObject> ();
     // Reset undo and redo stacks
     undoStack = new FiniteStack <int[, , ]> ();
     redoStack = new FiniteStack <int[, , ]> ();
 }
Пример #3
0
        public ActionManager(NodeEditorWindow w)
        {
            _undoStack = new FiniteStack <UndoableAction>(100);
            _redoStack = new Stack <UndoableAction>();

            _window = w;

            // Makes sure that the action cleans up after itself
            // when it is removed from the undo buffer.
            _undoStack.OnRemoveBottomItem += (action) =>
            {
                action.OnDestroy();
            };
        }
Пример #4
0
    private void ApplyEvent(FiniteStack <HistoryEvent> apply)
    {
        if (apply.count <= 0)
        {
            return;
        }

        HistoryEvent next = apply.Pop();

        next.Restore(data.songData);
        data.currentPattern = next.pattern;
        view.UpdatePatternData();
        Debug.Log("Next line is " + next.position.line);
        view.SetSelection(next.position);
    }
Пример #5
0
    // Method to instantiate the dependencies and variables
    public void Start()
    {
        // Check the start values to prevent errors
        CheckStartValues();

        // Define the level sizes as the sizes for the grid
        GridOverlay.instance.SetGridSizeX(WIDTH);
        GridOverlay.instance.SetGridSizeY(HEIGHT);

        // Find the camera, position it in the middle of our level and store initial zoom level
        mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
        if (mainCamera != null)
        {
            mainCamera.transform.position = new Vector3(WIDTH / 2, HEIGHT / 2, mainCamera.transform.position.z);
            //Store initial zoom level
            mainCameraComponent = mainCamera.GetComponent <Camera> ();
            if (mainCameraComponent.orthographic)
            {
                mainCameraInitialSize = mainCameraComponent.orthographicSize;
            }
            else
            {
                mainCameraInitialSize = mainCameraComponent.fieldOfView;
            }
        }
        else
        {
            errorCounter++;
            Debug.LogError("Object with tag MainCamera not found");
        }

        // Get or create the tileLevelParent object so we can make it our newly created objects' parent
        tileLevelParent = GameObject.Find("TileLevel");
        if (tileLevelParent == null)
        {
            tileLevelParent = new GameObject("TileLevel");
        }

        // Instantiate the level and gameObject to an empty level and empty Transform
        level       = CreateEmptyLevel();
        gameObjects = new Transform[WIDTH, HEIGHT, LAYERS];

        // Instantiate the undo and redo stack
        undoStack = new FiniteStack <int[, , ]> ();
        redoStack = new FiniteStack <int[, , ]> ();

        SetupUI();
    }
    public static void Main()
    {
        SimpleStack <string> a = new SimpleStack <string>();

        a.Push("Monday");
        a.Push("Tuesday");
        a.Push("Wednesday");
        a.Push("Thursday");
        a.Push("Friday");

        FiniteStack <string> b = new FiniteStack <string>(12);

        b.Push("June");
        b.Push("May");
        b.Push("April");
        b.Push("March");

        SimpleStack <Interval> c = new SimpleStack <Interval>();

        c.Push(new Interval(5, 31));
        c.Push(new Interval(4, 52));
        c.Push(new Interval(7, 23));
        c.Push(new Interval(3, 44));
        c.Push(new Interval(6, 15));

        SimpleStack <object> d = new SimpleStack <object>();

        d.Push("Sunday");
        d.Push(new Interval(2, 30));
        d.Push(12.3);

        a.Copy(b);
        c.Copy(d);

        PrintStack(a);
        PrintStack(b);
        PrintStack(c);
        PrintStack(d);
    }
Пример #7
0
    public static void Main()
    {
        SimpleStack <string> a = new SimpleStack <string>();

        a.Push("Monday");
        a.Push("Tuesday");
        a.Push("Wednesday");
        a.Push("Thursday");
        a.Push("Friday");

        FiniteStack <string> b = new FiniteStack <string>(10);

        b.Push("June");
        b.Push("May");
        b.Push("April");
        b.Push("March");

        SimpleStack <Interval> c = new SimpleStack <Interval>();

        c.Push(new Interval(5, 41));
        c.Push(new Interval(7, 32));
        c.Push(new Interval(6, 53));
        c.Push(new Interval(3, 24));
        c.Push(new Interval(4, 15));

        SimpleStack <object> d = new SimpleStack <object>();

        d.Push("Saturday");
        d.Push(45.6);
        c.Copy(d);         //contravariance(Interval -> object) for IStackWriter

        PrintStack(a);     //covariance(object -> string) for IStackReader
        PrintStack(b);
        PrintStack(c);
        PrintStack(d);
    }
Пример #8
0
        // ----- PUBLIC METHODS -----

        // Reset undo and redo stacks
        public void Reset()
        {
            _undoStack = new FiniteStack <int[, , ]>();
            _redoStack = new FiniteStack <int[, , ]>();
        }