private void SpawnPoints()
    {
        if (showWaypoints)
        {
            for (int j = 0; j < waypoints.Count; j++)
            {
                recentPoints = new GameObject[waypoints[j].pointSpawns.Count];
                float      pathAngle          = Helper.AngleDegrees(Vector3.up, waypoints[j].transform.position - waypoints[previous].transform.position, Vector3.forward);
                Quaternion pointSpawnRotation = Quaternion.AngleAxis(pathAngle, Vector3.forward);
                for (int i = 0; i < recentPoints.Length; i++)
                {
                    PointSpawn newPointSpawn = waypoints[j].pointSpawns[i];
                    Vector3    offset        = pointSpawnRotation * newPointSpawn.offset;
                    GameObject newPoint      = (GameObject)Instantiate(newPointSpawn.pointPrefab, waypoints[j].transform.position + offset, Quaternion.identity);
                    recentPoints[i] = newPoint;
                    MiniPoint newMiniPoint = newPoint.GetComponent <MiniPoint>();
                    if (newMiniPoint != null)
                    {
                        newMiniPoint.creator = gameObject;
                        if (true)                        //newPointSpawn.setInformationFactor)
                        {
                            newMiniPoint.informationFactor = newPointSpawn.informationFactor;
                        }
                    }
                }
            }
        }

        else if (waypoints[current].pointSpawns != null && waypoints[current].pointSpawns.Count > 0)
        {
            DestroyRecentPoints();

            recentPoints = new GameObject[waypoints[current].pointSpawns.Count];
            float      pathAngle          = Helper.AngleDegrees(Vector3.up, waypoints[current].transform.position - waypoints[previous].transform.position, Vector3.forward);
            Quaternion pointSpawnRotation = Quaternion.AngleAxis(pathAngle, Vector3.forward);
            for (int i = 0; i < recentPoints.Length; i++)
            {
                if (!waypoints[current].pointSpawns[i].requirePartner || partnerLink.Partner != null)
                {
                    PointSpawn newPointSpawn = waypoints[current].pointSpawns[i];
                    Vector3    offset        = pointSpawnRotation * newPointSpawn.offset;
                    GameObject newPoint      = (GameObject)Instantiate(newPointSpawn.pointPrefab, waypoints[current].transform.position + offset, Quaternion.identity);
                    recentPoints[i] = newPoint;
                    MiniPoint newMiniPoint = newPoint.GetComponent <MiniPoint>();
                    if (newMiniPoint != null)
                    {
                        newMiniPoint.creator = gameObject;
                        if (true)                        //newPointSpawn.setInformationFactor)
                        {
                            newMiniPoint.informationFactor = newPointSpawn.informationFactor;
                        }
                    }
                }
            }
        }
    }
예제 #2
0
 void Start()
 {
     player.transform.position = new Vector3(0f, 0f, 0f);
     count = GetComponent <PointSpawn>();
 }