public override void OnInspectorGUI() { if (!skin) { skin = Resources.Load("skin") as GUISkin; } GUI.skin = skin; CollectableMelee collectableWeapon = (CollectableMelee)target; GUILayout.BeginVertical("Collectable Weapon", "window"); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (collectableWeapon.gameObject.layer == 0) { EditorGUILayout.HelpBox("Please assign the Layer to Triggers", MessageType.Warning); } EditorGUILayout.BeginVertical(); base.OnInspectorGUI(); //EditorGUILayout.HelpBox("You can create weapon handles (empty gameobject) for each weapon inside the RightHand or LeftForeArm bones.", MessageType.Info); GUILayout.EndVertical(); EditorGUILayout.EndVertical(); }
public void SetWeaponHandler(CollectableMelee weapon) { print("MessageReceived"); if (!changeWeapon) { print("find handler"); changeWeapon = true; var handler = weaponHandlers.Find(h => h.name.Equals(weapon.handler)); if (handler) { DropWeapon(); print("Attaching"); weapon.transform.position = handler.position; weapon.transform.rotation = handler.rotation; weapon.transform.parent = handler; weapon.EnableMeleeWeapon(); SetMeleeWeapon(HumanBodyBones.RightHand); } else { Debug.LogWarning("Missing " + weapon.name + " handler, please create and assign one at the MeleeWeaponManager"); } } }
public void SetMeleeWeapon(HumanBodyBones bodyPart) { var part = GetComponent <Animator>().GetBoneTransform(bodyPart); if (part) { var meleeWeapon = part.GetComponentInChildren <MeleeWeapon>(); var collectWeapon = part.GetComponentInChildren <CollectableMelee>(); currentMeleeWeapon = meleeWeapon; currentCollectableWeapon = collectWeapon; if (currentMeleeWeapon) { } changeWeapon = false; } }
public void SetMeleeShield(HumanBodyBones bodyPart) { var part = GetComponent <Animator>().GetBoneTransform(bodyPart); if (part) { var meleeShield = part.GetComponentInChildren <MeleeShield>(); var collectShield = part.GetComponentInChildren <CollectableMelee>(); currentMeleeShield = meleeShield; currentCollectableShield = collectShield; if (currentMeleeShield) { currentMeleeShield.Init(); } changeWeapon = false; } }
public void SetShieldHandler(CollectableMelee shield) { if (!changeWeapon) { changeWeapon = true; var handler = weaponHandlers.Find(h => h.name.Equals(shield.handler)); if (handler) { DropShield(); shield.transform.position = handler.position; shield.transform.rotation = handler.rotation; shield.transform.parent = handler; shield.EnableMeleeItem(); SetMeleeShield(HumanBodyBones.LeftLowerArm); } else { Debug.LogWarning("Missing " + shield.name + " handler, please create and assign one at the MeleeWeaponManager"); } } }