Exemplo n.º 1
0
        public void AddPoint()
        {
            Vector3 pos = new Vector3(limit.offSet.x, height, limit.offSet.y);

            if (editZones[zoneNbr].points.Count > 0)
            {
                pos =
                    editZones[zoneNbr].points[editZones[zoneNbr].points.Count - 1].position
                    + new Vector3(
                        Mathf.Cos(editZones[zoneNbr].points.Count - 1) * Mathf.FloorToInt(editZones[zoneNbr].points.Count - 1 * 0.125f),
                        0,
                        Mathf.Sin(editZones[zoneNbr].points.Count - 1) * Mathf.FloorToInt(editZones[zoneNbr].points.Count - 1 * 0.125f)
                        ) * 4;
            }
            GameObject newPoint = Instantiate(pointTemplate, pos, Quaternion.identity, transform);

            newPoint.name = "Zone-" + zoneNbr + "_Point-" + editZones[zoneNbr].points.Count;
            newPoint.AddComponent(typeof(LinkedPoints));

            LinkedPoints lp = newPoint.GetComponent <LinkedPoints>();

            lp.lastPos      = newPoint.transform.position;
            lp.linkedPoints = new List <Transform>();
            lp.limit        = limit;
            editZones[zoneNbr].points.Add(newPoint.transform);
        }
Exemplo n.º 2
0
        public void AddPoint(int zone, Vector2 pos2D)
        {
            Vector3 pos = new Vector3(limit.offSet.x + pos2D.x, height, limit.offSet.y + pos2D.y);

            GameObject newPoint = Instantiate(pointTemplate, pos, Quaternion.identity, transform);

            newPoint.name = "Zone-" + zone + "_Point-" + editZones[zone].points.Count;
            newPoint.AddComponent(typeof(LinkedPoints));

            LinkedPoints lp = newPoint.GetComponent <LinkedPoints>();

            lp.lastPos      = newPoint.transform.position;
            lp.linkedPoints = new List <Transform>();
            lp.limit        = limit;
            editZones[zone].points.Add(newPoint.transform);
        }