Ejemplo n.º 1
0
  private void ConstructRoof()
  {
    roofBase = new RoofBase(this);

    if (parent.roofBaseMaterial == null)
    {
      var list = MaterialManager.Instance.GetCollection("mat_roof_base");
      roofBase.material = list[Random.Range(0, list.Count - 1)];
    }
    else
      roofBase.material = parent.roofBaseMaterial;
    parent.AddCombinable(roofBase.material.name, roofBase);

    int maxcpf = Mathf.Max(faces[0].componentsPerFloor, faces[1].componentsPerFloor);

    if (parent.roofType == null)
    {
      int n = Util.RollDice(new float[] { 0.33f, 0.33f, 0.34f });
      if (n == 1)
        roof = new FlatRoof(this);
      else if (n == 2 && maxcpf <= 3)
        roof = new SinglePeakRoof(this);
      else
        roof = new DoublePeakRoof(this);
    }
    else
    {
      var ctors = parent.roofType.GetConstructors(BindingFlags.Instance |
                                                  BindingFlags.Public);
      roof = (Roof) ctors[0].Invoke(new object[] { this });
    }

    if (parent.roofMaterial == null)
    {
      var list = MaterialManager.Instance.GetCollection("mat_roof");
      if (roof.GetType().Equals(typeof(FlatRoof)))
        roof.material = list[Random.Range(0, 2)];
      else
        roof.material = list[Random.Range(0, list.Count - 1)];
    }
    else
      roof.material = parent.roofMaterial;
    parent.AddCombinable(roof.material.name, roof);
  }
        private void ConstructRoof()
        {
            roofBase = new RoofBase(this);

            if (parent.roofBaseMaterial == null)
            {
              var list = MaterialManager.Instance.GetCollection("mat_roof_base");
              roofBase.material = list[Random.Range(0, list.Count - 1)];
            }
            else
              roofBase.material = parent.roofBaseMaterial;
            parent.AddCombinable(roofBase.material.name, roofBase);

            int maxcpf = Mathf.Max(faces[0].componentsPerFloor, faces[1].componentsPerFloor);

            if (parent.roofType == null)
            {
              int n = Util.RollDice(new float[] { 0.33f, 0.33f, 0.34f });
              if (n == 1)
            roof = new FlatRoof(this);
              else if (n == 2 && maxcpf <= 3)
            roof = new SinglePeakRoof(this);
              else
            roof = new DoublePeakRoof(this);
            }
            else
            {
              var ctors = parent.roofType.GetConstructors(BindingFlags.Instance |
                                                  BindingFlags.Public);
              roof = (Roof) ctors[0].Invoke(new object[] { this });
            }

            if (parent.roofMaterial == null)
            {
              var list = MaterialManager.Instance.GetCollection("mat_roof");
              if (roof.GetType().Equals(typeof(FlatRoof)))
            roof.material = list[Random.Range(0, 2)];
              else
            roof.material = list[Random.Range(0, list.Count - 1)];
            }
            else
              roof.material = parent.roofMaterial;
            parent.AddCombinable(roof.material.name, roof);
        }