protected virtual IEnumerator HideWeaponAnimation() { WeaponID currentID = cacheKeyToID[currentWeaponKey]; Transform curTransform = cacheIDToTransform[currentID]; IWeaponAnimator currrentAnimator = null; if (curTransform != null) { currrentAnimator = curTransform.GetComponent <IWeaponAnimator>(); } else { hideWeaponAnimation = null; yield break; } if (currrentAnimator != null) { currrentAnimator.PutAway(); yield return(new WaitForSeconds(currrentAnimator.GetPutAwayTime())); } curTransform.gameObject.SetActive(false); hideWeaponAnimation = null; yield break; }
protected virtual IEnumerator SwitchWeaponAnimation(KeyCode targetWeaponKey) { if (currentWeaponKey != KeyCode.None) { WeaponID currentID = cacheKeyToID[currentWeaponKey]; Transform currentTransform = cacheIDToTransform[currentID]; IWeaponAnimator currrentAnimator = null; if (currentTransform != null) { currrentAnimator = currentTransform.GetComponent <IWeaponAnimator>(); } else { switchWeaponAnimation = null; yield break; } if (currrentAnimator != null) { currrentAnimator.PutAway(); yield return(new WaitForSeconds(currrentAnimator.GetPutAwayTime())); } currentTransform.gameObject.SetActive(false); currentWeaponKey = KeyCode.None; } WeaponID targetID = cacheKeyToID[targetWeaponKey]; if (targetID == null) { switchWeaponAnimation = null; yield break; } Transform targetTransform = cacheIDToTransform[targetID]; IWeaponAnimator targetAnimator = null; if (targetTransform != null) { targetAnimator = targetTransform.GetComponent <IWeaponAnimator>(); } else { switchWeaponAnimation = null; yield break; } targetTransform.gameObject.SetActive(true); if (targetAnimator != null) { yield return(new WaitForSeconds(targetAnimator.GetTakeTime())); } currentWeaponKey = targetWeaponKey; switchWeaponAnimation = null; yield break; }
protected virtual IEnumerator DropWeaponAnimation() { WeaponID currentID = cacheKeyToID[currentWeaponKey]; Transform curTransform = cacheIDToTransform[currentID]; DropProperties dropProperties = currentID.GetDropProperties(); IWeaponAnimator currrentAnimator = null; if (curTransform != null) { currrentAnimator = curTransform.GetComponent <IWeaponAnimator>(); } if (currrentAnimator != null) { currrentAnimator.PutAway(); yield return(new WaitForSeconds(currrentAnimator.GetPutAwayTime())); } curTransform.gameObject.SetActive(false); Remove(currentID); if (dropProperties != DropProperties.Empty) { Vector3 pos = _FPCamera.position + (_FPCamera.forward * dropProperties.GetDistance()); GameObject dropObject = Instantiate(dropProperties.GetDropObject(), pos, Quaternion.Euler(dropProperties.GetRotation())); if (dropObject != null) { Rigidbody rigidbody = dropObject.GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.AddForce(_FPCamera.forward * dropProperties.GetForce(), ForceMode.Impulse); } } } currentWeaponKey = KeyCode.None; dropWeaponAnimation = null; yield break; }
protected virtual IEnumerator ReplaceWeaponAnimation(WeaponID targetWeaponID) { if (currentWeaponKey != KeyCode.None) { WeaponID currentID = cacheKeyToID[currentWeaponKey]; Transform currentTransform = cacheIDToTransform[currentID]; DropProperties dropProperties = currentID.GetDropProperties(); IWeaponAnimator currrentAnimator = null; if (currentTransform != null) { currrentAnimator = currentTransform.GetComponent <IWeaponAnimator>(); } else { switchWeaponAnimation = null; yield break; } if (currrentAnimator != null) { currrentAnimator.PutAway(); yield return(new WaitForSeconds(currrentAnimator.GetPutAwayTime())); } if (dropProperties != DropProperties.Empty) { Vector3 pos = _FPCamera.position + (_FPCamera.forward * dropProperties.GetDistance()); GameObject dropObject = Instantiate(dropProperties.GetDropObject(), pos, Quaternion.Euler(dropProperties.GetRotation())); if (dropObject != null) { Rigidbody rigidbody = dropObject.GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.AddForce(_FPCamera.forward * dropProperties.GetForce(), ForceMode.Impulse); } } } currentTransform.gameObject.SetActive(false); currentWeaponKey = KeyCode.None; } Transform targetTransform = cacheIDToTransform[targetWeaponID]; IWeaponAnimator targetAnimator = null; if (targetTransform != null) { targetAnimator = targetTransform.GetComponent <IWeaponAnimator>(); } else { switchWeaponAnimation = null; yield break; } targetTransform.gameObject.SetActive(true); if (targetAnimator != null) { yield return(new WaitForSeconds(targetAnimator.GetTakeTime())); } List <InventorySlot> slots = cacheGroupToSlots[targetWeaponID.GetGroup()]; for (int i = 0, length = slots.Count; i < length; i++) { InventorySlot slot = slots[i]; if (slot.GetWeapon() == targetWeaponID) { currentWeaponKey = slot.GetKey(); break; } } switchWeaponAnimation = null; yield break; }
protected virtual IEnumerator SwitchWeaponAnimation(WeaponID targetWeaponID) { if (currentWeaponKey != KeyCode.None) { WeaponID currentID = cacheKeyToID[currentWeaponKey]; Transform currentTransform = cacheIDToTransform[currentID]; IWeaponAnimator currrentAnimator = null; if (currentTransform != null) { currrentAnimator = currentTransform.GetComponent <IWeaponAnimator>(); } else { switchWeaponAnimation = null; yield break; } if (currrentAnimator != null) { currrentAnimator.PutAway(); yield return(new WaitForSeconds(currrentAnimator.GetPutAwayTime())); } currentTransform.gameObject.SetActive(false); currentWeaponKey = KeyCode.None; } Transform targetTransform = cacheIDToTransform[targetWeaponID]; IWeaponAnimator targetAnimator = null; if (targetTransform != null) { targetAnimator = targetTransform.GetComponent <IWeaponAnimator>(); } else { switchWeaponAnimation = null; yield break; } targetTransform.gameObject.SetActive(true); if (targetAnimator != null) { yield return(new WaitForSeconds(targetAnimator.GetTakeTime())); } List <InventorySlot> slots = cacheGroupToSlots[targetWeaponID.GetGroup()]; for (int i = 0, length = slots.Count; i < length; i++) { InventorySlot slot = slots[i]; if (slot.GetWeapon() == targetWeaponID) { currentWeaponKey = slot.GetKey(); break; } } switchWeaponAnimation = null; yield break; }