示例#1
0
 public vHitInfo(vMeleeAttackObject attackObject, vHitBox hitBox, Collider targetCollider, Vector3 hitPoint)
 {
     this.attackObject   = attackObject;
     this.hitBox         = hitBox;
     this.targetCollider = targetCollider;
     this.hitPoint       = hitPoint;
 }
示例#2
0
        void CheckSingleHitBox(Transform transform, vHumanBones bodyPart, bool debug = false)
        {
            if (transform)
            {
                vMeleeAttackObject attackObject = transform.GetComponent <vMeleeAttackObject>();
                if (attackObject == null)
                {
                    attackObject = transform.gameObject.AddComponent <vMeleeAttackObject>();
                }

                var _hitBoxes     = transform.GetComponentsInChildren <vHitBox>();
                var validHitBoxes = _hitBoxes.vToList().FindAll(hitBox => hitBox.transform.parent == attackObject.transform);

                attackObject.hitBoxes = validHitBoxes;

                if (manager && manager.Members != null)
                {
                    var bodyMembers = manager.Members.FindAll(member => member.bodyPart == bodyPart.ToString());
                    if (bodyMembers.Count > 0)
                    {
                        bodyMembers[0].isHuman      = true;
                        bodyMembers[0].attackObject = attackObject;
                        bodyMembers[0].bodyPart     = bodyPart.ToString();
                        bodyMembers[0].transform    = transform;
                        if (bodyMembers.Count > 1)
                        {
                            for (int i = 1; i < bodyMembers.Count; i++)
                            {
                                manager.Members.Remove(bodyMembers[i]);
                            }
                        }
                        CheckHitBoxes(bodyMembers[0], true);
                        EditorUtility.SetDirty(manager);
                    }
                    else
                    {
                        vBodyMember bodyMember = new vBodyMember();
                        bodyMember.isHuman      = true;
                        bodyMember.attackObject = attackObject;
                        bodyMember.bodyPart     = bodyPart.ToString();
                        bodyMember.transform    = transform;
                        manager.Members.Add(bodyMember);
                        CheckHitBoxes(bodyMember, true);
                        EditorUtility.SetDirty(manager);
                    }
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
 void OnEnable()
 {
     attackObject = (vMeleeAttackObject)target;
     skin         = Resources.Load("skin") as GUISkin;
 }
示例#4
0
        void DrawHitBoxesList(vMeleeAttackObject attackObject)
        {
            if (attackObject != null && attackObject.hitBoxes != null)
            {
                for (int i = 0; i < attackObject.hitBoxes.Count; i++)
                {
                    try
                    {
                        GUILayout.BeginHorizontal();
                        if (attackObject.hitBoxes[i] != null && attackObject.hitBoxes[i].transform == attackObject.transform ||
                            (attackObject.GetComponent <vHitBox>() != null))
                        {
                            DestroyImmediate(attackObject.GetComponent <vHitBox>());
                            attackObject.hitBoxes.RemoveAt(i);
                            GUILayout.EndHorizontal();
                            break;
                        }
                        Color color = GUI.color;
                        GUI.color = seletedHitboxIndex == i ? new Color(1, 1, 0, 0.6f) : color;

                        if (GUILayout.Button("Hit Box " + (i + 1), EditorStyles.miniButton))
                        {
                            if (seletedHitboxIndex == i)
                            {
                                seletedHitboxIndex = -1;
                            }
                            else
                            {
                                seletedHitboxIndex = i;
                            }
                        }
                        GUI.color = color;
                        if (attackObject.hitBoxes.Count > 1 && GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)))
                        {
                            if (attackObject.hitBoxes[i] != null && attackObject.hitBoxes[i].transform != attackObject.transform)
                            {
                                DestroyImmediate(attackObject.hitBoxes[i].gameObject);
                            }
                            attackObject.hitBoxes.RemoveAt(i);
                            GUILayout.EndHorizontal();
                            break;
                        }
                        GUILayout.EndHorizontal();
                    }
                    catch { }
                }
            }

            if (seletedHitboxIndex > -1 && seletedHitboxIndex < attackObject.hitBoxes.Count)
            {
                GUILayout.BeginVertical("box");
                var hitBox = attackObject.hitBoxes[seletedHitboxIndex];
                if (hitBox)
                {
                    EditorGUILayout.ObjectField("Selected Hit Box " + (seletedHitboxIndex + 1), hitBox, typeof(vHitBox), true);
                    //GUILayout.Box("Hit Settings", GUILayout.ExpandWidth(true));
                    hitBox.damagePercentage = EditorGUILayout.IntSlider("Damage Percentage", hitBox.damagePercentage, 0, 100);
#if UNITY_2017_3_OR_NEWER
                    hitBox.triggerType = (vHitBoxType)EditorGUILayout.EnumFlagsField("Trigger Type", hitBox.triggerType);
#else
                    hitBox.triggerType = (vHitBoxType)EditorGUILayout.EnumMaskField("Trigger Type", hitBox.triggerType);
#endif
                    if (GUI.changed)
                    {
                        EditorUtility.SetDirty(hitBox);
                    }
                }
                GUILayout.EndVertical();
            }

            GUILayout.Space(10);

            if (!inCreateHitBox && GUILayout.Button("Create New Hit Box", EditorStyles.miniButton))
            {
                inCreateHitBox   = true;
                damagePercentage = 100;
                triggerType      = vHitBoxType.Damage | vHitBoxType.Recoil;
            }
            if (inCreateHitBox)
            {
                GUILayout.Box("New Hit Box", GUILayout.ExpandWidth(true));
                damagePercentage = EditorGUILayout.IntSlider("Damage Percentage", damagePercentage, 0, 100);

#if UNITY_2017_3_OR_NEWER
                triggerType = (vHitBoxType)EditorGUILayout.EnumFlagsField("Trigger Type", triggerType);
#else
                triggerType = (vHitBoxType)EditorGUILayout.EnumMaskField("Trigger Type", triggerType);
#endif

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Create", EditorStyles.miniButton, GUILayout.ExpandWidth(true)))
                {
                    var type      = typeof(BoxCollider);
                    var hitObject = new GameObject("hitBox", typeof(vHitBox), type);
                    hitObject.transform.localScale       = Vector3.one * 0.2f;
                    hitObject.transform.parent           = attackObject.transform;
                    hitObject.transform.localPosition    = Vector3.zero;
                    hitObject.transform.localEulerAngles = Vector3.zero;
                    var hitBox = hitObject.GetComponent <vHitBox>();
                    hitBox.damagePercentage = damagePercentage;
                    hitBox.triggerType      = triggerType;
                    attackObject.hitBoxes.Add(hitBox);
                    inCreateHitBox = false;
                }

                if (GUILayout.Button("Cancel", EditorStyles.miniButton, GUILayout.ExpandWidth(true)))
                {
                    inCreateHitBox = false;
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);
        }