Esempio n. 1
0
        // add a new point after a path point
        public GameObject InsertPoint(PathPoint lastPathPoint)
        {
            GameObject pointGO = new GameObject();

            pointGO.name             = "Path Point";
            pointGO.transform.parent = gameObject.transform;

            PathPoint newPathPoint = pointGO.AddComponent <PathPoint>();

            newPathPoint.pointController = this;

            // set wait and rotation to 0.0
            newPathPoint.rotation = 0.0f;
            newPathPoint.wait     = 0.0f;

            if (listPoints == null)
            {
                listPoints = new List <PathPoint>();
            }

            //check if last path point exists
            if (listPoints.Contains(lastPathPoint))
            {
                newPathPoint.position      = lastPathPoint.gameObject.transform.position;
                pointGO.transform.position = newPathPoint.position;
                int index = listPoints.IndexOf(lastPathPoint);
                listPoints.Insert(index + 1, newPathPoint);
            }
            else
            {
                pointGO.transform.position = gameObject.transform.position;
                newPathPoint.position      = gameObject.transform.parent.transform.position;
                listPoints.Add(newPathPoint);
            }

            return(pointGO);
        }
Esempio n. 2
0
        // add a new point to the end of the list
        public GameObject AddPoint()
        {
            GameObject pointGO = new GameObject();

            pointGO.name               = "Path Point";
            pointGO.transform.parent   = gameObject.transform;
            pointGO.transform.position = gameObject.transform.position;

            PathPoint newPathPoint = pointGO.AddComponent <PathPoint>();

            newPathPoint.pointController = this;
            newPathPoint.position        = gameObject.transform.parent.transform.position;
            newPathPoint.rotation        = 0.0f;
            newPathPoint.wait            = 0.0f;

            if (listPoints == null)
            {
                listPoints = new List <PathPoint>();
            }

            listPoints.Add(newPathPoint);

            return(pointGO);
        }
Esempio n. 3
0
 // remove path point from list
 public void RemovePoint(PathPoint point)
 {
     listPoints.Remove(point);
 }