public void SetupRoomObjects(DungeonSettings gameInit, int level, Vector2Int pos, Vector2Int dim, Corridor corridor) { SetupLights(gameInit, level, pos, dim); SetupEnemies(gameInit, level, pos, dim); SetupTorches(gameInit, level, pos, dim); SetupPotions(gameInit, level, pos, dim); SetupChests(gameInit, level, pos, dim); }
public CorridorDirection enteringCorridor; // The direction of the corridor that is entering this room. // This is used for the first room. It does not have a Corridor parameter since there are no corridors yet. public void SetupRoom(int level, DungeonSettings gameInit, int columns, int rows) { // Set a random width and height. dim.x = gameInit.roomWidth.Random; dim.y = gameInit.roomHeight.Random; // Set the x and y coordinates so the room is roughly in the middle of the board. pos.x = Mathf.RoundToInt(columns / 2f - dim.x / 2f); pos.y = Mathf.RoundToInt(rows / 2f - dim.y / 2f); }
// This is an overload of the SetupRoom function and has a corridor parameter that represents the corridor entering the room. public void SetupRoom(int level, DungeonSettings gameInit, int columns, int rows, Corridor corridor) { // Set the entering corridor direction. enteringCorridor = corridor.direction; // Set random values for width and height. dim.x = gameInit.roomWidth.Random; dim.y = gameInit.roomHeight.Random; switch (corridor.direction) { // If the corridor entering this room is going north... case CorridorDirection.North: // ... the height of the room mustn't go beyond the board so it must be clamped based // on the height of the board (rows) and the end of corridor that leads to the room. dim.y = Mathf.Clamp(dim.y, 1, rows - corridor.EndPositionY); // The y coordinate of the room must be at the end of the corridor (since the corridor leads to the bottom of the room). pos.y = corridor.EndPositionY; // The x coordinate can be random but the left-most possibility is no further than the width // and the right-most possibility is that the end of the corridor is at the position of the room. pos.x = Random.Range(corridor.EndPositionX - dim.x + 1, corridor.EndPositionX); // This must be clamped to ensure that the room doesn't go off the board. pos.x = Mathf.Clamp(pos.x, 0, columns - dim.x); break; case CorridorDirection.East: dim.x = Mathf.Clamp(dim.x, 1, columns - corridor.EndPositionX); pos.x = corridor.EndPositionX; pos.y = Random.Range(corridor.EndPositionY - dim.y + 1, corridor.EndPositionY); pos.y = Mathf.Clamp(pos.y, 0, rows - dim.y); break; case CorridorDirection.South: dim.y = Mathf.Clamp(dim.y, 1, corridor.EndPositionY); pos.y = corridor.EndPositionY - dim.y + 1; pos.x = Random.Range(corridor.EndPositionX - dim.x + 1, corridor.EndPositionX); pos.x = Mathf.Clamp(pos.x, 0, columns - dim.x); break; case CorridorDirection.West: dim.x = Mathf.Clamp(dim.x, 1, corridor.EndPositionX); pos.x = corridor.EndPositionX - dim.x + 1; pos.y = Random.Range(corridor.EndPositionY - dim.y + 1, corridor.EndPositionY); pos.y = Mathf.Clamp(pos.y, 0, rows - dim.y); break; } }
public void LoadAlgorithmSettings() { DungeonSettings.Clear(); if (Algorithm > -1) { List <Tuple <string, bool> > settings = GameData.DungeonAlgorithmDex[Algorithm].DungeonSettings; for (int i = 0; i < settings.Count; i++) { DungeonSettings.Add(settings[i].Item1, 0); } } }
private void SetupChests(DungeonSettings gameInit, int level, Vector2Int Pos, Vector2Int Dim) { int NumOfEnemies = Random.Range(1, settings.objectSet[level <= settings.objectSet.Length ? level : 0].chestPerRoom); for (int i = 0; i < NumOfEnemies; ++i) { float startXPos = Random.Range(Pos.x, Pos.x + Dim.x); float startYPos = Random.Range(Pos.y, Pos.y + Dim.y); Vector3 pos = new Vector3(startXPos, startYPos, 0.0f); chestSpawner.spawn(null, pos - chestSpawner.transform.position); } }
private void SetupLights(DungeonSettings gameInit, int level, Vector2Int Pos, Vector2Int Dim) { int NumOfLights = settings.objectSet[level <= settings.objectSet.Length ? level : 0].lightsPerRoom.Random; for (int i = 0; i < NumOfLights; ++i) { float startXPos = Random.Range(Pos.x, Pos.x + Dim.x); float startYPos = Random.Range(Pos.y, Pos.y + Dim.y); Vector3 pos = new Vector3(startXPos, startYPos, lightSpawner.transform.position.z); lightSpawner.spawn(null, pos - lightSpawner.transform.position); } }
public void Load(int rdungeonNum) { //load settings from algorithm using (XmlReader reader = XmlReader.Create(Paths.DataPath + "RDungeon\\" + rdungeonNum + "\\base.xml")) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "Name": { Name = reader.ReadString(); break; } case "Algorithm": { Algorithm = reader.ReadString().ToInt(); LoadAlgorithmSettings(); break; } case "DungeonSettings": { XmlReader settingsReader = reader.ReadSubtree(); while (settingsReader.Read()) { if (settingsReader.IsStartElement() && DungeonSettings.ContainsKey(settingsReader.Name)) { DungeonSettings[settingsReader.Name] = settingsReader.ReadString().ToInt(); } } break; } } } } } int floorNum = 0; while (File.Exists(Paths.DataPath + "RDungeon\\" + rdungeonNum + "\\" + floorNum + ".xml")) { RDungeonFloor floor = new RDungeonFloor(); floor.Load(rdungeonNum, floorNum); Floors.Add(floor); floorNum++; } }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } //setup scales according to dungeon level SetupDungeonScaling(); }
private void SetupEnemies(DungeonSettings gameInit, int level, Vector2Int Pos, Vector2Int Dim) { int NumOfEnemies = settings.enemiesSets[level <= settings.enemiesSets.Length ? level : 0].enemiesPerRoom.Random; for (int i = 0; i < NumOfEnemies; ++i) { float startXPos = Random.Range(Pos.x, Pos.x + Dim.x); float startYPos = Random.Range(Pos.y, Pos.y + Dim.y); Vector3 pos = new Vector3(startXPos, startYPos, 0.0f); Vector3 localPos = pos - enemySpawner.transform.position; enemySpawner.spawn(null, localPos); } }
/// <summary> /// Default constructor /// </summary> /// <param name="dungeon">The dungeon information</param> /// <param name="browser">The browser object for displaying wiki information</param> /// <param name="userSettings">The dungeon user settings</param> public DungeonViewModel(Dungeon dungeon, IBrowserController browserController, DungeonSettings userSettings) { this.DungeonModel = dungeon; this.browserController = browserController; this.userSettings = userSettings; // Initialize the path view models this.Paths = new ObservableCollection <PathViewModel>(); foreach (var path in this.DungeonModel.Paths) { this.Paths.Add(new PathViewModel(path, this.userSettings)); } this.RefreshVisibility(); this.userSettings.PropertyChanged += (o, e) => this.RefreshVisibility(); this.userSettings.HiddenDungeons.CollectionChanged += (o, e) => this.RefreshVisibility(); }
private void SetupTorches(DungeonSettings gameInit, int level, Vector2Int Pos, Vector2Int Dim) { int NumOfTorches = Random.Range(1, settings.objectSet[level <= settings.objectSet.Length ? level : 0].torchesPerRoom); for (int i = 0; i < NumOfTorches; ++i) { int whichWall = Random.Range(0, 4); float startXPos = 0; float startYPos = 0; float padding = 0.3f; float lastTorchNorth = 0; float spacing = 2; switch (whichWall) { // north case 0: startXPos = Mathf.Clamp(lastTorchNorth + Random.Range(spacing, Dim.x - spacing), Pos.x, Pos.x + Dim.x); startYPos = Pos.y + Dim.y - padding; lastTorchNorth = startXPos; break; // east case 1: startXPos = Pos.x + Dim.x - padding; startYPos = Random.Range(Pos.y, Pos.y + Dim.y); break; // south case 2: startXPos = Random.Range(Pos.x, Pos.x + Dim.x); startYPos = Pos.y + padding; break; // west case 3: startXPos = Pos.x + padding; startYPos = Random.Range(Pos.y, Pos.y + Dim.y); break; } Vector3 pos = new Vector3(startXPos, startYPos, 0.0f); torchSpawner.spawn(null, pos - torchSpawner.transform.position); } }
/// <summary> /// Default constructor /// </summary> /// <param name="dungeonsService">The dungeons service object</param> /// <param name="userSettings">The dungeons user settings object</param> public DungeonsController(IDungeonsService dungeonsService, IBrowserController browserController, DungeonSettings userSettings) { logger.Debug("Initializing Dungeons Controller"); this.dungeonsService = dungeonsService; this.browserController = browserController; this.userSettings = userSettings; // Initialize the refresh timer this.dungeonsRefreshTimer = new Timer(this.RefreshDungeons); this.RefreshInterval = 1000; // Initialize the start call count to 0 this.startCallCount = 0; // Initialize the WorldEvents collection this.InitializeDungeons(); logger.Info("Dungeons Controller initialized"); }
private void Start() { dungeonModSettings = new DungeonSettings(); Mod mod = ModManager.Instance.GetMod("Handpainted Models - Main"); bool handPaintedModFound = mod != null; improvedDungeonLightMod.GetSettings().Deserialize("Dungeons", ref dungeonModSettings); if (dungeonModSettings.Enabled == true) { if (GameManager.Instance.IsPlayerInsideDungeon) { ApplyShadowSettings(null); //Apply our shadow settings RemoveVanillaLightSources(null); //If the game starts or is loaded indoors, apply the shadows right away //Check to see if the hand painted mod exists - if it does we don't have to add new lights, only adjust exisitng ones. if (handPaintedModFound == true) { AdjustExistingLightSources(null); } else { AddImprovedLighting(null); } } PlayerEnterExit.OnTransitionDungeonInterior += RemoveVanillaLightSources; //Remove all the daggerfall vanilla light sources in dungeons. PlayerEnterExit.OnTransitionDungeonInterior += ApplyShadowSettings; //If the hainted painted mod is found, adjust that mods existing lights instead of creating new ones if (handPaintedModFound == true) { PlayerEnterExit.OnTransitionDungeonInterior += AdjustExistingLightSources; } else { PlayerEnterExit.OnTransitionDungeonInterior += AddImprovedLighting; } } }
public virtual void InstantiateOuterWalls(DungeonModel.TileType[][] tiles, GameObject boardHolder, DungeonSettings gameInit) { }
protected virtual void InstantiateFromArray(GameObject[] prefabs, float xCoord, float yCoord, GameObject boardHolder, DungeonSettings gameInit) { }
protected virtual void InstantiateHorizontalOuterWall(float startingX, float endingX, float yCoord, GameObject boardHolder, DungeonSettings gameInit) { }
protected virtual void InstantiateVerticalOuterWall(float xCoord, float startingY, float endingY, GameObject boardHolder, DungeonSettings gameInit) { }
//public override void InstantiateOuterWalls(DungeonModel.TileType[][] tiles, GameObject boardHolder, GameSettings gameInit) { } //protected override void InstantiateVerticalOuterWall(float xCoord, float startingY, float endingY, GameObject boardHolder, GameSettings gameInit) { } //protected override void InstantiateHorizontalOuterWall(float startingX, float endingX, float yCoord, GameObject boardHolder, GameSettings gameInit) { } protected override void InstantiateFromArray(GameObject[] prefabs, float xCoord, float yCoord, GameObject boardHolder, DungeonSettings gameInit) { // Create a random index for the array. //int randomIndex = Random.Range(0, prefabs.Length); //// The position to be instantiated at is based on the coordinates. //Vector3 position = new Vector3(xCoord, yCoord, 0f); //// Create an instance of the prefab from the random index of the array. //GameObject tileInstance = Instantiate(prefabs[randomIndex], position, Quaternion.identity) as GameObject; //// Set the tile's parent to the board holder. //tileInstance.transform.parent = boardHolder.transform; }
protected override void InstantiateVerticalOuterWall(float xCoord, float startingY, float endingY, GameObject boardHolder, DungeonSettings gameInit) { // Start the loop at the starting value for Y. float currentY = startingY; // While the value for Y is less than the end value... while (currentY <= endingY) { // ... instantiate an outer wall tile at the x coordinate and the current y coordinate. InstantiateFromArray(gameInit.tileSets[0].outerWallTiles, xCoord, currentY, boardHolder, gameInit); currentY++; } }
public override void InstantiateTiles(DungeonModel.TileType[][] tiles, GameObject boardHolder, DungeonSettings gameInit) { // Go through all the tiles in the jagged array... for (int i = 0; i < tiles.Length; i++) { for (int j = 0; j < tiles[i].Length; j++) { // If the tile type is Wall... if (tiles[i][j] == DungeonModel.TileType.Wall) { // ... instantiate a wall over the top. InstantiateFromArray(gameInit.tileSets[0].wallTiles, i, j, boardHolder, gameInit); } else { // ... and instantiate a floor tile for it. InstantiateFromArray(gameInit.tileSets[0].floorTiles, i, j, boardHolder, gameInit); } } } }
protected override void InstantiateHorizontalOuterWall(float startingX, float endingX, float yCoord, GameObject boardHolder, DungeonSettings gameInit) { // Start the loop at the starting value for X. float currentX = startingX; // While the value for X is less than the end value... while (currentX <= endingX) { // ... instantiate an outer wall tile at the y coordinate and the current x coordinate. InstantiateFromArray(gameInit.tileSets[0].outerWallTiles, currentX, yCoord, boardHolder, gameInit); currentX++; } }
public override void InstantiateOuterWalls(DungeonModel.TileType[][] tiles, GameObject boardHolder, DungeonSettings gameInit) { // The outer walls are one unit left, right, up and down from the board. float leftEdgeX = -1f; float rightEdgeX = gameInit.columns + 0f; float bottomEdgeY = -1f; float topEdgeY = gameInit.rows + 0f; // Instantiate both vertical walls (one on each side). InstantiateVerticalOuterWall(leftEdgeX, bottomEdgeY, topEdgeY, boardHolder, gameInit); InstantiateVerticalOuterWall(rightEdgeX, bottomEdgeY, topEdgeY, boardHolder, gameInit); // Instantiate both horizontal walls, these are one in left and right from the outer walls. InstantiateHorizontalOuterWall(leftEdgeX + 1f, rightEdgeX - 1f, bottomEdgeY, boardHolder, gameInit); InstantiateHorizontalOuterWall(leftEdgeX + 1f, rightEdgeX - 1f, topEdgeY, boardHolder, gameInit); }
public override void InstantiateTiles(DungeonModel.TileType[][] tiles, GameObject boardHolder, DungeonSettings gameInit) { // create the Grid object GameObject gridObject = new GameObject("Grid"); gridObject.AddComponent <Grid>(); // create the tileMap object and attach required scripts GameObject tilemapObject = new GameObject("dungeonTilemap"); tilemapObject.AddComponent <Tilemap>(); tilemapObject.AddComponent <TilemapRenderer>(); tilemapObject.AddComponent <TilemapCollider2D>(); tilemapObject.transform.parent = gridObject.transform; // get the tile map component Tilemap tilemap = tilemapObject.GetComponent <Tilemap>(); TilemapRenderer TilemapRenderer = tilemapObject.GetComponent <TilemapRenderer>(); TilemapRenderer.material = dungeonMaterial; tilemapObject.layer = 10; int tileSetIdx = Random.Range(0, gameInit.tileSets.Length - 1); //colorGradient.Init(); // Go through all the tiles in the jagged array... for (int i = 0; i < tiles.Length; i++) { for (int j = 0; j < tiles[i].Length; j++) { TileDungeonTileMap tileDungeonTileMap = ScriptableObject.CreateInstance <TileDungeonTileMap>(); // If the tile type is Wall... if (tiles[i][j] == DungeonModel.TileType.Wall) { // ... instantiate a wall over the top. int randomIndex = Random.Range(0, gameInit.tileSets[tileSetIdx].wallTiles.Length); tileDungeonTileMap.sprite = gameInit.tileSets[tileSetIdx].wallTiles[randomIndex].GetComponent <SpriteRenderer>().sprite; tileDungeonTileMap.colliderType = Tile.ColliderType.Sprite; tileDungeonTileMap.color = wallColor; } else { int randomIndex = Random.Range(0, gameInit.tileSets[tileSetIdx].floorTiles.Length); // ... and instantiate a floor tile for it. tileDungeonTileMap.sprite = gameInit.tileSets[tileSetIdx].floorTiles[randomIndex].GetComponent <SpriteRenderer>().sprite; tileDungeonTileMap.colliderType = Tile.ColliderType.None; tileDungeonTileMap.color = Color.white; //floorColor; } tilemap.SetTile(new Vector3Int(i, j, 0), tileDungeonTileMap); } } //create the minimap tilemapObject = new GameObject("MinimapTilemap"); tilemapObject.AddComponent <Tilemap>(); tilemapObject.AddComponent <TilemapRenderer>(); tilemapObject.transform.parent = gridObject.transform; tilemapObject.layer = 9; //get the tile map component tilemap = tilemapObject.GetComponent <Tilemap>(); for (int i = 0; i < tiles.Length; i++) { for (int j = 0; j < tiles[i].Length; j++) { // If the tile type is Wall... if (tiles[i][j] == DungeonModel.TileType.Floor) { TileDungeonTileMap tileDungeonTileMap = ScriptableObject.CreateInstance <TileDungeonTileMap>(); // ... and instantiate a floor tile for it. Transform temp = gameInit.tileSets[tileSetIdx].floorTiles[0].transform.GetChild(0); tileDungeonTileMap.sprite = temp.gameObject.GetComponent <SpriteRenderer>().sprite; tileDungeonTileMap.colliderType = Tile.ColliderType.None; tileDungeonTileMap.color = Color.yellow; tilemap.SetTile(new Vector3Int(i, j, 0), tileDungeonTileMap); } } } }
/// <summary> /// Default constructor /// </summary> /// <param name="path"></param> /// <param name="userSettings"></param> public PathViewModel(DungeonPath path, DungeonSettings userSettings) { this.PathModel = path; this.userSettings = userSettings; }
/// <summary> /// Default constructor /// </summary> public ApplicationController() { // Create services logger.Debug("Creating services"); this.EventsService = new EventsService(); this.PlayerService = new PlayerService(); this.SystemService = new SystemService(); this.ZoneService = new ZoneService(); this.DungeonsService = new DungeonsService(); this.WvWService = new WvWService(); this.GuildService = new GuildService(); this.TeamspeakService = new TeamspeakService(); this.CommerceService = new CommerceService(); // Create ZoneName view model for the Zone Completion Assistant this.ZoneName = new ZoneNameViewModel(); // Create WvWMap view model for the WvW Tracker this.WvWMap = new WvWMapViewModel(); // Load user settings logger.Debug("Loading event user settings"); this.EventSettings = EventSettings.LoadSettings(EventSettings.Filename); if (this.EventSettings == null) { this.EventSettings = new EventSettings(); } logger.Debug("Loading zone completion assistant user settings"); this.ZoneCompletionSettings = ZoneCompletionSettings.LoadSettings(ZoneCompletionSettings.Filename); if (this.ZoneCompletionSettings == null) { this.ZoneCompletionSettings = new ZoneCompletionSettings(); } logger.Debug("Loading dungeon user settings"); this.DungeonSettings = DungeonSettings.LoadSettings(DungeonSettings.Filename); if (this.DungeonSettings == null) { this.DungeonSettings = new DungeonSettings(); } logger.Debug("Loading wvw user settings"); this.WvWSettings = WvWSettings.LoadSettings(WvWSettings.Filename); if (this.WvWSettings == null) { this.WvWSettings = new WvWSettings(); } logger.Debug("Loading teamspeak settings"); this.TeamspeakSettings = TeamspeakSettings.LoadSettings(TeamspeakSettings.Filename); if (this.TeamspeakSettings == null) { this.TeamspeakSettings = new TeamspeakSettings(); } logger.Debug("Loading commerce settings"); this.CommerceSettings = CommerceSettings.LoadSettings(CommerceSettings.Filename); if (this.CommerceSettings == null) { this.CommerceSettings = new CommerceSettings(); } // Enable autosave on the user settings logger.Debug("Enabling autosave of user settings"); this.EventSettings.EnableAutoSave(); this.ZoneCompletionSettings.EnableAutoSave(); this.DungeonSettings.EnableAutoSave(); this.WvWSettings.EnableAutoSave(); this.TeamspeakSettings.EnableAutoSave(); this.CommerceSettings.EnableAutoSave(); // Create the controllers logger.Debug("Creating browser controller"); this.BrowserController = new BrowserController(); logger.Debug("Creating events controller"); this.EventsController = new EventsController(this.EventsService, this.EventSettings); this.EventsController.Start(); // Get it started for event notifications logger.Debug("Creating zone completion assistant controller"); this.ZoneCompletionController = new ZoneCompletionController(this.ZoneService, this.PlayerService, this.SystemService, this.ZoneName, this.ZoneCompletionSettings); logger.Debug("Creating dungeons controller"); this.DungeonsController = new DungeonsController(this.DungeonsService, this.BrowserController, this.DungeonSettings); logger.Debug("Creating wvw controller"); this.WvWController = new WvWController(this.WvWService, this.PlayerService, this.GuildService, this.WvWMap, this.WvWSettings); this.WvWController.Start(); // Get it started for wvw notifications logger.Debug("Creating commerce controller"); this.CommerceController = new CommerceController(this.CommerceService, this.CommerceSettings); this.CommerceController.Start(); // Get it started for price-watch notifications // Create the event notifications view logger.Debug("Initializing event notifications"); this.eventNotificationsView = new EventNotificationWindow(this.EventsController); this.eventNotificationsView.Show(); // Transparent window, just go ahead and show it // Create the wvw notifications view logger.Debug("Initializing WvW notifications"); this.wvwNotificationsView = new WvWNotificationWindow(this.WvWController); this.wvwNotificationsView.Show(); // Transparent window, just go ahead and show it logger.Debug("Initializing price notifications"); this.priceNotificationsView = new PriceNotificationWindow(this.CommerceController); this.priceNotificationsView.Show(); // Transparent window, just go ahead and show it // Initialize the menu items logger.Debug("Initializing application menu items"); this.BuildMenuItems(); logger.Info("Application controller initialized"); }