Exemple #1
0
 private GameObject GetDecoration(LevelDataBlock block)
 {
     textures = block.GetReferences(AssetType.Texture);
     if (TryGetByParameter(block, out var byParameter))
     {
         return(byParameter); // try getting by parameter
     }
     return(default);
Exemple #2
0
    /// <summary>
    /// Loads all referenced sound effects into the Sound Cache
    /// </summary>
    /// <param name="DataBlock"></param>
    public void LoadAll(LevelDataBlock DataBlock)
    {
        List <string> references = new List <string>();

        foreach (var reference in DataBlock.GetReferences(AssetType.Sound))
        {
            references.Add(reference.DBName);
            if (SoundEffects.ContainsKey(reference.DBName))
            {
                continue;
            }
            var audio = LoadFromFile(reference.FileName);
            audio.name = reference.DBName;
            SoundEffects.Add(reference.DBName, audio);
        }
        SoundReferences = references.ToArray();
        Loaded          = true;
    }
Exemple #3
0
 private void Awake()
 {
     if (!TryGetComponent(out TileComponent) && InheritParent && !ForceTemplate)
     {
         TileComponent = GetComponentInParent <DataBlockComponent>();
     }
     // if (TileComponent?.TextureLoaded ?? false && !ForceTemplate)
     //   return;
     Data = TileComponent?.DataBlock;
     if (DefaultMaterial == null)
     {
         DefaultMaterial = (Material)Instantiate(Resources.Load("Materials/Object Material"));
     }
     if (Data == null || ForceTemplate)
     {
         Data = ApplyTileData(); // try to apply templated data
     }
     if (Data == null)
     {
         return;                                       // outright failure
     }
     textures = Data.GetReferences(AssetType.Texture); // get referenced textures
     if (Data.GetParameterByName("FLOOR", out _))      // floors
     {
         CreateFloor();
     }
     else if (Data.GetParameterByName("WALL", out _)) // walls
     {
         CreateWall();
     }
     else if (Data.GetParameterByName("FillTexture", out var parameter)) // generic fill texture parameter info
     {
         ApplyTextureMaterial(GetComponent <Renderer>(), int.Parse(parameter.Value));
     }
     else
     {
         ApplyTextureMaterial(GetComponentInChildren <Renderer>(), 0);
     }
     if (TileComponent != null)
     {
         TileComponent.TextureLoaded = true;
     }
     Loaded = true;
 }