Exemple #1
0
    // Use this for initialization
    void Start()
    {
        int width  = GameManager.width;
        int height = GameManager.height;

        GameManager.Blocks = new CityGenerator[width * height * 2 * 2];
        int i = 0;

        for (float x = -width; x < width; x++)
        {
            for (float y = -height; y < height; y++)
            {
                GameObject CityObject = Instantiate <GameObject> (CityBlock);
                CityObject.transform.SetParent(transform);
                CityObject.transform.localPosition = new Vector3(2f * x, 0f, 2f * y);
                CityGenerator CG = CityObject.GetComponent <CityGenerator> ();
                //City Design 1st Num is Spread
                //CG.TowerHealth = 45f*Mathf.Abs(((1f-(Mathf.Abs(x)/width))+(1f-(Mathf.Abs(y)/height)))/4f);
                CG.TowerHealth = 2f * Mathf.Abs(((1f - ((Mathf.Abs(x) + 1) / width)) + (1f - ((Mathf.Abs(y) + 1) / height))) / 4f);
                CG.GenerateCity((int)x + (int)width, (int)y + (int)height);
                GameManager.Blocks[i] = CG;
                i++;
            }
        }
    }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        CityGenerator cityGenerator = (CityGenerator)target;

        if (GUILayout.Button("Generate City Prefab"))
        {
            cityGenerator.GenerateCity();
        }
    }
Exemple #3
0
    public override void OnInspectorGUI()
    {
        CityGenerator cityGen = (CityGenerator)target;

        if (DrawDefaultInspector())
        {
        }
        if (GUILayout.Button("Generate"))
        {
            cityGen.GenerateCity();
        }
    }
Exemple #4
0
 public void GenerateCity()
 {
     try
     {
         int roadCount = Convert.ToInt32(_roadCount.text);
         _cityGenerator.GenerateCity(roadCount);
         CityGenerated.Invoke();
     }
     catch (FormatException e)
     {
         Debug.Log($"{e.Message}");
     }
 }
    public override void OnInspectorGUI()
    {
        CityGenerator cityGen = (CityGenerator)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Re-Generate City"))
        {
            cityGen.GenerateCity(cityGen.citySizeX, cityGen.citySizeZ);
        }

        if (GUILayout.Button("Clear City"))
        {
            cityGen.ClearCity();
        }
    }
Exemple #6
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();


        CityGenerator myScript = (CityGenerator)target;


        GUILayout.Label("City Funcionality", EditorStyles.boldLabel);
        if (GUILayout.Button("Generate City"))
        {
            myScript.DeleteCity();
            myScript.GenerateCity(myScript.perlinNoise);
        }

        if (GUILayout.Button("Delete City"))
        {
            myScript.DeleteCity();
        }

        GUILayout.Label("Enviroment Options", EditorStyles.boldLabel);
        if (GUILayout.Button("Set Day Time"))
        {
            myScript.SetDayTime();
        }

        if (GUILayout.Button("Set Noon Time"))
        {
            myScript.SetNoonTime();
        }

        if (GUILayout.Button("Set Night Time"))
        {
            myScript.SetNightTime();
        }
    }