예제 #1
0
    static void Push(CustomCollider a, CustomCollider b, FixedPointF offsetfac, CustomVector2 offsetvec, bool a_at_left)
    {
        FixedPointF fac = offsetfac;

        CustomVector3 offset_pos;

        offset_pos.x = fac * offsetvec.x;
        offset_pos.y = new FixedPointF(0);
        offset_pos.z = fac * offsetvec.y;

        //Actor actor = null;
        //bool actorisA = false;
        //if (a.mIsobstacle && !b.mIsobstacle)
        //    actor = b.GetComponentInParent<Actor>();
        //else if (!a.mIsobstacle && b.mIsobstacle)
        //{
        //    actor = a.GetComponentInParent<Actor>();
        //    actorisA = true;
        //}
        //if (actor != null)
        //{
        //    if (a_at_left == actorisA)
        //        actor.Position -= offset_pos;
        //    else
        //        actor.Position += offset_pos;
        //}

        if (!a.mIsobstacle && !b.mIsobstacle)
        {
            return;
        }

        if (a.mIsobstacle && !b.mIsobstacle)
        {
            if (a_at_left)
            {
                b.AddOffsetPosition(offset_pos);
            }
            else
            {
                b.AddOffsetPosition(-offset_pos);
            }
        }
        else if (!a.mIsobstacle && b.mIsobstacle)
        {
            if (a_at_left)
            {
                a.AddOffsetPosition(-offset_pos);
            }
            else
            {
                a.AddOffsetPosition(offset_pos);
            }
        }
    }