Exemplo n.º 1
0
    SunMesh CreateMesh()
    {
        GameObject obj = new GameObject(name + "-Mesh");

        obj.transform.parent = transform;
        SunMesh sunMesh = obj.AddComponent <SunMesh>();

        obj.transform.localScale    = Vector3.one * 4;
        obj.transform.localPosition = Vector3.zero;
        sunMesh.Init();
        return(sunMesh);
    }
Exemplo n.º 2
0
    public void Init()
    {
        islandCount             = 0;
        transform.localPosition = Vector3.zero;
        if (islands.Count > 0)
        {
            foreach (Island island in islands)
            {
                if (island != null)
                {
                    CameraBoom boom = island.GetComponentInChildren <CameraBoom>();
                    if (boom != null)
                    {
                        boom.transform.parent = null;
                    }
                    DestroyImmediate(island.gameObject);
                }
            }
            islands.Clear();
        }
        int r = random.Next(5) + 2;

        for (int i = 0; i < r; i++)
        {
            islands.Add(CreateIsland());
        }
        FindObjectOfType <CameraBoom>().attachedObject = islands[0].gameObject;
        if (sunMesh != null)
        {
            DestroyImmediate(sunMesh.gameObject);
        }
        sunMesh = CreateMesh();
        LineRenderer line      = GetComponent <LineRenderer>();
        int          vertCount = 1;
        float        radius    = 110f;
        float        x;
        float        y;
        float        h = -2f;

        for (float i = 0; i < 2 * Mathf.PI; i += 0.05f)
        {
            x = radius * Mathf.Cos(i);
            y = radius * Mathf.Sin(i);
            line.SetVertexCount(vertCount++);
            line.SetPosition(vertCount - 2, new Vector3(x, h, y));
        }
        line.SetVertexCount(vertCount++);
        x = radius * Mathf.Cos(0);
        y = radius * Mathf.Sin(0);
        line.SetPosition(vertCount - 2, new Vector3(x, h, y));
    }
Exemplo n.º 3
0
 public void Init()
 {
     islandCount = 0;
     transform.localPosition = Vector3.zero;
     if (islands.Count > 0)
     {
         foreach (Island island in islands)
         {
             if (island != null)
             {
                 CameraBoom boom = island.GetComponentInChildren<CameraBoom>();
                 if (boom != null)
                 {
                     boom.transform.parent = null;
                 }
                 DestroyImmediate(island.gameObject);
             }
         }
         islands.Clear();
     }
     int r = random.Next(5) + 2;
     for (int i = 0; i < r; i++)
     {
         islands.Add(CreateIsland());
     }
     FindObjectOfType<CameraBoom>().attachedObject = islands[0].gameObject;
     if (sunMesh != null) { DestroyImmediate(sunMesh.gameObject); }
     sunMesh = CreateMesh();
     LineRenderer line = GetComponent<LineRenderer>();
     int vertCount = 1;
     float radius = 110f;
     float x;
     float y;
     float h= -2f;
     for (float i = 0; i < 2 * Mathf.PI; i += 0.05f)
     {
         x = radius * Mathf.Cos(i);
         y = radius * Mathf.Sin(i);
         line.SetVertexCount(vertCount++);
         line.SetPosition(vertCount - 2, new Vector3(x, h, y));
     }
     line.SetVertexCount(vertCount++);
     x = radius * Mathf.Cos(0);
     y = radius * Mathf.Sin(0);
     line.SetPosition(vertCount - 2, new Vector3(x, h, y));
 }