示例#1
0
    void CreateDungeonRooms()
    {
        if (_dungeonRoomsList != null)
        {
            return;
        }

        if (!_coloredWallMaterialsHaveBeenInitialized)
        {
            CreateColorizedMaterials();
        }
        if (!_eastWestMaterialsInitialized)
        {
            CreateEastWestVersionOfMaterials();
        }

        _dungeonRoomsList = new List <DungeonRoom>();

        int       dungeonNum      = WorldInfo.Instance.DungeonNum;
        string    dungeonInfoName = "Dungeon Info " + dungeonNum;
        Transform dungeonInfo     = GameObject.Find(dungeonInfoName).transform;

        // Create Rooms
        foreach (Transform child in dungeonInfo)
        {
            DungeonRoomInfo info = child.GetComponent <DungeonRoomInfo>();
            if (info == null)
            {
                continue;
            }

            CreateRoom(info);
        }

        // Assign SubDungeonSpawnPoints to DungeonRooms
        if (subDungeonContainer != null)
        {
            foreach (Transform child in subDungeonContainer)
            {
                SubDungeonSpawnPoint sdsp = child.GetComponent <SubDungeonSpawnPoint>();
                if (sdsp == null)
                {
                    continue;
                }

                DungeonRoom dr = DungeonRoom.GetRoomForPosition(sdsp.marker.transform.position);
                dr.Info.subDungeonSpawnPoint = sdsp;
                sdsp.ParentDungeonRoom       = dr;
            }
        }
    }
示例#2
0
    public void InitWithInfo(Serializable s)
    {
        int numItems = s.roomNames.Length;

        for (int i = 0; i < numItems; i++)
        {
            Transform room = transform.Find(s.roomNames[i]);
            if (room == null)
            {
                continue;
            }
            DungeonRoomInfo drInfo = room.GetComponent <DungeonRoomInfo>();
            drInfo.InitWithSerializable(s.roomInfo[i]);
        }
    }
示例#3
0
    public void CreateRoom(DungeonRoomInfo info)
    {
        GameObject g = Instantiate(dungeonRoomPrefab);

        g.name = info.name;
        g.transform.SetParent(transform.parent);
        g.transform.position = info.transform.position;

        DungeonRoom dr = g.GetComponent <DungeonRoom>();

        dr.Info = info;

        AssignWallMaterials(dr);
        RemoveUnusedObjects(dr);

        _dungeonRoomsList.Add(dr);
    }
示例#4
0
    void AssignToWall(DungeonRoomInfo.WallDirection newWallDir)
    {
        wallDir = newWallDir;

        if (WorldInfo.Instance.IsInDungeon)
        {
            DungeonRoom dr = _enemy.DungeonRoomRef;
            wall = dr.GetWallForDirection(wallDir);
        }

        _wallNormal  = DungeonRoomInfo.NormalForWallDirection(wallDir);
        _wallTangent = DungeonRoomInfo.TangentForWallDirection(wallDir);
        if (Extensions.FlipCoin())
        {
            _wallTangent *= -1;
        }
    }
示例#5
0
    public void UnlockDoor(DungeonRoomInfo.WallDirection dir)
    {
        if (!IsDoorLocked(dir))
        {
            //Debug.LogError("Trying to Unlock door that is not Locked.");
            return;
        }
        SetWallTypeForDirection(dir, DungeonRoomInfo.WallType.DoorOpen);

        DungeonRoom adjoiningRoom = GetAdjoiningRoom(dir);

        if (adjoiningRoom != null)
        {
            adjoiningRoom.UnlockDoor(DungeonRoomInfo.GetOppositeDirection(dir));
        }

        PlayUnlockSound();
    }
示例#6
0
    public Serializable GetInfo()
    {
        Serializable s = new Serializable();

        int numRooms = transform.childCount;

        s.roomNames = new string[numRooms];
        s.roomInfo  = new DungeonRoomInfo.Serializable[numRooms];
        int i = 0;

        foreach (Transform child in transform)
        {
            DungeonRoomInfo drInfo = child.GetComponent <DungeonRoomInfo>();
            s.roomNames[i] = drInfo.name;
            s.roomInfo[i]  = drInfo.GetSerializable();
            i++;
        }

        return(s);
    }
示例#7
0
    public void BlowHoleInWall(DungeonRoomInfo.WallDirection dir)
    {
        if (IsWallBombedOpen(dir))
        {
            //Debug.LogError("Trying to Blow Hole In Wall that is already bombed open.");
            return;
        }
        if (!Info.IsBombable(dir))
        {
            Debug.LogError("Trying to Blow Hole In Wall that is not bombable.");
            return;
        }
        SetWallTypeForDirection(dir, DungeonRoomInfo.WallType.Bombed);

        DungeonRoom adjoiningRoom = GetAdjoiningRoom(dir);

        if (adjoiningRoom != null)
        {
            adjoiningRoom.BlowHoleInWall(DungeonRoomInfo.GetOppositeDirection(dir));
        }
    }
示例#8
0
    public void AssignWallMaterials(DungeonRoom dr)
    {
        DungeonRoomInfo info = dr.Info;

        // Set wall materials according to walltype
        dr.wall_N.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.North, info.northWallType);
        dr.wall_E.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.East, info.eastWallType);
        dr.wall_S.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.South, info.southWallType);
        dr.wall_W.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.West, info.westWallType);

        dr.wall_N2.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.North, DungeonRoomInfo.WallType.Top);
        dr.wall_E2.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.East, DungeonRoomInfo.WallType.Top);
        dr.wall_S2.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.South, DungeonRoomInfo.WallType.Top);
        dr.wall_W2.GetComponent <Renderer>().material = GetWallMaterial(DungeonRoomInfo.WallDirection.West, DungeonRoomInfo.WallType.Top);

        if (info.floorMaterial == null)
        {
            info.floorMaterial = new Material(defaultFloor);
        }

        dr.floor.GetComponent <Renderer>().material   = info.floorMaterial;
        dr.ceiling.GetComponent <Renderer>().material = defaultFloor;
    }
示例#9
0
    public Material GetWallMaterial(DungeonRoomInfo.WallDirection direction, DungeonRoomInfo.WallType wallType)
    {
        bool     northSouthWall = DungeonRoomInfo.IsNorthOrSouth(direction);
        Material mat            = null;

        switch (wallType)
        {
        case DungeonRoomInfo.WallType.Closed:
            mat = northSouthWall ? wall : wall_EW;
            break;

        case DungeonRoomInfo.WallType.DoorOpen:
            mat = northSouthWall ? wallOpen : wallOpen_EW;
            break;

        case DungeonRoomInfo.WallType.DoorSealed:
            mat = northSouthWall ? wallSealed : wallSealed_EW;
            break;

        case DungeonRoomInfo.WallType.DoorLocked:
            mat = northSouthWall ? wallLocked : wallLocked_EW;
            break;

        case DungeonRoomInfo.WallType.Bombed:
            mat = northSouthWall ? wallBombed : wallBombed_EW;
            break;

        case DungeonRoomInfo.WallType.Top:
            mat = northSouthWall ? wallTop : wallTop_EW;
            break;

        default:
            break;
        }

        return(mat);
    }
示例#10
0
    void RemoveUnusedObjects(DungeonRoom dr)
    {
        DungeonRoomInfo info = dr.Info;

        // DoorTriggers and Halls
        if (info.northWallType == DungeonRoomInfo.WallType.Closed)
        {
            if (!info.IsBombable(DungeonRoomInfo.WallDirection.North))
            {
                Destroy(dr.hall_N);
                Destroy(dr.doorTrigger_N);
                Destroy(dr.entranceBlock_N);
            }
        }
        if (info.eastWallType == DungeonRoomInfo.WallType.Closed)
        {
            if (!info.IsBombable(DungeonRoomInfo.WallDirection.East))
            {
                Destroy(dr.hall_E);
                Destroy(dr.doorTrigger_E);
                Destroy(dr.entranceBlock_E);
            }
        }
        if (info.southWallType == DungeonRoomInfo.WallType.Closed)
        {
            if (!info.IsBombable(DungeonRoomInfo.WallDirection.South))
            {
                Destroy(dr.hall_S);
                Destroy(dr.doorTrigger_S);
                Destroy(dr.entranceBlock_S);
            }
        }
        if (info.westWallType == DungeonRoomInfo.WallType.Closed)
        {
            if (!info.IsBombable(DungeonRoomInfo.WallDirection.West))
            {
                Destroy(dr.hall_W);
                Destroy(dr.doorTrigger_W);
                Destroy(dr.entranceBlock_W);
            }
        }

        // InnerBombable Walls
        if (!info.IsBombable(DungeonRoomInfo.WallDirection.North))
        {
            Destroy(dr.wall_bombedInner_N);
        }
        if (!info.IsBombable(DungeonRoomInfo.WallDirection.East))
        {
            Destroy(dr.wall_bombedInner_E);
        }
        if (!info.IsBombable(DungeonRoomInfo.WallDirection.South))
        {
            Destroy(dr.wall_bombedInner_S);
        }
        if (!info.IsBombable(DungeonRoomInfo.WallDirection.West))
        {
            Destroy(dr.wall_bombedInner_W);
        }

        // NpcContainer
        if (dr.IsNpcRoom)
        {
            dr.npcContainer.gameObject.SetActive(true);

            if (dr.ContainsBombUpgrade && info.BombUpgradeHasBeenPurchased)
            {
                Destroy(dr.rupeeTrigger);
            }
        }
        else
        {
            Destroy(dr.npcContainer.gameObject);
        }
    }
示例#11
0
 void AssignToRandomWall()
 {
     DungeonRoomInfo.WallDirection d = WorldInfo.Instance.IsInDungeon ? DungeonRoomInfo.GetRandomWallDirection() : wallDir;
     AssignToWall(d);
 }