Example #1
0
 private void ResizeHandle2_MouseDown(GUIItem item, int button, Vector2 position)
 {
     _IsResizing = true;
     dragStart   = new Vector2(position.x, position.y);
     sizeStart   = new Vector2(_Parent.Rect.width, _Parent.Rect.height);
     ModGUI.RegisterResize(this);
 }
Example #2
0
 private void _CloseBtn_Clicked(GUIItem item, int button, Vector2 position)
 {
     if (button == 0)
     {
         Close();
     }
 }
Example #3
0
        private void ImportBtn_Clicked(GUI.GUIItem item)
        {
            if (_GameStarted && _Manager != null)
            {
                MouseUI mouseUI = _Manager.GetComponent <MouseUI>();

                GameObject     tileMap        = mouseUI._ModGet_TileMap();
                Tiles          shipTiles      = tileMap.GetComponent <Tiles>();
                ManagerJobs    managerJobs    = _Manager.GetComponent <ManagerJobs>();
                ManagerMenu    managerMenu    = _Manager.GetComponent <ManagerMenu>();
                ManagerOptions managerOptions = _Manager.GetComponent <ManagerOptions>();

                if (shipTiles != null)
                {
                    String json = System.IO.File.ReadAllText(System.IO.Path.Combine(ModFolder, "Design.json"), Encoding.UTF8);

                    TileData[] tiles = Pathfinding.Serialization.JsonFx.JsonReader.Deserialize <TileData[]>(json);

                    List <TileData> hull     = new List <TileData>();
                    List <TileData> floor    = new List <TileData>();
                    TileData        shipCore = null;
                    List <TileData> other    = new List <TileData>();

                    foreach (TileData td in tiles)
                    {
                        List <TileData.Vec3> StructureParts = new List <TileData.Vec3>();
                        StructureParts.AddRange(td.StructureParts);
                        td.StructureParts = StructureParts;

                        if (td.TileType == "Hull" || td.TileType == "HullCorner")
                        {
                            hull.Add(td);
                        }
                        else if (td.TileType == "Floor")
                        {
                            floor.Add(td);
                        }
                        else if (td.TileType == "ShipCore")
                        {
                            shipCore = td;
                        }
                        else
                        {
                            other.Add(td);
                        }
                    }

                    if (shipCore == null)
                    {
                        throw new Exception("Ship Design is missing required tile ShipCore");
                    }

                    _IsImporting = true;
                    _Manager.GetComponent <ManagerMenu>().toggleMainMenu();
                    managerMenu.StartCoroutine(UpdateTiles(shipTiles, managerJobs, managerOptions, tileMap, hull, floor, shipCore, other));
                    managerMenu.StartCoroutine(OnImportFinished(tiles));
                }
            }
        }
        private void LoadBtn_Clicked(GUI.GUIItem item)
        {
            if (_SelectedScenario != null)
            {
                GameObject _Manager = GameObject.Find("Manager");

                _LoadingScenario = _SelectedScenario;

                _ScenarioWindow.Visible = false;
                mainMenuRight.SetActive(true);

                ManagerMenu.renameShipString = _SelectedScenario.Ship.Name;
                ManagerMenu.nextLevelToLoad  = 100;
                _Manager.GetComponent <ManagerOptions>().resetBoard();
            }
        }
Example #5
0
 private void ToggleModListBtn_Clicked(GUI.GUIItem item)
 {
     _ShowModList = !_ShowModList;
     if (_ShowModList)
     {
         foreach (GUI.Button modbtn in _ModListButtonArea.Items)
         {
             modbtn.Visible = true;
         }
     }
     else
     {
         foreach (GUI.GUIItem modbtn in _ModListButtonArea.Items)
         {
             if (modbtn != _ToggleModListBtn)
             {
                 modbtn.Visible = false;
             }
         }
     }
 }
        private void ScenarioBtn_Clicked(GUI.GUIItem item)
        {
            Scenario scenario = item.Tag as Scenario;

            _Name.Text = scenario.Name;
            _Desc.Text = scenario.Description;

            if (!String.IsNullOrEmpty(scenario.ThumbnailFile) && File.Exists(Path.Combine(scenario.ScenarioFolder, scenario.ThumbnailFile)))
            {
                Texture tex = LoadTexture(Path.Combine(scenario.ScenarioFolder, scenario.ThumbnailFile));
                if (tex != null)
                {
                    _ThumbNail.Visible = true;
                    _ThumbNail.Image   = tex;
                }
            }
            else
            {
                _ThumbNail.Visible = false;
            }

            _SelectedScenario     = scenario;
            _ScenarioInfo.Visible = true;
        }
Example #7
0
        private void ExportBtn_Clicked(GUI.GUIItem item)
        {
            if (_GameStarted && _Manager != null)
            {
                List <String> allowedTiles = new List <string>()
                {
                    "Hull",
                    "HullCorner",
                    "Floor"
                };

                GameObject tileMap    = GameObject.Find("TileMap");
                Tiles      shipTiles  = tileMap.GetComponent <Tiles>();
                Structures structures = tileMap.GetComponent <Structures>();
                if (shipTiles != null && structures != null)
                {
                    List <Vector2>  ignoreTileData = new List <Vector2>();
                    List <TileData> tiles          = new List <TileData>();

                    foreach (Vector2 pos in structures.structure[0].allTilesList)
                    {
                        TileInfo info = shipTiles.tiles[(int)pos.x, (int)pos.y];

                        if (ignoreTileData.Contains(pos))
                        {
                            if (!allowedTiles.Contains(info.structureType) && !allowedTiles.Contains(info.toBecome))
                            {
                                continue;
                            }
                        }

                        ignoreTileData.Add(pos);

                        List <TileData.Vec3> StructureParts = new List <TileData.Vec3>();
                        foreach (Vector3 vec in info.structureParts)
                        {
                            StructureParts.Add(TileData.Vec3.FromVector(vec));
                        }

                        TileData.TileRotation Rotation = TileData.TileRotation.UP;

                        if (info.structureParts.Count > 0)
                        {
                            Rotation = (TileData.TileRotation)(int) info.structureParts[0].z;
                        }

                        if (!String.IsNullOrEmpty(info.structureType))
                        {
                            TileData td2 = new TileData()
                            {
                                TileType       = info.structureType,
                                X              = (int)pos.x,
                                Y              = (int)pos.y,
                                Rotation       = Rotation,
                                StructureParts = Extensions.Copy <TileData.Vec3>(StructureParts)
                            };

                            tiles.Add(td2);
                            StructureParts.Clear(); //StructureParts mostly likely belongs to the structure, not the tile! --Need confirmation.
                        }

                        TileData td = new TileData()
                        {
                            TileType       = info.tileType,
                            X              = (int)pos.x,
                            Y              = (int)pos.y,
                            Rotation       = Rotation,
                            StructureParts = StructureParts
                        };

                        tiles.Add(td);
                    }

                    if (tiles.Count > 0)
                    {
                        String json = Pathfinding.Serialization.JsonFx.JsonWriter.Serialize(tiles.ToArray());
                        System.IO.File.WriteAllText(System.IO.Path.Combine(ModFolder, "Design.json"), json, Encoding.UTF8);
                    }
                }
            }
        }
Example #8
0
        private void ModBtn_Clicked(GUI.GUIItem item)
        {
            Mod M = item.Tag as Mod;

            M.ToggleModWindow();
        }
Example #9
0
 private void CloseDebugBtn_Clicked(GUI.GUIItem item)
 {
     _debugWindow.Visible = false;
 }
 private void CancelBtn_Clicked(GUI.GUIItem item)
 {
     _ScenarioWindow.Visible = false;
     mainMenuRight.SetActive(true);
 }
 private void _ScenarioWindow_WindowClosed(GUI.GUIItem item)
 {
     mainMenuRight.SetActive(true);
 }
Example #12
0
 private void ResizeHandle2_MouseUp(GUIItem item, int button, Vector2 position)
 {
     ResizeEnd(Event.current.mousePosition);
 }