Example #1
0
        public void generate()
        {
            int sizeDemande  = int.Parse(Size);
            int moneyDemande = int.Parse(Money);

            if (10 > sizeDemande || sizeDemande > 100)
            {
                throw new Exception("size invalide");
            }

            if (0 > moneyDemande || moneyDemande > 10000)
            {
                throw new Exception("money invalide");
            }

            if (string.IsNullOrWhiteSpace(Filename))
            {
                Popups.instance.Popup("Level name required.", Color.red);
                throw new Exception("filename invalide");
            }

            if (File.Exists(Application.persistentDataPath + "/" + Filename + ".lvl"))
            {
                map = Map.Load(camera, mapObject, Filename);
            }
            else
            {
                map = new Map(camera, mapObject, sizeDemande, moneyDemande, Filename);
            }

            canvasTool.SetActive(true);
            canvasInit.SetActive(false);
        }
Example #2
0
        public Editor(string[] args)
        {
            // Create the main window.
            window = new RenderWindow(new VideoMode(Configuration.Width, Configuration.Height), "Level Editor");
            window.SetFramerateLimit(60);

            // Listen for window events.
            window.Closed             += OnClose;
            window.MouseWheelScrolled += OnScroll;
            window.MouseButtonPressed += OnPress;
            window.KeyPressed         += KeyPressed;

            // Load all the components that we have created.
            components         = ComponentLoader.GetComponents();
            selectedComponents = new List <Component>();

            background = new Vertex[4]
            {
                new Vertex(new Vector2f(0, 0), new Color(0x3E, 0x5A, 0x8E)),
                new Vertex(new Vector2f(Configuration.Width, 0), new Color(0x3E, 0x5A, 0x8E)),
                new Vertex(new Vector2f(Configuration.Width, Configuration.Height), new Color(0x82, 0xAB, 0xE3)),
                new Vertex(new Vector2f(0, Configuration.Height), new Color(0x82, 0xAB, 0xE3))
            };

            clock = new Clock();
            grid  = new AllignmentGrid();
            map   = new Map();

            if (args.Any())
            {
                map = MapHelper.LoadMap($"{Configuration.MapLocations}\\{args.First()}");
                map.Load();
            }
        }