Пример #1
0
    void Awake()
    {
        crouching = false;

        // take the collider and some useful values
        box             = GetComponent <ChipmunkBoxShape>();
        colliderCenterY = box.center.y;
        centerOffsetY   = ((1f - crouchColliderProportion) * 0.5f) * box.size.y;

        jump     = GetComponent <Jump>();
        sneak    = GetComponent <Sneak>();
        move     = GetComponent <WalkAbs>();
        crouchAC = AnimateTiledConfig.getByName(gameObject, EnumAnimateTiledName.Crouch, true);
    }
Пример #2
0
    // Use this for initialization
    void Awake()
    {
        hideAC = AnimateTiledConfig.getByName(gameObject, EnumAnimateTiledName.Hide, true);
        hidden = false;

        // take the collider and some useful values
        ChipmunkBoxShape[] boxes = GetComponents <ChipmunkBoxShape>();
        for (int i = 0, c = boxes.Length; i < c; ++i)
        {
            box = boxes[i];
            // the koopa has two chipmunk boxes, take the correct one
            if ("KoopaTroopa".Equals(box.collisionType))
            {
                break;
            }
        }
        colliderCenterY = box.center.y;
        centerOffsetY   = ((1f - hideColliderProportion) * 0.5f) * box.size.y;
    }
Пример #3
0
    protected void OnSceneGUI()
    {
        ChipmunkBoxShape box = target as ChipmunkBoxShape;

        if (box != null)
        {
            SetupUndo("edited ChipmunkBoxShape");
            Transform t = box.transform;

            Vector3 center = t.TransformPoint(box.center);

            Vector2 centerDelta = CircleHandle(center) - (Vector2)center;
            if (centerDelta != Vector2.zero)
            {
                box.center = t.InverseTransformPoint((Vector2)center + centerDelta);
                EditorUtility.SetDirty(target);
            }

            Vector3 extent      = t.TransformPoint(box.center + box.size / 2f);
            Vector2 extentDelta = (Vector2)(DotHandle(extent) - (Vector2)extent);
            if (extentDelta != Vector2.zero)
            {
                box.size = 2f * ((Vector2)t.InverseTransformPoint((Vector2)extent + extentDelta) - box.center);
                EditorUtility.SetDirty(target);
            }

            float radius = box.radius;
            if (radius > 0f)
            {
                float scaledRadius = radius * box._maxScale;
                float radiusDelta  = Handles.RadiusHandle(t.rotation, extent, scaledRadius, false) - scaledRadius;
                if (radiusDelta != 0f)
                {
                    box.radius = radius + radiusDelta / box._maxScale;
                    EditorUtility.SetDirty(target);
                }
            }
        }
    }