using System; using System.Collections; using System.Collections.Generic; using System.IO; using DarkTonic.MasterAudio; using PixelCrushers.DialogueSystem; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; // Token: 0x020000DA RID: 218 public class Spellcrafting : MonoBehaviour { // Token: 0x06001467 RID: 5223 RVA: 0x0018B29C File Offset: 0x0018949C private void Awake() { this.contents1.SetActive(false); this.anim.enabled = false; if (this.knowledgePrefab != null) { for (int i = 0; i < 20; i++) { this.AddPrefab(); } } this.allSpells.SetActive(false); this.deletePopup.SetActive(false); } // Token: 0x06001468 RID: 5224 RVA: 0x0018B2FA File Offset: 0x001894FA private void Start() { } // Token: 0x06001469 RID: 5225 RVA: 0x0018B2FC File Offset: 0x001894FC public void TurnOffMainCamera() { Links.x.worldCamera.cullingMask = 1; } // Token: 0x0600146A RID: 5226 RVA: 0x0018B30E File Offset: 0x0018950E public void TurnOnMainCamera() { Links.x.worldCamera.cullingMask = Links.x.mainCameraMask; } // Token: 0x0600146B RID: 5227 RVA: 0x0018B330 File Offset: 0x00189530 public void UpdateSlider() { GameObject currentEventObject = Links.x.gameplay.currentEventObject; if (currentEventObject) { float x = Links.x.fellowship.direction.x; Slider slider = null; if (currentEventObject == this.slider1.gameObject) { slider = this.slider1; } if (currentEventObject == this.slider2.gameObject) { slider = this.slider2; } if (currentEventObject == this.slider3.gameObject) { slider = this.slider3; } if (currentEventObject == this.tetherSlider.gameObject) { slider = this.tetherSlider; } float num = 1f; if (slider) { float num2 = 0.3f; if (Time.realtimeSinceStartup > this.lastSliderTime + num2 || this.lastSliderTime == 0f) { if (x > 0f) { slider.value += num; } else if (x < 0f) { slider.value -= num; } this.lastSliderTime = Time.realtimeSinceStartup; } } } } // Token: 0x0600146C RID: 5228 RVA: 0x0018B444 File Offset: 0x00189644 public void StartMenu(bool fromCC, Character startCharacter) { this.ccBlackOverlay.SetActive(false); this.cancelButton.SetActive(true); this.drawCursor.SetActive(false); Records.x.inMenus = true; if (this.spellLimitScreen.activeSelf) { this.spellLimitScreen.SetActive(false); } Records.x.SetTypingState(true); for (int i = 0; i < this.knowledgeTextUsed.Count; i++) { this.knowledgeTextOpen.Add(this.knowledgeTextUsed[i]); this.knowledgeOpen.Add(this.knowledgeUsed[i]); this.knowledgeUsed[i].SetActive(false); } this.drawing.ResetTexture(); this.knowledgeUsed.Clear(); this.knowledgeTextUsed.Clear(); this.resetButton.SetActive(Links.x.mk); this.anim.enabled = true; this.canvas.enabled = true; this.anim.Play("SpellsOpen"); Links.x.hudControl.ChangeHudVisibility(false, true); this.open = true; this.controllerMessage.enabled = false; this.runeFrame.enabled = Links.x.joy; this.contents1.SetActive(true); Records.x.AddMenu(base.gameObject); this.party = Links.x.portraitOrder; this.CloseAllSpells(); int num = 0; if (fromCC) { this.character = startCharacter; num = this.party.IndexOf(startCharacter); } else { this.character = this.party[0]; bool flag = false; for (int j = 0; j < this.party.Count; j++) { if (this.party[j] && !flag && !this.party[j].isBoro) { this.knowledge = this.party[j].stats.knowledge; if (this.knowledge.Count > 0) { flag = true; this.character = this.party[j]; num = j; } } } } for (int k = 0; k < this.party.Count; k++) { this.portraits[k].texture = this.party[k].characterSheetPortrait.GetTextureIdle(this.currIndex); if (this.character == this.party[k]) { this.portraitSelected[k].enabled = true; Color color = this.selectedPortraitColor; ColorBlock colors = this.portraitButtons[k].colors; colors.normalColor = color; this.portraitButtons[k].colors = colors; } else { this.portraitSelected[k].enabled = true; Color color2 = this.normalPortraitColor; ColorBlock colors2 = this.portraitButtons[k].colors; colors2.normalColor = color2; this.portraitButtons[k].colors = colors2; } } this.updateTime = 0f; this.ChangeCharacter(num); Links.x.fellowship.FreshBlinks(); this.controllerSwitchL.spriteAsset = Links.x.GetSpriteSheetAsset(Links.x.gameplay.currentSpriteSheetAsset); this.controllerSwitchR.spriteAsset = Links.x.GetSpriteSheetAsset(Links.x.gameplay.currentSpriteSheetAsset); this.controllerSwitchL.text = ""; this.controllerSwitchR.text = ""; this.controllerSwitchL.enabled = Links.x.joy; this.controllerSwitchR.enabled = Links.x.joy; Links.x.cameraEffects.ToggleObscurance(); } // Token: 0x0600146D RID: 5229 RVA: 0x0018B8A8 File Offset: 0x00189AA8 public void CheckIfAtSpellLimit() { if (this.character.stats.SpellCount() >= this.spellLimit) { this.spellLimitScreen.SetActive(true); this.book1.SetActive(false); this.book2.SetActive(true); this.SetInteractables(false); for (int i = 0; i < this.knowledgeUsed.Count; i++) { this.knowledgeTextUsed[i].color = this.textColorNormal; this.knowledgeUsed[i].gameObject.GetComponent().color = this.backColorNormal; this.knowledgeUsed[i].gameObject.transform.GetChild(1).gameObject.GetComponent().color = this.borderColorNormal; } return; } if (this.spellLimitScreen.activeSelf) { this.spellLimitScreen.SetActive(false); this.book1.SetActive(true); this.book2.SetActive(false); if (this.combinedKnowledge.Count > 0) { this.SetInteractables(true); this.SelectLearningButton(0); } } } // Token: 0x0600146E RID: 5230 RVA: 0x0018B9C8 File Offset: 0x00189BC8 private void Update() { if (this.open) { if (Time.realtimeSinceStartup > this.updateTime + 0.15f) { this.updateTime = Time.realtimeSinceStartup; this.currIndex = 0; for (int i = 0; i < this.party.Count; i++) { this.portraits[i].texture = this.party[i].characterSheetPortrait.GetTextureIdle(this.currIndex); } } if (this.combinedKnowledge.Count > 0) { this.SetCost(); this.SetDescription(); } if (!Records.x.paused) { Links.x.gameplay.TogglePause(true); } if (Links.x.inventory.gems >= this.SetCost()) { this.notEnoughMoney = false; } else { this.notEnoughMoney = true; } if (this.nameInput.text == "" || !this.hasDrawn || this.notEnoughMoney || this.uniqueNames.Contains(this.nameInput.text)) { if (this.combinedKnowledge.Count == 0) { this.button.interactable = false; this.buttonText.text = ""; } else { this.button.interactable = true; if (this.notEnoughMoney) { this.buttonText.text = "Not enough minerals"; } else if (!this.hasDrawn) { this.buttonText.text = "Missing Rune"; } else if (this.uniqueNames.Contains(this.nameInput.text)) { this.buttonText.text = "Name used"; } else { this.buttonText.text = "Missing Name"; } } } else if (this.combinedKnowledge.Count == 0) { this.button.interactable = false; } else { this.button.interactable = true; if (!this.character.stats.HasSpellName(this.nameInput.text)) { this.buttonText.text = "Create Spell"; } else { this.buttonText.text = "Duplicate Name"; } } if (Links.x.joy) { if (Links.x.gameplay.targetDodgeStart) { int num = this.party.IndexOf(this.character); int num2; if (num == 3) { num2 = 0; } else { num2 = num + 1; } if (num2 > -1 && num2 <= 3) { this.ChangeCharacter(num2); } } if (Links.x.gameplay.aimStart) { int num3 = this.party.IndexOf(this.character); int num4; if (num3 == 0) { num4 = 3; } else { num4 = num3 - 1; } if (num4 > -1 && num4 <= 3) { this.ChangeCharacter(num4); } } if (Links.x.gameplay.currentEventObject == this.runeRT.gameObject) { if (!this.drawingRune) { this.drawingRune = true; this.drawPosition = this.runeRT.anchoredPosition + new Vector2(200f, 200f); this.drawCursor.SetActive(true); this.str.Clear(); this.controllerMessage.spriteAsset = Links.x.GetSpriteSheetAsset(Links.x.gameplay.currentSpriteSheetAsset); int controllerSprite = Links.x.gameplay.GetControllerSprite("Show Items", Links.x.gameplay.controllerName); int controllerSprite2 = Links.x.gameplay.GetControllerSprite("Right Joystick", Links.x.gameplay.controllerName); int controllerSprite3 = Links.x.gameplay.GetControllerSprite("Attack", Links.x.gameplay.controllerName); int controllerSprite4 = Links.x.gameplay.GetControllerSprite("Interact", Links.x.gameplay.controllerName); this.str.Append("Draw Move Confirm Clear"); this.controllerMessage.text = this.str.ToString(); this.controllerMessage.enabled = true; } } else if (this.drawingRune) { this.drawingRune = false; this.drawCursor.SetActive(false); this.controllerMessage.enabled = false; } GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject; bool flag = false; if (currentSelectedGameObject == null) { flag = true; } if (!flag && !flag) { if (this.allSpells.activeSelf) { if (currentSelectedGameObject.transform.parent != this.contentPanel2.transform) { flag = true; } if (currentSelectedGameObject == this.lastSelected) { flag = true; } if (!flag) { this.selectedRectTransform = currentSelectedGameObject.GetComponent(); float num5 = Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) + this.selectedRectTransform.rect.height; float y = this.contentPanel2.anchoredPosition.y; float num6 = this.contentPanel2.anchoredPosition.y + this.scrollRectTransform2.rect.height; if (num5 > num6) { float num7 = num5 - this.scrollRectTransform2.rect.height + 90f; this.contentPanel2.anchoredPosition = new Vector2(this.contentPanel2.anchoredPosition.x, num7); } else if (Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) < y) { this.contentPanel2.anchoredPosition = new Vector2(this.contentPanel2.anchoredPosition.x, Mathf.Abs(this.selectedRectTransform.anchoredPosition.y)); } this.lastSelected = currentSelectedGameObject; } if (currentSelectedGameObject.name.Contains("Spell Song")) { Links.x.hudControl.JoyBounds(currentSelectedGameObject.GetComponent().rt, currentSelectedGameObject.GetComponent().boxOffset, false); } } else { if (currentSelectedGameObject.transform.parent != this.contentPanel.transform) { flag = true; } if (currentSelectedGameObject == this.lastSelected) { flag = true; } if (!flag) { this.selectedRectTransform = currentSelectedGameObject.GetComponent(); float num8 = Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) + this.selectedRectTransform.rect.height; float y2 = this.contentPanel.anchoredPosition.y; float height = this.scrollRectTransform.rect.height; float num9 = this.contentPanel.anchoredPosition.y + height; if (num8 > num9) { float num10 = num8 - height + 90f; this.contentPanel.anchoredPosition = new Vector2(this.contentPanel.anchoredPosition.x, num10); } else if (Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) < y2) { float num11 = 60f; this.contentPanel.anchoredPosition = new Vector2(this.contentPanel.anchoredPosition.x, Mathf.Abs(this.selectedRectTransform.anchoredPosition.y) - num11); } this.lastSelected = currentSelectedGameObject; } if (currentSelectedGameObject.name.Contains("Knowledge")) { Links.x.hudControl.JoyBounds(currentSelectedGameObject.GetComponent().rt, currentSelectedGameObject.GetComponent().boxOffset, false); } } } } if (Links.x.gameplay.currentEventObject == this.nameInput.gameObject && !Links.x.keyboardScript.gameObject.activeSelf) { if (Links.x.gameplay.actionStart) { Links.x.keyboardScript.StartMenu(this.nameInput, null, base.gameObject, "Spellcrafting"); this.canvasGroup.interactable = false; this.cancelButton.SetActive(false); } if ((Links.x.fellowship.move.y < -0.25f || Links.x.fellowship.move.y > 0.25f || Links.x.gameplay.party2Down || Links.x.gameplay.partyItems3Down || Links.x.gameplay.partyItems4Down) && this.controllerMoveOutOfInputField == null) { string text = "Down"; if (Links.x.fellowship.move.y > 0.25f) { text = "Up"; } this.controllerMoveOutOfInputField = this.FieldWait(text); base.StartCoroutine(this.controllerMoveOutOfInputField); } } if (this.drawingRune && Links.x.joy) { EventSystem.current.SetSelectedGameObject(this.runeRT.gameObject); if (Links.x.gameplay.itemsStart) { this.drawing.joystickPosition = this.drawPosition; this.drawing.OnBeginDrag(null); this.hasDrawn = true; } float num12 = Links.x.fellowship.direction.magnitude / 2f; Vector2 vector = new Vector3(Links.x.fellowship.direction.x, Links.x.fellowship.direction.y) * num12 * this.drawSpeed * Time.unscaledDeltaTime; bool flag2 = true; Vector2 vector2 = this.drawPosition + vector; Vector3 vector3 = this.WorldToUISpace(Links.x.menuCamera.WorldToScreenPoint(vector2)); Vector2 anchoredPosition = this.drawCursorRT.anchoredPosition; if (vector2.x >= this.bottomRight.anchoredPosition.x) { flag2 = false; } if (vector2.x <= this.bottomLeft.anchoredPosition.x) { flag2 = false; } if (vector2.y >= this.topRight.anchoredPosition.y) { flag2 = false; } if (vector2.y <= this.bottomRight.anchoredPosition.y) { flag2 = false; } if (flag2) { this.drawPosition += vector; this.drawCursorRT.anchoredPosition = vector3; } if (Links.x.gameplay.itemsDown && flag2) { float num13 = this.rectParent.anchoredPosition.x * -1f + vector3.x; float num14 = this.rectParent.anchoredPosition.y * -1f + vector3.y; this.drawing.joystickPosition = new Vector2(num13, num14); this.drawing.OnDrag(null); } if (Links.x.gameplay.itemsUp && Links.x.joy) { this.drawing.OnEndDrag(null); } if (Links.x.gameplay.interactStart) { this.ResetTex(); } if (Links.x.gameplay.actionStart) { if (Links.x.joy) { EventSystem.current.SetSelectedGameObject(this.nameInput.gameObject); } this.drawingRune = false; this.drawCursor.SetActive(false); this.controllerMessage.enabled = false; } } } } // Token: 0x0600146F RID: 5231 RVA: 0x0018C5B2 File Offset: 0x0018A7B2 private IEnumerator FieldWait(string dir) { yield return new WaitForSecondsRealtime(0.15f); if (dir == "Down" || dir == "Left") { EventSystem.current.SetSelectedGameObject(this.button.gameObject); } else { EventSystem.current.SetSelectedGameObject(this.runeRT.gameObject); } this.controllerMoveOutOfInputField = null; yield break; } // Token: 0x06001470 RID: 5232 RVA: 0x0018C5C8 File Offset: 0x0018A7C8 public Vector3 WorldToUISpace(Vector3 screenPos) { Vector2 vector; RectTransformUtility.ScreenPointToLocalPointInRectangle(this.canvas.transform as RectTransform, screenPos, this.canvas.worldCamera, out vector); return this.canvas.transform.TransformPoint(vector); } // Token: 0x06001471 RID: 5233 RVA: 0x0018C614 File Offset: 0x0018A814 public void Drawn() { if (!Links.x.joy) { this.hasDrawn = true; } } // Token: 0x06001472 RID: 5234 RVA: 0x0018C62C File Offset: 0x0018A82C public void Setup() { for (int i = 0; i < this.knowledgeTextUsed.Count; i++) { this.knowledgeTextOpen.Add(this.knowledgeTextUsed[i]); this.knowledgeOpen.Add(this.knowledgeUsed[i]); this.knowledgeUsed[i].SetActive(false); } this.knowledgeUsed.Clear(); this.knowledgeTextUsed.Clear(); if (!this.allSpells.activeSelf) { this.learningHeader.text = "Select Effect"; } this.allSpellsHeader.text = this.character.stats.GetName() + "'s Spells"; this.treeList = new string[0]; if (Links.x.diorama.sceneName == "C5_AbandonedFarm") { this.treeList = new string[] { "HealingSpores", "VinePrison", "VineCocoon", "SlipSlime", "SporeFloat", "PukeSpores", "VineWall", "LizardTrap", "FrogTrap" }; } if (Links.x.diorama.sceneName == "C6_FortenLazure") { this.treeList = new string[] { "CorpseNest", "SporeFloat", "SlipSlime", "AttractionSpores", "Entangle", "SilentMoss", "AcornMen", "VineWall", "RolyTrap", "FrogTrap", "VinePrison", "PukeSpores" }; } if (Links.x.diorama.sceneName == "C6_Cave" && QuestLog.GetQuestState("C6_DryadVolTree") == QuestState.Success) { this.treeList = new string[] { "JumpFrog" }; } if (Links.x.diorama.sceneName == "D6_Rozafir") { this.treeList = new string[] { "FindShroomer", "FindFish", "FindForest" }; } this.knowledge = this.character.stats.knowledge; this.combinedKnowledge.Clear(); int num = 0; foreach (string text in this.treeList) { if (!this.knowledge.Contains(text)) { this.combinedKnowledge.Add(text); num++; } } foreach (string text2 in this.knowledge) { this.combinedKnowledge.Add(text2); } int num2 = Links.x.inventory.PartyMineralCount(); this.partyMinerals.text = "Collected minerals: " + num2.ToString(); this.knowledgeHeader1.text = "Effects " + this.character.stats.GetName() + " can learn from tree"; this.knowledgeHeader2.text = this.character.stats.GetName() + "'s known effects"; int count = this.combinedKnowledge.Count; for (int k = count - 1; k >= 0; k--) { if (this.knowledgeOpen.Count == 0) { this.AddPrefab(); } GameObject gameObject = this.knowledgeOpen[0]; TextMeshProUGUI textMeshProUGUI = this.knowledgeTextOpen[0]; this.knowledgeOpen.RemoveAt(0); this.knowledgeTextOpen.RemoveAt(0); this.knowledgeUsed.Add(gameObject); this.knowledgeTextUsed.Add(textMeshProUGUI); gameObject.SetActive(true); Library.Pagan paganRow = Links.x.library.GetPaganRow(this.combinedKnowledge[k]); this.str.Clear(); this.str.Append(""); this.str.Append(paganRow._DisplayName); this.str.Append("\n"); this.str.Append(paganRow._School); this.str.Append(" Effect: "); this.str.Append(paganRow._Description); this.str.Append(""); textMeshProUGUI.text = this.str.ToString(); float preferredHeight = textMeshProUGUI.preferredHeight; textMeshProUGUI.rectTransform.sizeDelta = new Vector2(565f, preferredHeight + 30f); gameObject.GetComponent().sizeDelta = new Vector2(565f, preferredHeight + 30f); gameObject.GetComponent().id = k; if (k == count - 1) { } if (k < num) { gameObject.transform.GetChild(2).gameObject.SetActive(true); gameObject.transform.GetChild(2).GetChild(1).gameObject.GetComponent().text = "+" + paganRow._LearningCost.ToString(); } else { gameObject.transform.GetChild(2).gameObject.SetActive(false); } gameObject.transform.SetAsFirstSibling(); } this.forSaleHeader.SetAsFirstSibling(); this.learnedHeader.SetSiblingIndex(num + 1); if (this.combinedKnowledge.Count == 0) { this.SetInteractables(false); } else { this.SetInteractables(true); this.SelectLearningButton(0); } this.contentTr.gameObject.GetComponent().anchoredPosition3D = new Vector3(0f, 0f, 0f); } // Token: 0x06001473 RID: 5235 RVA: 0x0018CC28 File Offset: 0x0018AE28 public void UpdateKnowledgeOrder() { } // Token: 0x06001474 RID: 5236 RVA: 0x0018CC2C File Offset: 0x0018AE2C public Button GetFirstKnowledge() { Transform parent = this.forSaleHeader.parent; Button button = null; foreach (object obj in parent) { Transform transform = (Transform)obj; if (!button) { button = transform.gameObject.GetComponent