Example #1
0
    public static PathDisplay getPathLine(Path path)
    {
        Debug.Log("drawPath numba J");
        //			Debug.Log("awkward length " + 	path.getPathLength());

        float usable_ap = mech.current_ap;
        float max_ap = mech.max_ap;

        if(path != null)
        {
            Vector3[] path_spots = new Vector3[path.getPathLength()];
            Color[] path_colors  = new Color[path_spots.Length-1];
            float[] path_widths   = new float[path_spots.Length-1];
            int i = 0;
            int this_turns_travelable = -1;

            List<VectorLine> spots = new List<VectorLine>();

            foreach(HexData path_pos in path.getTraverseOrderList())
            {
        //				path_spots[i] = Camera.mainCamera.WorldToScreenPoint((hexManagerS.CoordsGameTo3D(path_pos.x, path_pos.z)));

                path_spots[i] = ((hexManagerS.CoordsGameTo3D(path_pos.x, path_pos.z) + y_adj_line));

                if(i != 0)
                {
                    path_colors[i-1] = getColorFromCost(path_pos.traversal_cost);

                    usable_ap-=path_pos.traversal_cost;
                    if(usable_ap >= 0)
                    {
                        path_widths[i-1] = usable_ap/max_ap * max_path_width/2 + max_path_width/2;

                    }
                    else
                    {
                        usable_ap = 1;
                        if(this_turns_travelable == -1)
                            this_turns_travelable = i-1;
                        path_widths[i-1] = 2;
                        path_colors[i-1] = enginePlayerS.disable_color;

        //						break;
                    }

        //					var circle = new VectorLine("Circle", new Vector3[30], path_colors[i-1], null, 10F, LineType.Continuous, Joins.Weld);
        //					circle.MakeCircle(path_spots[i], Vector3.up, .3F);
        //					spots.Add(circle);
                    VectorLine outline = outlineHex(path_pos);
                    outline.SetColor(path_colors[i-1]);
                    outline.lineWidth = usable_ap/max_ap * max_path_width/2 + max_path_width/4;
                    spots.Add (outline);
                }

                Debug.Log(path_spots[i] + " | " + path_pos.traversal_cost);
                i++;
            }

            Array.Resize(ref path_spots, i+1);
            Array.Resize(ref path_colors, i);
            Array.Resize(ref path_widths, i);

        //			for(int vc = 0; vc < lineColors.Length; ++vc)
        //				lineColors[vc] = Color.red;
        ////				lineColors[vc] = new Color(UnityEngine.Random.Range(0,255), UnityEngine.Random.Range(0,255), UnityEngine.Random.Range(0,255));

        //			VectorLine.SetLine (Color.green, path_spots);
        //			VectorLine.Destroy(ref player_route);

            player_route = new VectorLine("Line", path_spots, path_colors, null, 5F, LineType.Continuous, Joins.Weld);
        //			player_route.MakeCircle(path_spots[3], Vector3.up, 2F, 10);
            player_route.SetColorsSmooth(path_colors);
            player_route.SetWidths(path_widths);
            player_route.MakeSpline(path_spots);
            player_route.smoothWidth = true;

        //			if(this_turns_travelable != -1)
        //			{
        //				var circle = new VectorLine("Circle", new Vector3[30], null, 10F, LineType.Continuous, Joins.Weld);
        //				circle.MakeCircle(path_spots[this_turns_travelable], Vector3.up, .3F);
        //
        //			}
        //

        //		VectorLine	rings = new VectorLine("Ring1", new Vector2[8], Color.white, null, 10F, LineType.Continuous);
        //
        //	       rings.MakeCircle(path_spots[3], Vector3.up, 8F);
        //	       rings.Draw3DAuto();

            return new PathDisplay(spots, player_route, new List<Color>(path_colors), new List<float>(path_widths));
        //			player_route.Draw3DAuto();
        }

        return null;
    }