Exemplo n.º 1
0
    private void GoodsInWall(WallData wall, ref Vector3 world, ref float Angle)
    {
        float angle      = wall.GetWallAngle();
        float deltaAngle = angle - Angle;
        float xifudis    = targetSize.y / 2;
        int   times90    = (int)(deltaAngle / 90);

        if (times90 % 2 != 0)
        {
            times90 += 1;
        }
        deltaAngle = times90 * 90;
        float dis = xifudis + wall.width / 2;

        if (wall.GetDis(world) < dis)
        {
            Vector2 pos = wall.GetDisPoint(world);
            if (wallFunc.PointOnWall(pos, wall) || (wall.point1.pos - pos).magnitude < xifudis ||
                (wall.point2.pos - pos).magnitude < xifudis)
            {
                world = pos;
                if (targetWall == null)
                {
                    Vector3 eulerAngles = targetObj.transform.rotation.eulerAngles;
                    Angle         = angle - deltaAngle;
                    eulerAngles.z = Angle;
                    targetObj.transform.rotation = Quaternion.Euler(eulerAngles);
                    targetSize.y = wall.width;
                    targetObj.transform.localScale = targetSize;
                    targetWall = wall;
                }
            }
        }
    }
    /// <summary>
    /// 内嵌
    /// </summary>
    private void Inlay(ref Vector3 world, ref float Angle)
    {
        targetWall = null;
        Vector2 world2d = Vector2.zero;

        world2d.x = world.x;
        world2d.y = world.z;
        for (int i = 0; i < data.wallList.Count; i++)
        {
            WallData wall       = data.wallList[i];
            float    angle      = wall.GetWallAngle();
            float    deltaAngle = angle - (Angle - forTop);
            float    xifudis    = targetSize.z / 2;
            int      times90    = (int)(deltaAngle / 90);
            if (times90 % 2 != 0)
            {
                times90 += 1;
            }
            deltaAngle = times90 * 90;
            //int times180 = times90 / 2;
            float dis = xifudis + wall.width / 2;
            if (wall.GetDis(world2d) < dis)
            {
                Vector2 pos = wall.GetDisPoint(world2d);
                if (wallFunc.PointOnWall(pos, wall) || (wall.point1.pos - pos).magnitude < xifudis ||
                    (wall.point2.pos - pos).magnitude < xifudis)
                {
                    world.x = pos.x;
                    world.z = pos.y;
                    if (targetWall == null)
                    {
                        Vector3 eulerAngles = targetObj.transform.rotation.eulerAngles;
                        Angle         = angle - deltaAngle;
                        eulerAngles.y = -(Angle - forTop);
                        targetObj.transform.rotation = Quaternion.Euler(eulerAngles);
                        targetWall = wall;
                    }
                }
            }
        }
        if (targetWall != null)
        {
        }
    }
Exemplo n.º 3
0
    private float GoodsWallDis(WallData wall, Vector2 world, float Angle)
    {
        float angle      = wall.GetWallAngle();
        float deltaAngle = angle - Angle;
        float xifudis    = targetSize.y / 2;
        int   times45    = (int)(deltaAngle / 45);

        if (times45 % 2 != 0)
        {
            times45 += 1;
        }
        deltaAngle = times45 * 45;
        int times90 = times45 / 2;

        if (times90 % 2 != 0)
        {
            xifudis = targetSize.x / 2;
        }
        float dis     = xifudis + wall.width / 2;
        float walldis = wall.GetDis(world);

        if (walldis < dis)
        {
            Vector2 pos = wall.GetDisPoint(world);
            if (wallFunc.PointOnWall(pos, wall)
                //|| (wall.point1.pos - pos).magnitude < xifudis
                //|| (wall.point2.pos - pos).magnitude < xifudis
                )
            {
                return(Mathf.Abs(walldis - dis));
                //world = wall.GetDisPoint(world, dis);
                //if (targetWall == null)
                //{
                //    Vector3 eulerAngles = targetObj.transform.rotation.eulerAngles;
                //    Angle = angle - deltaAngle;
                //    eulerAngles.z = Angle;
                //    targetObj.transform.rotation = Quaternion.Euler(eulerAngles);
                //    targetWall = wall;
                //}
            }
        }
        return(float.MaxValue);
    }
Exemplo n.º 4
0
    private void GoodsInWall(WallData wall, ref Vector3 world, ref float Angle)
    {
        float angle      = wall.GetWallAngle();
        float deltaAngle = angle - Angle;
        float xifudis    = targetSize.y / 2;
        int   times90    = (int)(deltaAngle / 90);

        if (times90 % 2 != 0)
        {
            times90 += 1;
        }
        deltaAngle = times90 * 90;
        //int times180 = times90 / 2;
        float dis = xifudis + wall.width / 2;

        if (wall.GetDis(world) < dis)
        {
            Vector2 pos = wall.GetDisPoint(world);
            if (wallFunc.PointOnWall(pos, wall) || (wall.point1.pos - pos).magnitude < xifudis ||
                (wall.point2.pos - pos).magnitude < xifudis)
            {
                world = pos;//wall.GetDisPoint(world, dis);
                if (targetWall == null)
                {
                    //int intvalue = deltaAngle >= 0 ? 1 : -1;
                    //times45 += bool2 == true ? 0 : intvalue;
                    Vector3 eulerAngles = targetObj.transform.rotation.eulerAngles;
                    Angle         = angle - deltaAngle;//times45 * 45f;
                    eulerAngles.z = Angle;
                    //Debug.LogWarning(eulerAngles);
                    targetObj.transform.rotation = Quaternion.Euler(eulerAngles);
                    targetSize.y = wall.width;
                    targetObj.transform.localScale = targetSize;
                    targetWall = wall;
                }
            }
        }
    }
Exemplo n.º 5
0
    private void GoodsOnWall(WallData wall, ref Vector3 world, ref float Angle)
    {
        float angle      = wall.GetWallAngle();
        float deltaAngle = angle - Angle;
        float xifudis    = targetSize.y / 2;
        int   times45    = (int)(deltaAngle / 45);

        if (times45 % 2 != 0)
        {
            times45 += 1;
        }
        deltaAngle = times45 * 45;
        int times90 = times45 / 2;

        if (times90 % 2 != 0)
        {
            xifudis = targetSize.x / 2;
        }
        float dis = xifudis + wall.width / 2;

        if (wall.GetDis(world) < dis)
        {
            Vector2 pos = wall.GetDisPoint(world);
            if (wallFunc.PointOnWall(pos, wall) || (wall.point1.pos - pos).magnitude < xifudis ||
                (wall.point2.pos - pos).magnitude < xifudis)
            {
                world = wall.GetDisPoint(world, dis);
                //if (targetWall == null)
                //{
                Vector3 eulerAngles = targetObj.transform.rotation.eulerAngles;
                Angle         = angle - deltaAngle;
                eulerAngles.z = Angle;
                targetObj.transform.rotation = Quaternion.Euler(eulerAngles);
                //    targetWall = wall;
                //}
            }
        }
    }