Exemple #1
0
    private void UpdatePath()
    {
        for (int i = 0; i < path_points.Count; ++i)
        {
            PathPoint curr_point = path_points[i];

            curr_point.world_pos = transform.position;

            if (curr_point.entity.go != null)
            {
                curr_point.entity.go.transform.localScale = new Vector3(points_size, points_size, 1);
            }
        }

        for (int i = 0; i < path_point_conexions.Count; ++i)
        {
            PathPointConexions curr_con = path_point_conexions[i];

            if (curr_con.line != null)
            {
                PathPoint p1 = GetPathPointFromUid(curr_con.p1);
                PathPoint p2 = GetPathPointFromUid(curr_con.p2);

                Vector3 start_pos = new Vector3(p1.RealPos().x, p1.RealPos().y, 1);
                Vector3 end_pos   = new Vector3(p2.RealPos().x, p2.RealPos().y, 1);

                curr_con.line.SetPosition(0, start_pos);
                curr_con.line.SetPosition(1, end_pos);
            }
        }
    }
Exemple #2
0
    private void DebugDrawPath()
    {
        for (int i = 0; i < path_points.Count; ++i)
        {
            PathPoint curr_point = path_points[i];

            Vector3 p1 = new Vector3(curr_point.RealPos().x - (points_size * 0.5f), curr_point.RealPos().y + (points_size * 0.5f), transform.position.z);
            Vector3 p2 = new Vector3(curr_point.RealPos().x - (points_size * 0.5f), curr_point.RealPos().y - (points_size * 0.5f), transform.position.z);
            Vector3 p3 = new Vector3(curr_point.RealPos().x + (points_size * 0.5f), curr_point.RealPos().y - (points_size * 0.5f), transform.position.z);
            Vector3 p4 = new Vector3(curr_point.RealPos().x + (points_size * 0.5f), curr_point.RealPos().y + (points_size * 0.5f), transform.position.z);

            Color col = PathEntityDebugColorFromPathEntityType(curr_point.entity.type);

            Debug.DrawLine(p1, p2, col);
            Debug.DrawLine(p2, p3, col);
            Debug.DrawLine(p3, p4, col);
            Debug.DrawLine(p4, p1, col);

            for (int y = 0; y < path_point_conexions.Count; ++y)
            {
                PathPointConexions curr_con = path_point_conexions[y];

                PathPoint pp1 = GetPathPointFromUid(curr_con.p1);
                PathPoint pp2 = GetPathPointFromUid(curr_con.p2);

                if (pp1 != null && pp2 != null)
                {
                    Vector3 c1 = new Vector3(pp1.RealPos().x, pp1.RealPos().y, transform.position.z);
                    Vector3 c2 = new Vector3(pp2.RealPos().x, pp2.RealPos().y, transform.position.z);

                    Debug.DrawLine(c1, c2);
                }
            }
        }
    }
Exemple #3
0
    private void InitPath()
    {
        if (!inited)
        {
            for (int i = 0; i < path_points.Count; ++i)
            {
                PathPoint curr_tile = path_points[i];

                GameObject inst = InstantiateEntityGoFromPathEntityType(curr_tile.entity.type);

                if (inst != null)
                {
                    inst.name           = "Entity: " + i;
                    curr_tile.entity.go = inst;
                    curr_tile.entity.go.transform.position      = curr_tile.RealPos();
                    curr_tile.entity.go.transform.parent        = this.transform;
                    curr_tile.entity.go.transform.localRotation = Quaternion.Euler(0, 0, curr_tile.entity.start_rotation_angle);
                }
            }

            for (int i = 0; i < path_point_conexions.Count; ++i)
            {
                PathPointConexions curr_con = path_point_conexions[i];

                GameObject go_con = new GameObject();
                go_con.name             = "Connexion: " + i;
                go_con.transform.parent = this.transform;
                curr_con.line           = go_con.AddComponent <LineRenderer>();

                PathPoint p1 = GetPathPointFromUid(curr_con.p1);
                PathPoint p2 = GetPathPointFromUid(curr_con.p2);

                Vector3 start_pos = new Vector3(p1.RealPos().x, p1.RealPos().y, 1);
                Vector3 end_pos   = new Vector3(p2.RealPos().x, p2.RealPos().y, 1);

                curr_con.line.SetPosition(0, start_pos);
                curr_con.line.SetPosition(1, end_pos);

                curr_con.line.material       = LevelCreatorEditor.Instance.GetLineMaterial();
                curr_con.line.numCapVertices = 60;
                curr_con.line.startWidth     = 0.1f;
                curr_con.line.endWidth       = 0.1f;
            }

            UpdatePath();

            inited = true;
        }
    }