Example #1
0
    /// <summary>
    /// Function to build a building on the map.
    /// </summary>
    /// <param name="target">Place to build building.</param>
    public void Build(Transform target)
    {
        int buildingNumber;

        if (start)
        {
            buildingNumber = 0;
            start          = false;
        }
        else
        {
            if (selectedBuilding != BuildingType.None)
            {
                buildingNumber = (int)selectedBuilding;
            }
            else
            {
                buildingNumber = Random.Range(1, 6);
            }
        }
        Vector3    pos      = new Vector3(target.position.x, target.position.y - 0.264f, target.position.z);
        GameObject building = Instantiate(buildings[buildingNumber], pos, Quaternion.identity) as GameObject;

        //triggers animation while placing the building
        building.GetComponent <Animator>().SetTrigger("Show");
        notifications.AdvanceDialoque(building, buildingNumber);
        createdBuildings.Add(building);
    }