IEnumerator SpawnArrowInBow(RagdollHand ragdollHand, Handle handle) { yield return(new WaitForEndOfFrame()); Item bow = handle.item; BowString bowString = bow.GetCustomReference("StringHandle").gameObject.GetComponent <BowString>(); //Debug.Log("String grabbed"); if (bowString.nockedArrow == null && bowString.restedArrow == null && tryarrow) { tryarrow = false; //Debug.Log("No nocked arrow!"); ragdollHand.UnGrab(false); if (!SpellAbilityManager.HasEnoughHealth(2)) { yield break; } //Debug.Log("Yup enough health!"); Catalog.GetData <ItemData>("BloodArrow").SpawnAsync(delegate(Item arrow) { Handle l_ArrowHandle = arrow.handles.First(h => h.interactableId == "ObjectHandleArrowBack"); ragdollHand.Grab(l_ArrowHandle, true); bowString.NockArrow(l_ArrowHandle); SpellAbilityManager.SpendHealth(2); tryarrow = true; }, null, null, null, false, null); } }
IEnumerator SpawnBow() { bowSpawned = true; yield return(new WaitForSeconds(0.2f)); Catalog.GetData <ItemData>("BloodBow").SpawnAsync(delegate(Item bow) { Handle l_MainHandle = bow.handles.First(h => h.interactableId == "ObjectHandleBow"); spellCaster.ragdollHand.Grab(l_MainHandle, true); //Now in other hand spawn arrow and put in bow??? Catalog.GetData <ItemData>("BloodArrow").SpawnAsync(delegate(Item arrow) { BowString bowString = bow.GetCustomReference("StringHandle").gameObject.GetComponent <BowString>(); Handle l_ArrowHandle = arrow.handles.First(h => h.interactableId == "ObjectHandleArrowBack"); spellCaster.other.ragdollHand.Grab(l_ArrowHandle, true); spellCaster.other.spellInstance.Fire(false); (spellCaster.other.spellInstance as BloodSpell).currentCharge = 0; spellCaster.other.isFiring = false; bowString.NockArrow(l_ArrowHandle); Handle bowHandle = bow.handles.First(h => h.interactableId == "ObjectHandleBowString"); bowHandle.Grabbed += BowHandle_Grabbed; tryarrow = true; //bow.OnHeldActionEvent += Bow_OnHeldActionEvent; }, null, null, null, false, null); Fire(false); currentCharge = 0; spellCaster.isFiring = false; l_MainHandle.UnGrabbed += L_MainHandle_UnGrabbed;; }, spellCaster.magic.position, Quaternion.LookRotation(spellCaster.magic.up, spellCaster.magic.right), null, false, null); }