// Tries to open and load a map file on users computer

        /*
         *      public static void MapDataOpenMap(string mapName = "", string mapPath = "")
         *      {
         *              switch (MapDataPrepForChange())
         *              {
         *                      case -1:
         *                      break;
         *                      case 0:
         *                              MapDataSaveMap();
         *                              MapDataQuery.DeleteMapQuery();
         *                      goto case 1;
         *                      case 1:
         *                              GlobalToolManager.disabelTools();
         *                              MapDataQuery.DeleteMapQuery();
         *                              SessionManager.SessionManagerClearRefs();
         *
         *                              mapData = MapDataImportFromFile(mapPath, mapName + ".berrymap");
         *
         *                              mapDataFileName = mapName;
         *                              mapDataTileSize = 0.32f;
         *                              UiManager.DestroyAllFocus();
         *
         *                              if(mapData == null){ Debug.LogError("WOOOPSI"); }
         *                              MapDataCreateMapObj();
         *
         *                      break;
         *              }
         *      }
         */

        public static void MapDataOpenXCPMap(int mapIndex)
        {
            if (XCPManager.currentXCP.xpcMaps[mapIndex] == null)
            {
                Debug.LogError("WWWWWNWOWPWEWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
            }
            //if(mapIndex == mapDataXCPIndex) {UiManager.DestroyAllFocus(); Debug.Log("Sorry Dave but i can't let you do that."); return;}

            GlobalToolManager.DisabelTools();
            MapDataQuery.DeleteMapQuery();
            SessionManager.SessionManagerClearRefs();

            mapDataXCPIndex = mapIndex;

            mapDataFileName = XCPManager.currentXCP.xpcMaps[mapIndex].map;
            mapDataTileSize = 0.32f;
            ScenePrimer.curPrimerComponent.PrimerMapUpdate();
            UiManager.DestroyAllFocus();

            if (XCPManager.currentXCP.xpcMaps[mapDataXCPIndex] == null)
            {
                Debug.LogError("WOOOPSI");
            }
            MapDataCreateMapObj();
        }
Exemple #2
0
        public override void Click()
        {
            if (targetFeild0.text == "")
            {
                error0.SetActive(true);
                ok = false;
            }
            else
            {
                error0.SetActive(false);
                ok = true;
            }

            if (MapDataManager.IsValidPath(targetFeild1.text))
            {
                error1.SetActive(false);
                ok1 = true;
            }
            else
            {
                error1.SetActive(true);
                ok1 = false;
            }

            if (ok && ok1)
            {
                UiManager.DestroyAllFocus();
                Debug.LogError("NOT IMPLEMENTED!");
                //MapDataManager.MapDataOpenMap(targetFeild0.text, targetFeild1.text);
            }
        }
Exemple #3
0
 public override void Click()
 {
     if (optionData.itemPressMethod != null)
     {
         optionData.itemPressMethod(); UiManager.DestroyAllFocus(); return;
     }
     if (ACClick != null)
     {
         ACClick();
     }
     if (optionData.targetNewWindow != null)
     {
         if (!optionData.destroy)
         {
             UiManager.DestroyAllFocus();
         }
         if (optionData.hack)
         {
             WindowManager.CreateWindow(optionData.freeIndex, 300, optionData.targetNewWindow, true, optionData.skipInstanceRef);
         }
         else
         {
             WindowManager.CreateWindow(300, 300, optionData.targetNewWindow, true, optionData.skipInstanceRef);
         }
     }
     else
     {
     }
 }
        // Creates a empty map that is only stored in temp memory.
        public static void MapDataCreateEmptyMap(string mapName = "New Map")
        {
            GlobalToolManager.DisabelTools();
            MapDataQuery.DeleteMapQuery();
            SessionManager.SessionManagerClearRefs();

            if (XCPManager.currentXCP.xpcMaps == null)
            {
                XCPManager.currentXCP.xpcMaps    = new MapData[1];
                XCPManager.currentXCP.xpcMaps[0] = new MapData().CreateEmptyMapData(mapName, EditorPrimer.editorVersionNumberInternal, "Derelictus");
                mapDataXCPIndex = 0;
            }
            else
            {
                Array.Resize(ref XCPManager.currentXCP.xpcMaps, XCPManager.currentXCP.xpcMaps.Length + 1);
                XCPManager.currentXCP.xpcMaps[XCPManager.currentXCP.xpcMaps.Length - 1] = new MapData().CreateEmptyMapData(mapName, EditorPrimer.editorVersionNumberInternal, "Derelictus");;
                mapDataXCPIndex = XCPManager.currentXCP.xpcMaps.Length - 1;
            }
            mapDataFileName = mapName;
            mapDataTileSize = 0.32f;
            SessionManager.CreateMapLayer("Layer 0", true, true);
            ScenePrimer.curPrimerComponent.PrimerMapUpdate();
            UiManager.DestroyAllFocus();
            MapDataCreateMapObj();
        }
        public override void Click()
        {
            if (targetFeild0.text == "")
            {
                error0.SetActive(true);
                ok = false;
            }
            else
            {
                error0.SetActive(false);
                ok = true;
            }

            if (MapDataManager.IsValidPath(targetFeild1.text))
            {
                error1.SetActive(false);
                ok1 = true;
            }
            else
            {
                error1.SetActive(true);
                ok1 = false;
            }

            if (ok && ok1)
            {
                MapDataManager.mapDataFileName = targetFeild0.text;
                if (MapDataManager.MapDataExportToFile(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex], targetFeild1.text, targetFeild0.text + ".berrymap"))
                {
                    UiManager.DestroyAllFocus();
                }
            }
        }
Exemple #6
0
 public override void WindowCreate(int sizeX, int sizeY, GameObject windowRef)
 {
     if (ScenePrimer.curGamePrimer != null)
     {
         GameObject.Destroy(ScenePrimer.curGamePrimer.primerParrentObj);
         ScenePrimer.curGamePrimer = null;
     }
     UiManager.DestroyAllFocus();
 }
Exemple #7
0
        public override void ToolActivation()
        {
            UiManager.DestroyAllFocus();
            BPlacerTool toolWindowType = new BPlacerTool();

            toolWindowType.targetTool = this;
            toolWindow = WindowManager.CreateWindow(200, 100, toolWindowType, true, true);
            if (toolActiveSetterIcon != null)
            {
            }
            GlobalToolManager.globalToolManager.ToolSelectorDeactivate();
            curTileSelector.tileSelectionEnabled = false;
            tileSize = MapDataManager.mapDataTileSize;

            Icon = EditorPrimer.SpawnIconRenderer;
            Icon.transform.position  = MapDataConverter.V3ToVector3(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].layerSpawn);
            Icon.transform.position += new Vector3(0, 0.4f, 0);
            usesDrag = true;
        }
 public void OpenMap()
 {
     UiManager.DestroyAllFocus();
     MapDataManager.MapDataOpenXCPMap(selectedItem.itemTarget.index);
     if (ScenePrimer.curEditorPrimer != null)
     {
         if (!ScenePrimer.curEditorPrimer.editorCreated)
         {
             ScenePrimer.curEditorPrimer.PrimerInitialize();
         }
         else
         {
             ScenePrimer.curPrimerComponent.PrimerCreateCamera();
         }
     }
     else
     {
         ScenePrimer.curSceneprimer.PrimerStartEditor();
     }
 }
Exemple #9
0
 public override void Click()
 {
     if (targetField.text == "")
     {
         Error.SetActive(true);
     }
     else
     {
         // Clear the passed prewive game
         if (ScenePrimer.curGamePrimer != null)
         {
             if (ScenePrimer.curGamePrimer.primerParrentObj != null)
             {
                 GameObject.Destroy(ScenePrimer.curGamePrimer.primerParrentObj);
                 ScenePrimer.curGamePrimer = null;
             }
             ScenePrimer.curGamePrimer = null;
         }
         UiManager.DestroyAllFocus();
         MapDataManager.MapDataCreateEmptyMap(targetField.text);
         if (ScenePrimer.curEditorPrimer != null)
         {
             if (!ScenePrimer.curEditorPrimer.editorCreated)
             {
                 ScenePrimer.curEditorPrimer.PrimerInitialize();
             }
             else
             {
                 ScenePrimer.curPrimerComponent.PrimerCreateCamera();
             }
         }
         else
         {
             ScenePrimer.curSceneprimer.PrimerStartEditor();
         }
     }
 }
Exemple #10
0
 public override void WindowCreate(int sizeX, int sizeY, GameObject windowRef)
 {
     SessionManager.CreateMapLayer("Layer " + XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers.Length, false, false);
     SessionManager.CreateNewMapLayerObject(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers.Length - 1);
     UiManager.DestroyAllFocus();
 }
        // Move key cheking to a diffrent class.
        public void Update()
        {
            // This is a great way to get some extra performance!
            if (Input.anyKeyDown)
            {
                if (Input.GetKeyDown(KeyCode.N) && editorCreated)
                {
                    if (previewMode)
                    {
                        previewMode  = false;
                        disableInput = false;
                        EditorPrimer.SpawnIcon.SetActive(true);
                        ScenePrimer.curSceneprimer.PrimerSwitchMode(ScenePrimer.PrimerStartModes.editor, false);
                    }
                    else
                    {
                        UiManager.DestroyAllFocus();
                        previewMode  = true;
                        disableInput = true;
                        spriteIcon.gameObject.SetActive(false);
                        EditorPrimer.SpawnIcon.SetActive(false);
                        ScenePrimer.curSceneprimer.PrimerSwitchMode(ScenePrimer.PrimerStartModes.game, false);
                    }
                }

                if (!previewMode && editorCreated && !disableInput)
                {
                    if (Input.GetKeyDown(KeyCode.KeypadPlus) || Input.GetKeyDown(KeyCode.Plus))
                    {
                        if (spriteMode)
                        {
                            UpdateLayer(curSortingLayer + 1);
                        }
                        else
                        {
                            UpdateLayer(curLayer + 1);
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.KeypadMinus) || Input.GetKeyDown(KeyCode.Minus))
                    {
                        if (spriteMode)
                        {
                            UpdateLayer(curSortingLayer - 1);
                        }
                        else
                        {
                            if (curLayer != 0)
                            {
                                UpdateLayer(curLayer - 1);
                            }
                        }
                    }

                    if (Input.GetKeyDown(KeyCode.E))
                    {
                        if (editorGridObj != null)
                        {
                            if (editorGridObj.activeInHierarchy)
                            {
                                editorGridObj.SetActive(false);
                            }
                            else
                            {
                                editorGridObj.SetActive(true);
                            }
                            if (worldGrid2D.activeInHierarchy)
                            {
                                worldGrid2D.SetActive(false);
                            }
                            else
                            {
                                worldGrid2D.SetActive(true);
                            }
                            curGridBtn.IconUpdate();
                        }
                    }


                    if (Input.GetKeyDown(KeyCode.F7))
                    {
                        Screen.fullScreen = !Screen.fullScreen;
                    }

                    // re Do change.
                    if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Y))
                    {
                        if (!reDoKeyDown)
                        {
                            reDoKeyDown = true;
                            SystemHistory.HistoryReDo();
                        }
                    }
                    else
                    {
                        reDoKeyDown = false;
                    }

                    // LayerPanel
                    if (Input.GetKeyDown(KeyCode.A))
                    {
                        if (layerPanel == null)
                        {
                            usingPanel = true;
                            UiManager.DestroyAllFocus();
                            layerPanel = WindowManager.CreateWindow(0, 0, new BLayerPanel(), true, false, false);
                        }
                        else
                        {
                            usingPanel = false;
                            UiManager.DestroyAllFocus();
                            layerPanel = null;
                        }
                    }

                    // re Do change.
                    if (Input.GetKeyDown(KeyCode.D))
                    {
                        if (spritePanel == null)
                        {
                            usingPanel = true;
                            UiManager.DestroyAllFocus();
                            spritePanel = WindowManager.CreateWindow(0, 0, new BSpritePanel(), true, false, false);
                        }
                        else
                        {
                            usingPanel = false;
                            UiManager.DestroyAllFocus();
                            layerPanel = null;
                        }
                    }

                    // re Do change.
                    if (Input.GetKeyDown(KeyCode.S))
                    {
                        if (texturePanel == null)
                        {
                            usingPanel = true;
                            UiManager.DestroyAllFocus();
                            texturePanel = WindowManager.CreateWindow(0, 0, new BTexturePanel(), true, false, false);
                        }
                        else
                        {
                            usingPanel = false;
                            UiManager.DestroyAllFocus();
                            layerPanel = null;
                        }
                    }

                    if (Input.GetKeyDown(KeyCode.W))
                    {
                        if (entityPanel == null)
                        {
                            usingPanel = true;
                            UiManager.DestroyAllFocus();
                            entityPanel = WindowManager.CreateWindow(0, 0, new BEntityPanel(), true, false, false);
                        }
                        else
                        {
                            usingPanel = false;
                            UiManager.DestroyAllFocus();
                            layerPanel = null;
                        }
                    }

                    if (Input.GetKeyDown(KeyCode.X))
                    {
                        if (itemPanel == null)
                        {
                            usingPanel = true;
                            UiManager.DestroyAllFocus();
                            itemPanel = WindowManager.CreateWindow(0, 0, new BItemPanel(), true, false, false);
                        }
                        else
                        {
                            usingPanel = false;
                            UiManager.DestroyAllFocus();
                            layerPanel = null;
                        }
                    }

                    // Undo change.
                    if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.Z))
                    {
                        if (!undoKeyDown)
                        {
                            undoKeyDown = true;
                            SystemHistory.HistoryUndo();
                        }
                    }
                    else
                    {
                        undoKeyDown = false;
                    }

                    // Save map key
                    if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.S))
                    {
                        if (!saveKeyDown)
                        {
                            if (saveMapMenu == null)
                            {
                                if (MapDataManager.mapDataFilePath != "")
                                {
                                    saveKeyDown = true;
                                    BerryWindow targetWindow = new BMapSave();
                                    saveMapMenu = WindowManager.CreateWindow(300, 300, targetWindow);
                                }
                            }
                        }
                    }
                    else
                    {
                        saveKeyDown = false;
                    }

                    // Toggel Resource View
                    if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.T))
                    {
                        if (!resKeyDown)
                        {
                            resKeyDown = true;
                            //curResourceView.Click();
                        }
                    }
                    else
                    {
                        resKeyDown = false;
                    }

                    // Camera pos reset
                    // TODO : Fix so that we disable the rigidbody before the teleport to origin, and update the grids pos (Unity's physics system apparently don't like sudden teleports)
                    if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.R))
                    {
                        if (!cameraReset)
                        {
                            CameraManager.CurrentRenderCamera.transform.position = new Vector3(0, 2, 0);
                        }
                    }
                    else
                    {
                        cameraReset = false;
                    }
                }
            }
        }
 public override void WindowCreate(int sizeX, int sizeY, GameObject windowRef)
 {
     MapDataManager.SwitchLayer(sizeX, true);
     UiManager.DestroyAllFocus();
 }