private void FinaliseCombination(Slot current, Slot slot) { StopAllCoroutines(); string gemType = toolbox.FindGemType(current, slot); int index1, index2; index1 = current.index; index2 = slot.index; //SFX.Play("golem_created"); Debug.Log("Created Golem"); //Get the average quality of the shell and charged gem, assign to new golem. Quality.QualityGrade item1 = current.itemInstance.Quality; Quality.QualityGrade item2 = slot.itemInstance.Quality; Quality.QualityGrade avg = Quality.CalculateCombinedQuality(item1, item2); ItemInstance newGolem = new ItemInstance(gemType, 1, avg, true); string gem = (newGolem.item as Shonky).type.ToString(); int index = ShonkyInventory.Instance.InsertItem(newGolem); if (index != -1) { Quaternion rot = Quaternion.Euler(obj1Rotation); PenSlot pSlot = physicalShonkyInventory.GetSlotAtIndex(index); GameObject clone = Instantiate(newGolem.item.physicalRepresentation, desiredPosition.transform.position, rot); clone.GetComponent <ShonkyWander>().enabled = false; clone.GetComponent <NavMeshAgent>().enabled = false; clone.GetComponent <Rigidbody>().useGravity = false; Inventory.Instance.RemoveItem(index1); Inventory.Instance.RemoveItem(index2); //Move new golem to pen pSlot.SetItemInstantiated(newGolem, clone); toolbox.ClearGolemCreation(slot); StartCoroutine(ShowText(gem, avg, pSlot, clone)); } }
private void FinaliseCombination(Slot current, Slot slot) { StopAllCoroutines(); gemType = toolbox.FindGemType(current, slot); int index1, index2; index1 = current.index; index2 = slot.index; //SFX.Play("golem_created"); Debug.Log("Created Golem"); //Get the average quality of the shell and charged gem, assign to new golem. Quality.QualityGrade item1 = current.itemInstance.Quality; Quality.QualityGrade item2 = slot.itemInstance.Quality; Quality.QualityGrade avg = Quality.CalculateCombinedQuality(item1, item2); ItemInstance newGolem = new ItemInstance(gemType, 1, avg, true); string gem = (newGolem.item as Shonky).type.ToString(); int index = ShonkyInventory.Instance.InsertItem(newGolem); if (index != -1) { Quaternion rot = Quaternion.Euler(obj1Rotation); PenSlot pSlot = physicalShonkyInventory.GetSlotAtIndex(index); GameObject clone = Instantiate(newGolem.item.physicalRepresentation, desiredPosition.transform.position, rot); clone.GetComponent <ShonkyWander>().enabled = false; clone.GetComponent <NavMeshAgent>().enabled = false; clone.GetComponent <Rigidbody>().useGravity = false; Inventory.Instance.RemoveItem(index1); Inventory.Instance.RemoveItem(index2); //Reset Variables in toolbox and remove held references to deleted objects pSlot.SetItemInstantiated(newGolem, clone); toolbox.ClearGolemCreation(slot); //If a true golem, do narrative handling if (newGolem.Quality == Quality.QualityGrade.Mystic) { Debug.Log("gem type is " + gemType); // NOTE: gemType == "RubyGolem1", but GemStringToGolem checks for "ruby"? if (TrueGolems.PotentialUnlockTrueGolem(TrueGolems.GemStringToGolem(gemType))) { //Show relevant dialogue based on amount of true golems previously made List <TrueGolems.TrueGolem> golemsUnlocked = Inventory.Instance.GetUnlockedTrueGolems(); //Need to get boolean to handle if the narrative is not necessary. bool gizmo; switch (golemsUnlocked.Count) { case 0: gizmo = NarrativeManager.Read("true_golem_01"); break; case 1: gizmo = NarrativeManager.Read("true_golem_02"); break; case 2: gizmo = NarrativeManager.Read("true_golem_03"); break; case 3: gizmo = NarrativeManager.Read("true_golem_04"); break; default: gizmo = false; break; } Debug.Log("Gizmo is " + gizmo); if (!gizmo) { PopupTextManager.onClose += () => TransitionToHall(); //Instantiate glow on golem and make it dance glowObject = Instantiate(glowParticle, clone.transform); glowObject.transform.localPosition = new Vector3(0f, 0f, 0f); glowObject.transform.localScale = new Vector3(1f, 1f, 1f); clone.GetComponent <Animator>().Play("Dance"); //Remove golem from golem inventory as the player does not receive one when first creating a true golem ShonkyInventory.Instance.RemoveItem(index); } else { Inventory.Instance.UnlockTrueGolem(TrueGolems.GemStringToGolem(gemType)); StartCoroutine(ShowText(gem, avg, pSlot, clone)); } } else { StartCoroutine(ShowText(gem, avg, pSlot, clone)); } } else { StartCoroutine(ShowText(gem, avg, pSlot, clone)); } } }