Exemple #1
0
    //camera View -11 < camera > 11
    void Start()
    {
        if (File.Exists("World.xml") == true)
        {
            World = GestioneFileXml.ReadConfig();
        }

        current_x = -11;
        index     = 0;
        rotate    = quaternion.Euler(0, 0, 0);
        x         = -11;
        //randomizzo la posizione 0 di spawn
        y += new System.Random().Next(-3, 2);
        //Instantiate(WorldBlocks[0], new Vector3(x, y, 0), rotate);
    }
Exemple #2
0
    void ProceduralWorld(int h)
    {
        if (Camera.main.transform.position.x + 11f >= current_x - 1.28F)
        {
            if (File.Exists("World.xml") == true && World.Count - 1 > current_x + 11f)
            {
                if (World[index].Name != "Castle")
                {
                    Instantiate(WorldBlocks[0], World[index++].Position, rotate);
                }
                else
                {
                    Instantiate(WorldStructure[0], World[index++].Position, rotate);
                    current_x += 32 * 1.28f;
                }


                current_x += 1.28F;
            }
            else
            {
                if (World == null)
                {
                    World = new List <Blocco>();
                }

                if (new System.Random().Next(1, 100) > Castle_percent)
                {
                    World.Add(new Blocco(new Vector3(current_x, Mathf.PerlinNoise(current_x / 30f, 0f) * h, 1), "grass"));
                    Instantiate(WorldBlocks[0], World[World.Count - 1].Position, rotate);
                    GestioneFileXml.SaveConfig(World);
                    current_x += 1.28F;
                }
                else
                {
                    World.Add(new Blocco(new Vector3(current_x, Mathf.PerlinNoise(current_x / 30f, 0f) * h, 1), "Castle"));
                    Instantiate(WorldStructure[0], World[World.Count - 1].Position, rotate);
                    current_x += 32 * 1.28f;
                    GestioneFileXml.SaveConfig(World);
                }
            }
        }
    }