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 ResBtn_Clicked(GUIItem item) { Button btn = item as Button; Group costGroup = btn.Tag as Group; String cost_name = costGroup.Tag as String; MouseUI mUI = _Manager.GetComponent <MouseUI>()._ModGet_Manager().GetComponent <MouseUI>(); EntityCost cost = Costs.GetEntityCost(cost_name); foreach (GUIItem costItem in costGroup.Items) { TextField txt = null; if (costItem is TextField) { txt = costItem as TextField; } else if (costItem is Group) { foreach (GUIItem gItem in ((Group)costItem).Items) { if (gItem is TextField) { txt = gItem as TextField; break; } } } if (txt != null) { String resource = txt.Tag as String; int val; if (int.TryParse(txt.Text, out val)) { Debug.Log("Setting " + resource + " of " + cost_name + " to " + val); cost.SetCost(resource, val); } else { txt.Text = cost.GetCost(resource).ToString(); Debug.Log("Failed to set " + resource + " of " + cost_name + ": Not a Number"); } } } Costs.SetEntityCost(cost); if (mUI != null) { mUI.updateBuildInfomation("ButtonBuild" + cost.Internal_Name); } ManagerResources res = _Manager.GetComponent <ManagerResources>(); if (res != null && res._ModGet_TileMap() != null) { res.updateResourcePanel(res._ModGet_TileMap()); } }
public void ClearMouseUI(MouseUI mouseUI, bool resetCursor) { if (resetCursor) { Cursor.SetCursor(null, Vector2.zero, mouseUI.cursorMode); } GameObject.Find("Mouse UI").GetComponent <Tilemap>().ClearAllTiles(); }
private void DrawSideAttackSuggestionsHover(Player player, Vector3 mousePos, MouseUI mouseUI) { var sideAttackPositions = _gameMap.GetValidSideAttackPositions(player, mousePos); foreach (var sideAttackPosition in sideAttackPositions) { PlaceTile(player, sideAttackPosition, mouseUI.thinkingAboutAttackingHereSideAttacks, "Mouse UI"); } }
/// <summary> /// Event handler for the "Toggle Debug Mode" button /// </summary> /// <param name="item"></param> private void _ToggleBtn_Clicked(StarshipTheory.ModLib.GUI.GUIItem item) { //Check if the manager isn't null (It might be null if the game is still loading) if (_Manager != null) { MouseUI UI = _Manager.GetComponent <MouseUI>(); ManagerOptions options = _Manager.GetComponent <ManagerOptions>(); //Make sure we have both components before proceeding. They might be null if we are still loading if (UI != null && options != null) { options.enableDebug = true; //Tricks the in-game code to think that we are in the debug mode. UI.toggleDebugPanel(); //Toggles the debug panel on or off. } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag.Equals("Player")) { PlayerMovement playerMovement = collision.GetComponent <PlayerMovement>(); if (playerMovement != null) { playerMovement.SetMouses(1); MouseUI mouseUI = GameObject.FindGameObjectWithTag("MouseUI").GetComponent <MouseUI>(); mouseUI.UpdateMouses(); Destroy(this.gameObject); } } }
void Start() { grid = GetComponent <Grid>(); mouseUI = FindObjectOfType <MouseUI>(); power = 0; cash = 999999; power += truckGeneratorPower; for (int i = 0; i < startingEquipment.Length; i++) { BuyEquipment(i, 0, startingEquipment[i]); } cash = startingCash; temperature = startingTemperature; lifetimeCash = startingCash; }
/// <summary> /// Metodo para cargar la partida /// </summary> public void LoadParty() { // Si existe el archivo if (File.Exists(Application.persistentDataPath + StringsType.FileStreamPath)) { // Se crea una nueva instancia de BinaryFormatter BinaryFormatter binaryFormatter = new BinaryFormatter(); // Se abre el archivo FileStream fileStream = File.Open(Application.persistentDataPath + StringsType.FileStreamPath, FileMode.Open); // Se deserializan las variables DataContainer dataContainer = (DataContainer)binaryFormatter.Deserialize(fileStream); // Se cierra el archivo fileStream.Close(); // Se ajustan las variables del Player a las que se guardaron _player.SetHealth(dataContainer.health); _player.SetPosition(dataContainer.posX, dataContainer.posY); _player.SetMouses(dataContainer.mouses); // Se revisa que el delegado no sea null if (ShowLifes != null) { // Ejecuta el evento de mostrar las vidas ShowLifes(); } // Se obtine el componente de MouseUI del gameobject MouseUI mouseUI = GameObject.FindGameObjectWithTag("MouseUI").GetComponent <MouseUI>(); // Se actualiza al cargar el texto de mouses mouseUI.mouseText.text = dataContainer.mouses.ToString(); } }
public void SetMouseUI(MouseUI mouseUIIn) { mouseUI = mouseUIIn; }
public void SetAttackCursor(MouseUI mouseUI) { Cursor.SetCursor(mouseUI.attackCursor, mouseUI.attackCursorHotSpot, mouseUI.cursorMode); }
public void Clear(MouseUI mouseUI) { ClearMouseUI(mouseUI, true); GameObject.Find("Suggestions").GetComponent <Tilemap>().ClearAllTiles(); }
public void SetDefaultCursor(MouseUI mouseUI) { Cursor.SetCursor(null, Vector2.zero, mouseUI.cursorMode); }