public void SaveQuadro() { QuadroData data = CreateQuadroData(); SaveGameSystem.SaveGame(data, "slot" + GlobalProfile.Slot + "_quadro"); GlobalProfile.getInstance().SaveGame(); }
public void SaveGame() { ScenarioData data = CreateScenarioData(); bool succ = SaveGameSystem.SaveGame(data, "slot" + GlobalProfile.Slot + "_" + GlobalProfile.GetCurrentSceneName()); GlobalProfile.getInstance().SaveGame(); }
public void LoadQuadroData(QuadroData data) { List <PistaFrame> frames = new List <PistaFrame>(); foreach (QuadroData.Item item in data.items) { InventoryItem inv = GlobalProfile.getInstance().GetItems(textureManager).Find(new System.Predicate <InventoryItem>((InventoryItem i) => { return(i.itemID == item.id); })); frames.Add(inventory.InsertPistaFrame(item.position, inv)); } foreach (QuadroData.Connection conn in data.connections) { GameObject lineConection = Instantiate(connectionPrefab); ItemConnection connection = lineConection.GetComponent <ItemConnection>(); connection.connectorSelector = connectionPanel; connection.objectA = frames[conn.itemA].outerPin; connection.objectB = frames[conn.itemB].outerPin; connection.isOnMouse = false; connection.menu = menu; connection.status = conn.status; connection.connector = conn.connectionName; lineConection.transform.SetParent(lineGroup.transform, false); } }
public void RefreshDialogData() { if (GlobalProfile.getInstance().HasReceivedMessage(data.unlockMessage)) { data.enabled = true; } }
public void ConfirmCheck() { checkSelection = false; labelCheck.SetActive(false); List <ItemConnection> conns = Object.FindObjectsOfType(typeof(ItemConnection)).Select((obj) => { return((ItemConnection)obj); }).TakeWhile((conn) => { return(conn.GetPistaA().selected&& conn.GetPistaB().selected); }).ToList(); foreach (PistaFrame pista in Object.FindObjectsOfType(typeof(PistaFrame))) { pista.selected = false; } //passa pro GetResponse List <SolutionScriptableObject.Solution> solutions = this.solution.GetResponse(conns); if (solutions.Count > 0) { SolutionScriptableObject.Solution solution = solutions[0]; //Da lista de soluções encontradas, procura a que tem mais conexões foreach (SolutionScriptableObject.Solution s in solutions) { if (s.conns.Length > solution.conns.Length) { solution = s; } } GlobalProfile.getInstance().dialogIgnition = solution.dialogo.ToList(); GlobalProfile.getInstance().SendMessage(solution.event_id); foreach (ItemConnection conn in conns) { foreach (SolutionScriptableObject.ConnStruct str in solution.conns) { if (CompareConnections(conn, str)) { conn.status = solution.correctness; } } } SaveQuadro(); fadeEffect.ExitScene(GlobalProfile.getInstance().lastScenarioBeforeInventory); } else { foreach (ItemConnection conn in conns) { PistaFrame pistaA = conn.objectA.GetComponent <PistaPin>().pista.transform.parent.GetComponent <PistaFrame>(); PistaFrame pistaB = conn.objectB.GetComponent <PistaPin>().pista.transform.parent.GetComponent <PistaFrame>(); Debug.Log("Pista 1: " + pistaA.item.itemID); Debug.Log("Pista 2: " + pistaB.item.itemID); Debug.Log("Conexão: " + conn.connector); } } }
public void RefreshDialogData() { foreach (Dialogo d in data.dialogos) { if (GlobalProfile.getInstance().HasReceivedMessage(d.unlock_message)) { d.enabled = true; } } }
public void Exit() { //TODO: Salva cenário if (data.enabled) { ScenarioData data = manager.CreateScenarioData(); bool succ = SaveGameSystem.SaveGame(data, "slot" + GlobalProfile.Slot + "_" + GlobalProfile.GetCurrentSceneName()); GlobalProfile.getInstance().SaveGame(); Cursor.SetCursor(null, hotSpot, cursorMode); manager.fadeEffect.ExitScene(this.data.exitPoint); } }
// Update is called once per frame void OnMouseDown() { if (lupa.pressed) { //Adicionar ao inventário //Abrir um texto GlobalProfile.getInstance().addItem(new InventoryItem(itemId, displayName, spriteRenderer.sprite)); //Destruir item speech.OpenText(texts); Destroy(gameObject); } }
// Update is called once per frame void OnMouseDown() { if (!PauseUI.Paused) { if (!speech.isActiveAndEnabled) { //Adicionar ao inventário //Abrir um texto GlobalProfile.getInstance().addItem(new InventoryItem(data.itemId, data.displayName, spriteRenderer.sprite, data.itemDescription)); //Destruir item Debug.Log("Adding item with sprite: " + spriteRenderer.sprite.texture.name); GlobalProfile.getInstance().SendMessage(data.itemId); GlobalProfile.getInstance().SaveInventory(); manager.RefreshAllCharacterDialogData(); speech.OpenText(data.dialogo.texts); Destroy(gameObject); } } }
void Start() { int ix = 0; int iy = 0; foreach (InventoryItem item in GlobalProfile.getInstance().GetItems()) { GameObject cellItem = new GameObject(); RectTransform rect = cellItem.AddComponent <RectTransform>(); Image img = cellItem.AddComponent <Image>(); img.preserveAspect = true; rect.pivot = new Vector2(0, 1); rect.anchorMin = new Vector2(0, 1); rect.anchorMax = new Vector2(0, 1); cellItem.transform.SetParent(gameObject.transform, true); cellItem.transform.localScale = new Vector3(1, 1, 1); cellItem.transform.position = new Vector3(0, 0, 0); cellItem.AddComponent <DragDrop>().itemSelected = itemSelected; cellItem.AddComponent <EventTrigger>(); rect.offsetMin = new Vector2(ix * cellWidth, -((iy + 1) * cellHeight)); rect.offsetMax = new Vector2((ix + 1) * cellWidth, -iy * cellHeight); img.sprite = item.image; ix++; if (ix > cols) { ix = 0; iy++; } } }
public void CloseDialog() { if (minimap) { minimap.SetActive(true); } if (texts == GlobalProfile.getInstance().dialogIgnition) { GlobalProfile.getInstance().dialogIgnition = null; fadeEffect.ExitScene(2); } else { gameObject.SetActive(false); personagens.SetActive(true); gui.SetActive(true); isTalking = false; Destroy(buttonCanvas); buttonCanvas = null; Cursor.SetCursor(null, hotSpot, CursorMode); } }
public void OpenCharacterDialog(SpeechableCharacter personagem) { GlobalProfile.getInstance().SaveGame(); Cursor.SetCursor(null, hotSpot, CursorMode); gameObject.SetActive(true); personagens.SetActive(false); gui.SetActive(false); if (!minimap) { minimap = GameObject.Find("MinimapCanvas"); } if (minimap) { minimap.SetActive(false); } characterImage.sprite = manager.textureManager.GetSpritePose(personagem.data.defaultImage); characterImage.color = new Color(1, 1, 1, 1); canvasText.text = ""; charName.text = "Detetive"; //Abre o menu de botões if (buttonCanvas == null) { //Cria o grupo de botões de perguntas buttonCanvas = new GameObject("Buttons Canvas"); RectTransform rect = buttonCanvas.AddComponent <RectTransform>(); rect.anchorMin = new Vector2(.5f, .5f); rect.anchorMax = new Vector2(.5f, .5f); List <Dialogo> digs = personagem.AvailableDialogs(); float margin = (digs.Count + 1) * 10; rect.offsetMin = new Vector2(-200, -15 * digs.Count - margin / 2f); rect.offsetMax = new Vector2(200, 15 * digs.Count + margin / 2f); for (int i = 0; i < digs.Count; i++) { //Cria cada botão Dialogo dig = digs[i]; GameObject btn = new GameObject("Button " + i); RectTransform btnRect = btn.AddComponent <RectTransform>(); btnRect.anchorMin = new Vector2(0, 1); btnRect.anchorMax = new Vector2(1, 1); btnRect.pivot = new Vector2(.5f, 1); btnRect.offsetMin = new Vector2(0, -40 - 40 * i); btnRect.offsetMax = new Vector2(0, -10 - 40 * i); Button btn_btn = btn.AddComponent <Button>(); Image img = btn.AddComponent <Image>(); img.color = dig.read ? Color.gray : Color.white; btn_btn.targetGraphic = img; img.sprite = buttonUp; img.type = Image.Type.Sliced; btn_btn.transition = Selectable.Transition.SpriteSwap; SpriteState ss = new SpriteState(); ss.pressedSprite = buttonDown; btn_btn.spriteState = ss; btn.transform.SetParent(buttonCanvas.transform, false); btn_btn.onClick.AddListener(() => { OpenText(dig.texts); GlobalProfile.getInstance().addItem( new InventoryItem( personagem.data.id, personagem.data.displayName, manager.textureManager.GetSpritePista(personagem.data.headBob), personagem.data.description )); dig.read = true; GlobalProfile.getInstance().SendMessage(dig.id); manager.RefreshAllCharacterDialogData(); }); //Cria o texto do botão GameObject btnText = new GameObject(); RectTransform txtRect = btnText.AddComponent <RectTransform>(); txtRect.anchorMin = new Vector2(0, 0); txtRect.anchorMax = new Vector2(1, 1); txtRect.offsetMin = new Vector2(0, 0); txtRect.offsetMax = new Vector2(0, 0); Text txt = btnText.AddComponent <Text>(); txt.alignment = TextAnchor.MiddleCenter; txt.text = dig.pergunta; txt.color = new Color(0, 0, 0); txt.font = font; btnText.transform.SetParent(btn.transform, false); } buttonCanvas.transform.SetParent(panelImage.gameObject.transform, false); } }
public void ClickOnInventory() { SaveGame(); GlobalProfile.getInstance().lastScenarioBeforeInventory = SceneManager.GetActiveScene().buildIndex; SceneManager.LoadScene(2); }
public void BackToGame() { SaveQuadro(); SceneManager.LoadScene(GlobalProfile.getInstance().lastScenarioBeforeInventory); }
// Start is called before the first frame update void Start() { string scenarioName = GlobalProfile.GetCurrentSceneName(); GlobalProfile.getInstance().LoadGame(textureManager); GlobalProfile.getInstance().addItem(new InventoryItem(cenario_pista, scenarioName, textureManager.GetSpritePista(cenario_pista), cenario_desc)); GlobalProfile.getInstance().SaveGame(); //Carrega dados do cenário if (SaveGameSystem.DoesSaveGameExist("slot" + GlobalProfile.Slot + "_" + scenarioName)) { scenarioData = (ScenarioData)SaveGameSystem.LoadGame("slot" + GlobalProfile.Slot + "_" + scenarioName); if (scenarioData != null) { //Limpando os personagens e instanciando de novo foreach (Transform child in personagens_folder.transform) { GameObject.Destroy(child.gameObject); } for (int i = 0; i < scenarioData.characters.Count; i++) { GameObject character = Instantiate(personagemPrefab); character.transform.SetParent(personagens_folder.transform, false); character.GetComponent <SpeechableCharacter>().LoadData(scenarioData.characters[i], speechManager, this); } //Limpando pistas e instanciando de novo foreach (Transform child in pistas_folder.transform) { GameObject.Destroy(child.gameObject); } for (int i = 0; i < scenarioData.pistas.Count; i++) { GameObject pista = Instantiate(pistaPrefab); pista.transform.SetParent(pistas_folder.transform, false); pista.GetComponent <PistaItem>().LoadData(scenarioData.pistas[i], speechManager, this); } //Limpando exits e instanciando de novo foreach (Transform child in exits_folder.transform) { GameObject.Destroy(child.gameObject); } for (int i = 0; i < scenarioData.exits.Count; i++) { GameObject exit = Instantiate(exitPrefab); exit.transform.SetParent(exits_folder.transform, false); exit.GetComponent <ExitPoint>().LoadData(scenarioData.exits[i], this, speechManager); } } } if (GlobalProfile.getInstance().dialogIgnition != null) { speechManager.OpenText(GlobalProfile.getInstance().dialogIgnition); } //string output = JsonUtility.ToJson(CreateScenarioData(),true); //Debug.Log(output); }
// Start is called before the first frame update void Start() { RectTransform rect = GetComponent <RectTransform>(); int cols = 4; float margin = 10; width = (rect.rect.width - (cols + 1) * margin) / cols; int x = 0; int y = 0; foreach (InventoryItem item in GlobalProfile.getInstance().GetItems(manager)) { //Criando o slot GameObject slot = new GameObject(item.itemID); RectTransform slotRect = slot.AddComponent <RectTransform>(); Image image = slot.AddComponent <Image>(); image.sprite = slotSprite; image.preserveAspect = true; slotRect.anchorMin = new Vector2(0, 1); slotRect.anchorMax = new Vector2(0, 1); slotRect.pivot = new Vector2(0, 1); slotRect.offsetMin = new Vector2(margin + x * (width + margin), -(margin + width) - y * (margin + width)); slotRect.offsetMax = new Vector2(margin + x * (width + margin) + width, -margin - y * (margin + width)); slot.transform.SetParent(content.transform, false); //Criando o item dentro do slot GameObject itemGO = new GameObject(item.displayName); itemGO.AddComponent <ItemSlot>().item = item; RectTransform itemRect = itemGO.AddComponent <RectTransform>(); Image itemImage = itemGO.AddComponent <Image>(); itemImage.preserveAspect = true; itemImage.sprite = item.image; itemRect.anchorMin = new Vector2(0, 0); itemRect.anchorMax = new Vector2(1, 1); itemRect.offsetMin = new Vector2(20, 20); itemRect.offsetMax = new Vector2(-20, -20); itemGO.transform.SetParent(slot.transform, false); EventTrigger trigger = itemGO.AddComponent <EventTrigger>(); //Drag begin EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.BeginDrag; entry.callback.AddListener(new UnityEngine.Events.UnityAction <BaseEventData>(BeginDrag)); trigger.triggers.Add(entry); //Drag entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.Drag; entry.callback.AddListener(new UnityEngine.Events.UnityAction <BaseEventData>(Drag)); trigger.triggers.Add(entry); //Drop entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.EndDrag; entry.callback.AddListener(new UnityEngine.Events.UnityAction <BaseEventData>(Drop)); trigger.triggers.Add(entry); x++; if (x == 4) { x = 0; y++; } } content.GetComponent <RectTransform>().offsetMin = new Vector2(0, -(margin + y * (width + margin) + margin)); }
public void ReturntoMenu() { GlobalProfile.getInstance().SaveGame(); SceneManager.LoadScene(1); }