// Start is called before the first frame update
 void Awake()
 {
     floor            = FloorName.GARDEN;
     activeObjectType = DungeonObjectType.TILE;
     activeTile       = tiles[0];
     activeObject     = objects[0];
 }
Exemple #2
0
    /// <summary>
    /// Prepares the wall object for tile.
    /// </summary>
    /// <returns>
    /// Prepared wall object as dungeon object.
    /// </returns>
    /// <param name='code'>
    /// Code of tile.
    /// </param>
    /// <param name='objectType'>
    /// Object type.
    /// </param>
    /// <param name='prefabReference'>
    /// Prefab string reference to resource.
    /// </param>
    /// <param name='fromI'>
    /// I index of source tile.
    /// </param>
    /// <param name='fromJ'>
    /// J index of source tile.
    /// </param>
    /// <param name='toI'>
    /// I index of target tile.
    /// </param>
    /// <param name='toJ'>
    /// J index of target tile.
    /// </param>
    public static DungeonObject PrepareWallObject(int code, DungeonObjectType objectType, string prefabReference, int fromI, int fromJ, int toI, int toJ)
    {
        DungeonObject newDungeonObject = new DungeonObject(code, objectType, prefabReference);

        newDungeonObject.rotation = DungeonUtils.GetRotationFromToTile(fromI, fromJ, toI, toJ);
        newDungeonObject.offset   = newDungeonObject.rotation * new Vector3(0f, 0f, -DungeonUtils.TileSize * 0.5f);
        return(newDungeonObject);
    }
    /// <summary>
    /// Gets the resource by type and name.
    /// </summary>
    /// <returns>
    /// The resource.
    /// </returns>
    /// <param name='objectType'>
    /// Dungeon object type.
    /// </param>
    /// <param name='name'>
    /// Object name.
    /// </param>
    public static object GetResource(DungeonObjectType objectType, string name)
    {
        string path = GetPathByType(objectType, name);

        if (Objects.ContainsKey(path))
        {
            return(Objects [path]);
        }
        else
        {
            object o = Resources.Load(path);
            Objects.Add(path, o);
            return(o);
        }
    }
    /// <summary>
    /// Gets the path to the resource according to its type.
    /// </summary>
    /// <returns>
    /// The path by type.
    /// </returns>
    /// <param name='objectType'>
    /// Object type.
    /// </param>
    /// <param name='name'>
    /// Name.
    /// </param>
    private static string GetPathByType(DungeonObjectType objectType, string name)
    {
        switch (objectType)
        {
        default:
            return(null);

        case DungeonObjectType.Ceiling:
            return(CEILINGS_PATH + name);

        case DungeonObjectType.Floor:
            return(FLOORS_PATH + name);

        case DungeonObjectType.LightSource:
            return(LIGHTS_PATH + name);

        case DungeonObjectType.Passage:
            return(PASSAGES_PATH + name);

        case DungeonObjectType.Wall:
            return(WALLS_PATH + name);
        }
    }
Exemple #5
0
 public DungeonObject(int code, DungeonObjectType type, string prefabReference)
 {
     this.code            = code;
     this.type            = type;
     this.prefabReference = prefabReference;
 }
 public void SetObjectMode(DungeonObjectType type)
 {
     activeObjectType = type;
 }