Exemple #1
0
    public void GenerateTower()
    {
        for (int i = 0; i < gameObject.transform.childCount; i++)
        {
            string despawnTag = gameObject.transform.GetChild(i).tag;
            if (despawnTag == "Building" || despawnTag == "Enemy")
            {
                Destroy(gameObject.transform.GetChild(i).gameObject);
            }
        }
        pos = gameObject.transform.position;

        //genOptions = new WeightedEntry[] { new WeightedEntry(0, 0), new WeightedEntry(1, 0), new WeightedEntry(2, 3) };
        int     structureType = WeightedRandom.WeightedSelect(genOptions);
        Vector3 structurePos;

        structurePos = new Vector3(pos.x + Random.Range(structures[structureType].xBounds.x, structures[structureType].xBounds.y), pos.y + structures[structureType].yPos, pos.z);
        //GameObject newBuilding = Instantiate(structures[structureType].structurePrefab, structurePos, Quaternion.identity, gameObject.transform) as GameObject;
        Instantiate(structures[structureType].structurePrefab, structurePos, Quaternion.identity, gameObject.transform);
        //newBuilding.GetComponent<ITransparancy>().startFadingIn();
    }