Beispiel #1
0
 /// <summary>
 /// Callback to draw gizmos that are pickable and always drawn.
 /// </summary>
 void OnDrawGizmos()
 {
     if (EditorApplication.isPlayingOrWillChangePlaymode && !IsActive)
     {
         return;
     }
     Gizmos.color = HitboxUtil.GetHitboxColor(Type);
     Gizmos.DrawWireSphere(Center, Radius);
 }
Beispiel #2
0
 /// <summary>
 /// Callback to draw gizmos that are pickable and always drawn.
 /// </summary>
 void OnDrawGizmos()
 {
     if (isActiveAndEnabled)
     {
         using (GizmoUtil.With(HitboxUtil.GetHurtboxColor(Type))) {
             foreach (var collider in GetComponents <Collider>())
             {
                 if (!collider.enabled && collider.gameObject.activeInHierarchy)
                 {
                     continue;
                 }
                 GizmoUtil.DrawCollider(collider);
             }
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Callback to draw gizmos that are pickable and always drawn.
 /// </summary>
 void OnDrawGizmos()
 {
     if (EditorApplication.isPlayingOrWillChangePlaymode && !IsActive)
     {
         return;
     }
     Gizmos.color = HitboxUtil.GetHitboxColor(Type);
     if (oldCenter_.HasValue)
     {
         GizmoUtil.DrawCapsule(Center, oldCenter_.Value, Radius);
     }
     else
     {
         Gizmos.DrawWireSphere(Center, Radius);
     }
 }
Beispiel #4
0
        public int GetCollidedHurtboxes(Hurtbox[] hurtboxes)
        {
            HitboxUtil.FlushHurtboxDedupCache();
            var arrayPool     = ArrayPool <Collider> .Shared;
            var colliders     = arrayPool.Rent(hurtboxes.Length);
            var colliderCount = FullCollisionCheck(colliders);
            int hurtboxCount  = 0;

            for (int i = 0; i < colliderCount && hurtboxCount < hurtboxes.Length; i++)
            {
                if (colliders[i] == null)
                {
                    continue;
                }
                var hurtbox = colliders[i].GetComponent <Hurtbox>();
                if (HitboxUtil.IsValidHurtbox(hurtbox))
                {
                    hurtboxes[hurtboxCount++] = hurtbox;
                }
            }
            arrayPool.Return(colliders);
            return(hurtboxCount);
        }
Beispiel #5
0
        void BuildTable()
        {
            table = new EditorTable <SerializedObject>();

            table.OnDrawRowStart += (rect, element) => {
                var gameObj = (element.targetObject as Component).gameObject;
                if (!Selection.gameObjects.Contains(gameObj))
                {
                    return;
                }
                var color = GUI.backgroundColor;
                GUI.backgroundColor = Color.blue;
                GUI.Box(rect, GUIContent.none);
                GUI.backgroundColor = color;
            };

            var enabledCol = CreatePropertyColumn("m_Enabled", false);
            var nameCol    = table.AddColumn((rect, serializedObject) => {
                var target = serializedObject.targetObject as Component;
                EditorGUI.LabelField(rect, target.name);
                var evt     = Event.current;
                var gameObj = target.gameObject;
                if (evt.type != EventType.MouseUp || !rect.Contains(evt.mousePosition))
                {
                    return;
                }
                if ((evt.modifiers & EventModifiers.Control) != 0)
                {
                    if (Selection.gameObjects.Contains(gameObj))
                    {
                        return;
                    }
                    var temp = new List <Object>(Selection.gameObjects);
                    temp.Add(gameObj);
                    Selection.objects = temp.ToArray();
                }
                else
                {
                    Selection.activeGameObject = gameObj;
                }
            });
            var typeCol = table.AddColumn((rect, serializedObject) => {
                var color   = GUI.color;
                var hitbox  = serializedObject.targetObject as Hitbox;
                var hurtbox = serializedObject.targetObject as Hurtbox;
                if (hitbox != null)
                {
                    GUI.color = HitboxUtil.GetHitboxColor(hitbox.Type);
                }
                if (hurtbox != null)
                {
                    GUI.color = HitboxUtil.GetHurtboxColor(hurtbox.Type);
                }
                EditorGUI.PropertyField(rect, serializedObject.FindProperty("Type"), GUIContent.none);
                GUI.color = color;
            });
            var priorityCol         = CreatePropertyColumn("Priority");
            var damageCol           = CreatePropertyColumn("BaseDamage");
            var baseKnockbackCol    = CreatePropertyColumn("BaseKnockback");
            var knockbackScalingCol = CreatePropertyColumn("KnockbackScaling");
            var angleCol            = CreatePropertyColumn("KnockbackAngle");

            table.Padding             = new Vector2(5f, 2f);
            table.LabelStyle          = EditorStyles.toolbar;
            table.LabelPadding        = 2.5f;
            enabledCol.Name           = "";
            enabledCol.Width          = 0.01f;
            nameCol.Name              = "Hitbox";
            nameCol.Width             = 0.19f;
            typeCol.Name              = "Type";
            typeCol.Width             = 0.1f;
            damageCol.Name            = "Damage";
            damageCol.Width           = 0.1f;
            baseKnockbackCol.Name     = "Knockback";
            baseKnockbackCol.Width    = 0.1f;
            knockbackScalingCol.Name  = "Scaling";
            knockbackScalingCol.Width = 0.1f;
            priorityCol.Name          = "Priority";
            priorityCol.Width         = 0.1f;
            angleCol.Name             = "Angle";
            angleCol.Width            = 0.2f;
        }