public static UnitAnimation MakeUnitAnimations(GameObject unit_mesh, WeaponMesh weapon, int index, AnimationCallbackCaster callbacks, GetBool b) { WeaponAnimator animator_right = new WeaponAnimator(weapon.AttachmentRight, weapon.FX_Right, weapon.MuzzleRight); WeaponAnimator animator_left = new WeaponAnimator(weapon.AttachmentLeft, weapon.FX_Left, weapon.MuzzleLeft); Animator unit_animator = unit_mesh.GetComponent <Animator>(); UnitAnimation_IdleController idle = unit_mesh.GetComponent <UnitAnimation_IdleController>(); return(new UnitAnimation().Init(unit_animator, animator_right, animator_left, index, callbacks, idle.GetId, b)); }
public static WeaponMesh SpawnWeaponMeshToUnit(GameObject unit_mesh, WeaponMesh weapon_mesh_prefab) { WeaponMesh weapon_mesh = Instantiate(weapon_mesh_prefab.gameObject).GetComponent <WeaponMesh>(); weapon_mesh.transform.SetParent(unit_mesh.transform); if (weapon_mesh.AttachmentLeft != null) { UnitMesh_Attachment.AttachToBone(unit_mesh, weapon_mesh.AttachmentLeft, AttachmentPoints.left_hand); } if (weapon_mesh.AttachmentRight != null) { UnitMesh_Attachment.AttachToBone(unit_mesh, weapon_mesh.AttachmentRight, AttachmentPoints.right_hand); } return(weapon_mesh); }
public void Init(WeaponMesh mesh) { if (current != null) { Destroy(current.AttachmentLeft); Destroy(current.AttachmentRight); Destroy(current.gameObject); } /* * if(m_Animator != null) * { * caster.OnAbilityTrigger -= m_Animator.AbilityCallback; * caster.OnWeaponHide -= m_Animator.WeaponHide; * caster.OnWeaponShow -= m_Animator.WeaponShow; * }*/ AnimationCallbackCaster caster = TargetUnit.GetComponent <AnimationCallbackCaster>(); current = UnitFactory.SpawnWeaponMeshToUnit(TargetUnit, mesh); // UnitAnimation_IdleController idle = mesh.GetComponent<UnitAnimation_IdleController>(); m_Animator = UnitFactory.MakeUnitAnimations(TargetUnit, current, current.WeaponIndex, caster, () => { return(IsRaged); }); }