private void DrawRoomObjects(string type, DungeonRoom room, Vector3 offset) { List <DungeonRoomObject> objs = room.roomObjects; PlanetVisualData dataSet = GetVisualDataSet(type); //GameObject puzzleHolder = new GameObject("Block push puzzle holder"); //Rigidbody2D rb = puzzleHolder.AddComponent<Rigidbody2D>(); //rb.gravityScale = 0f; //rb.bodyType = RigidbodyType2D.Static; //puzzleHolder.AddComponent<CompositeCollider2D>(); //puzzleHolder.transform.parent = objectParent; for (int i = 0; i < objs.Count; i++) { DungeonRoomObject obj = objs[i]; if (obj.IsCreated) { continue; } string objName = obj.ObjectName; Vector3 pos = obj.RoomSpacePosition + offset; DungeonRoomObjectComponent newObj = GetObjectToSpawn(objName); if (newObj == null) { continue; } newObj.Setup(this, obj); newObj.transform.parent = obj.IsPersistent ? null : objectParent; if (obj.IsPersistent) { obj.IsCreated = true; } } }
public void AddKey(int lockID) { IntPair pos = GetRandomPositionInRoom; DungeonRoomObject key = new DungeonRoomObject(this, pos, $"Key{lockID}", null, false); roomObjects.Add(key); }
public override void GenerateContent() { base.GenerateContent(); IntPair pos = CenterInt + IntPair.up; DungeonRoomObject treasureChest = new DungeonRoomObject(this, pos, "TreasureChest", null, false); roomObjects.Add(treasureChest); }
private void SetUpLoot() { for (int i = 0; i < roomObjects.Count; i++) { DungeonRoomObject obj = roomObjects[i]; if (obj.ObjectName == "Key") { obj.RoomSpacePosition = idealLootPosition; } } }
public override void GenerateContent() { base.GenerateContent(); List <DungeonRoomEnemy> enemies = EnemyRoomData.GenerateChallenge(difficulty, this); roomObjects.AddRange(enemies); IntPair pos = CenterInt * IntPair.right + InnerDimensions * IntPair.up; DungeonRoomObject treasureChest = new DungeonRoomObject(this, pos, "LockedTreasureChest", null, false); roomObjects.Add(treasureChest); }
public override void GenerateContent() { base.GenerateContent(); IntPair landingPadPos = CenterInt + IntPair.down * 3; DungeonRoomObject landingPad = new DungeonRoomObject(this, landingPadPos, "LandingPad", null, false); roomObjects.Add(landingPad); IntPair playerPos = landingPadPos + IntPair.down * 2; DungeonRoomObject player = new DungeonRoomObject(this, playerPos, "PlanetPlayer", null, true); roomObjects.Add(player); }
public override void GenerateContent() { base.GenerateContent(); Generator gen = new Generator(); int padding = 1; int minimumSolutionCount = 1; puzzle = gen.Generate(PuzzleSize, padding, minimumSolutionCount); puzzle.OnPuzzleCompleted += UnlockAllExitsOfLockTypeNone; Debug.Log(puzzle.GridSize); IntPair offset = IntPair.one; int tileSize = ExitWidth; for (int i = 0; i < puzzle.grid.Length; i++) { IntPair puzzlePos = puzzle.GetPositionFromIndex(i); bool isBlock = puzzle.BlockExists(puzzlePos); if (!isBlock) { continue; } DungeonRoomObject roomBlock = new DungeonRoomObject( this, puzzlePos * tileSize + offset, "PushableBlock", puzzlePos, false); roomObjects.Add(roomBlock); } DungeonRoomObject finishButton = new DungeonRoomObject(this, puzzle.finishTile * tileSize + offset, "GreenButton", (Action)puzzle.CompletePuzzle, false); roomObjects.Add(finishButton); for (int i = 0; i < puzzle.resetTiles.Length; i++) { DungeonRoomObject resetButton = new DungeonRoomObject(this, puzzle.resetTiles[i] * tileSize + offset, "RedButton", (Action)puzzle.RevertLastChange, false); roomObjects.Add(resetButton); } LockAllExceptPreviousRoom(); }
public override void GenerateContent() { base.GenerateContent(); Generator gen = new Generator(); puzzleGrid = gen.GeneratePuzzle(puzzleGrid.GridSize, (int)puzzleDifficulty); IntPair offset = new IntPair(RoomWidth / 2 - puzzleGrid.GridSize.x / 2, RoomHeight / 2 - puzzleGrid.GridSize.y / 2); for (int i = 0; i < puzzleGrid.GetArrayLength(); i++) { IntPair pos = puzzleGrid.GetPosition(i); bool flipped = puzzleGrid.IsFlipped(i); DungeonRoomObject tileLight = new DungeonRoomObject(this, pos + offset, "FlipTile", i, false); roomObjects.Add(tileLight); } }
public void AddExit(Direction direction, IntPair exitPos) { bool isHorizontal = direction.IsHorizontal(); IntPair intDirection = direction.ToVector2(); if (isHorizontal) { exitPos.x = boundaries[direction] + intDirection.x; } else { exitPos.y = boundaries[direction] + intDirection.y; } SetExit(direction, true, exitPos); for (int i = 0; i < EXIT_WIDTH; i++) { IntPair lineIntDir = direction.Clockwise().ToPositiveDirection().ToVector2(); IntPair pos = exitPos + lineIntDir * i; DungeonRoomObject newTrigger = new DungeonRoomObject(this, pos, "ExitTrigger", direction, false); roomObjects.Add(newTrigger); } }
public void RemoveObject(DungeonRoomObject obj) => roomObjects.Remove(obj);
public virtual void Setup(DungeonRoomViewer viewer, DungeonRoomObject roomObject) { Viewer = viewer; RoomObject = roomObject; Position = roomObject.Position; }