public void Destroye() { if (DisplayBlock) { //BuildingBlock block = Entity.GetComponent<BuildingBlock>(); Entity.Kill(); } if (Stair != null) { Stair.Destroye(); } if (FloorFrame != null) { FloorFrame.Destroye(); } if (LadderHatch != null) { LadderHatch.Destroye(); } if (Roof != null) { Roof.Destroye(); } foreach (Block wall in Walls) { wall.Destroye(); } }
protected void ResolveEncountersAtGoal(int x, int y) { Vector2 goal = path[path.Count - 1]; if (x == (int)goal.x && y == (int)goal.y) { Entity entity = grid.GetEntity(x, y); if (entity != null) { // stairs (player only) if ((this is Player) && (entity is Stair)) { Stair stair = (Stair)entity; if (stair.state == EntityStates.Open) { state = CreatureStates.Descending; Dungeon.instance.ExitLevel(stair.direction); } else { Hud.instance.Log("The stair doors are locked."); } } } } }
// Generates the stairs of a single level. private void GenerateLevelStairs(List <Stair> stairList, int currentLevel) { if (stairList.Count > 2) { int placedStairs = 0; while (stairList.Count > 0 && placedStairs < stairsPerLevel) { Stair currentStair = stairList[mapGeneratorScript.GetRandomInteger(0, stairList.Count)]; stairList.Remove(currentStair); if (CanPlaceStair(currentStair.originX, currentStair.originY, currentStair.endX, currentStair.endY, currentLevel)) { PlaceStair(currentStair, currentLevel); placedStairs++; } } if (placedStairs == 0) { ManageError(Error.HARD_ERROR, "Error while populating the map, stairs could not " + "be placed.\nPlease use another input."); } } else if (stairList.Count == 1) { PlaceStair(stairList[0], currentLevel); } else { ManageError(Error.HARD_ERROR, "Error while populating the map, stairs could not be " + "placed.\nPlease use another input."); } }
void Initialize() { stairs = new List<Stair>(); for (int i=0; i<stairInit.Count; i++) { Floor destination; Vector2 enterPos; Vector2 outPos; if (stairInit[i].upper == this) { destination = stairInit[i].lower; enterPos = stairInit[i].goDown; outPos = stairInit[i].goUp; } else { destination = stairInit[i].upper; enterPos = stairInit[i].goUp; outPos = stairInit[i].goDown; } Stair newStair = new Stair(enterPos, outPos, destination, stairInit[i]); stairs.Add(newStair); } // Debug.Log(stairs.Count); isInitialized = true; }
//The main function! This EXACT coroutine will be executed, even across frames. //See GameAction.cs for more information on how this function should work! public override IEnumerator TakeAction() { Debug.Log("Moving levels!"); Stair stair = Map.current.GetTile(caller.location) as Stair; if (stair) { if (stair.upStair ^ up) { yield break; /*bool keepGoing = false; * UIController.singleton.OpenConfirmation($"<color=\"black\">Are you sure you want to go {(up ? "up" : "down")}?", (b) => keepGoing = b); * yield return new WaitUntil(() => !UIController.WindowsOpen); * if (!keepGoing) yield break;*/ } GameController.singleton.MoveToLevel(stair.connectsToFloor); caller.energy -= 100; } else { Debug.Log($"Console: You cannot go {(up ? "up" : "down")} here!"); } }
void Initialize() { stairs = new List <Stair>(); for (int i = 0; i < stairInit.Count; i++) { Floor destination; Vector2 enterPos; Vector2 outPos; if (stairInit[i].upper == this) { destination = stairInit[i].lower; enterPos = stairInit[i].goDown; outPos = stairInit[i].goUp; } else { destination = stairInit[i].upper; enterPos = stairInit[i].goUp; outPos = stairInit[i].goDown; } Stair newStair = new Stair(enterPos, outPos, destination, stairInit[i]); stairs.Add(newStair); } // Debug.Log(stairs.Count); isInitialized = true; }
private bool TryAddStair(MapTile tile, Point location) { BlockType blockType; switch (tile) { case MapTile.DungeonStairs: blockType = BlockType.DungeonStair; break; case MapTile.BasementStairs: blockType = BlockType.BasementStair; break; case MapTile.StairSpecialUp1_1: blockType = BlockType.StairSpecialUp1_1; break; default: return(false); } var stairs = new Stair(_dungeonManager, location, blockType); Collidables.Add(stairs); Drawables.Add(stairs); return(true); }
public void Execute(Actor actor) { if (MapGenerator.IsTileWalkable(actor.Position, Hud.MapWidth, Hud.MapHeight)) { Stair Stairs = GameLoop.GameDataManager.GameMap.GetStairAt(actor.Position); if (Stairs != null) { // **TEST For now there are only two levels with no level tracker so all upstairs go to town if (!Stairs.DownStair) { --GameLoop.GameDataManager.CurrentGameLevel; if (GameLoop.GameDataManager.CurrentGameLevel == 0) { MapGenerator.GenerateTownMap(); } else { MapGenerator.GenerateSquareMap(); } MapGenerator.LoadMap(); return; } ++GameLoop.GameDataManager.CurrentGameLevel; ++GameLoop.GameDataManager.HighestLevelAchieved; MapGenerator.GenerateSquareMap(); MapGenerator.LoadMap(); return; } } else { return; } }
private void GenerateStairs(Stair stair) { StairDisplay newStair = Instantiate(stairDisplayPrefab, this.transform); newStair.transform.localPosition = (Vector3)stair.GetStairPosition(room); newStair.stair = stair; stairDisplays.Add(newStair); }
/// <summary> /// /// </summary> /// <param name="stair"></param> /// <param name="dungeon"></param> public StairControl(Stair stair, Dungeon dungeon) { InitializeComponent(); TargetBox.SetTarget(dungeon, stair.Target); DirectionBox.DataSource = Enum.GetValues(typeof(StairType)); DirectionBox.SelectedItem = stair.Type; Stair = stair; }
IEnumerator ChangeFloorCoroutine(Stair curStair) { Time.timeScale = 0f; fadeImage.ShowFadeImage(); while (!fadeImage.showFadeImageDone) { yield return null; } Time.timeScale = 1f; curStair.GoToExitStair(); }
// Places a stair. private void PlaceStair(Stair stair, int currentLevel) { if (stair.originY == stair.endY) { if (stair.originX > stair.endX) { maps[currentLevel][stair.originX, stair.originY] = stairCharLeft; } else { maps[currentLevel][stair.originX, stair.originY] = stairCharRigth; } } else { if (stair.originY > stair.endY) { maps[currentLevel][stair.originX, stair.originY] = stairCharUp; } else { maps[currentLevel][stair.originX, stair.originY] = stairCharDown; } } for (int j = 1; j < stairLength - 1; j++) { if (stair.originY == stair.endY) { if (stair.originX > stair.endX) { maps[currentLevel][stair.originX - j, stair.originY] = voidChar; } else { maps[currentLevel][stair.originX + j, stair.originY] = voidChar; } } else { if (stair.originY > stair.endY) { maps[currentLevel][stair.originX, stair.originY + j] = voidChar; } else { maps[currentLevel][stair.originX, stair.originY - j] = voidChar; } } } }
public void stair(Stair stair) { AuM.playAudio("door"); GDM.saveCurrentFloorToTemp(); if (stair.type == Stair.stairType.up) { int floor = Convert.ToInt16(Application.loadedLevelName) + 1; GM.changeFloor(floor, "up"); } else if (stair.type == Stair.stairType.down) { int floor = Convert.ToInt16(Application.loadedLevelName) - 1; GM.changeFloor(floor, "down"); } }
public void SaveAndClose() { Stair newStair = new Stair(); newStair.id = UIController.stairId++; newStair.NextFloorId = int.Parse(UpFloor.GetComponent <InputField>().text); newStair.PrevFloorId = int.Parse(DownFloor.GetComponent <InputField>().text); newStair.NextStairId = int.Parse(UpStair.GetComponent <InputField>().text); newStair.PrevStairId = int.Parse(DownStair.GetComponent <InputField>().text); newStair.placement = UIController.objectPosition; UIController.CurrentFloor.StairList.Add(newStair); Destroy(UIController.CurrentPanel); UIController.gm.SetActive(true); UIController.HideLines(false); }
//TODO: Determine how monsters get placed if they don't have space to be placed public void MoveMonsters(Monster m, Stair stair, Map map) { if (stair.upStair) { Vector2Int offset = m.location - stair.location; m.SetPosition(map.exits[stair.stairPair] + offset); } else { Vector2Int offset = m.location - stair.location; m.SetPosition(map.entrances[stair.stairPair] + offset); } m.transform.parent = map.monsterContainer; }
void Traverse(Stair stair) { if (stair.IsObjGoingUp(this.gameObject)) { ChangeLevel(stair.GetTopLevel()); } else if (stair.IsObjGoingDown(this.gameObject)) { ChangeLevel(stair.GetBaseLevel()); } else { Debug.LogError("This should not be happening."); Debug.Break(); } }
private void GenerateDungeonFeatures(int direction) { // Generate architecture for each tree quad recursively ArchitectureGenerator architecture = new ArchitectureGenerator(); architecture.GenerateArchitecture(dungeonGenerator.quadTree); // Generate stairs StairGenerator stairs = new StairGenerator(); stairs.Generate(); // If we cannot solve the level, we need to generate a different one if (!LevelIsSolvable()) { Debug.LogError("Dungeon level cannot be solved. Genrating again..."); GenerateDungeon(direction); return; } // Generate player PlayerGenerator player = new PlayerGenerator(); Stair stair = direction == -1 ? grid.stairDown : grid.stairUp; player.GenerateAtPos(stair.x, stair.y); // Generate furniture FurnitureGenerator furniture = new FurnitureGenerator(); furniture.Generate(); // Generate monsters MonsterGenerator monsters = new MonsterGenerator(); monsters.Generate(); //monsters.GenerateSingle(); // Generate chests ChestGenerator chests = new ChestGenerator(); chests.Generate(); // Generate items ItemGenerator items = new ItemGenerator(); items.Generate(); }
internal WorldLayer GenerateNewLayer(Creature _creature, Stair _stair) { var rnd = new Random(_creature[0, 0].LiveMapBlock.MapBlock.RandomSeed); var n = rnd.Next(); WorldLayer layer; switch (n % 1) { case 0: layer = new TreeMazeDungeonLayer(_creature[0, 0].WorldCoords, rnd); break; default: throw new ArgumentOutOfRangeException(); } layer.AddStair(_creature.GeoInfo.Layer, _creature[0, 0].WorldCoords, _stair); return(layer); }
GameObject CreateStairDownAtPosition(Vector3 position, Vector3 direction, float creationTime) { GameObject stairDownObject = Instantiate(StairDownPrototype); Stair stairDown = stairDownObject.GetComponent <Stair>(); //StairCreationBehaviour stairDown = new StairCreationBehaviour(); //stairDown.Name = "DOWN"; //stairDown.Stair = stairDownObject; //stairDown.CreationTime = creationTime; stairDown.Position = position; //Debug.Log("setting inclination of newly created Stair Down"); //stairDown.Inclination = StairCreationBehaviour.InclinationDirection.Down; stairDown.Direction = direction; stairDownObject.SetActive(true); return(stairDownObject); }
protected override void Init() { stair = GameObject.Find("Stair").GetComponent <Stair>(); for (int i = 0; i < buttons.Length; i++) { if (buttons[i].name == "Yes") { buttons[i].onClick.AddListener(GoToNextFloor); } else if (buttons[i].name == "No") { buttons[i].onClick.AddListener(Cancel); } else { buttons[i].onClick.AddListener(null); } } }
private bool CheckForStair() { var hit = Physics2D.Raycast(transform.position, Vector2.down, 2f, StairLayerMask); Debug.DrawRay(transform.position, Vector2.down, Color.red); if (hit) { var stair = hit.transform.GetComponent <Stair>(); if (stair != null) { actualStair = stair; return(true); } } return(false); }
private static void PlaceStairs(bool notTown = false) { GameLoop.GameDataManager.Stairs = new List <Stair>() { }; Stair Downstairs = new Stair(Color.White, Color.Transparent, "Down Stairs", true, '>'); Downstairs.Position = SadConsole.Helpers.GetPointFromIndex((GameLoop.GameDataManager.GameMap.Height / 2) * Hud.MapWidth + (GameLoop.GameDataManager.GameMap.Width / 2), Hud.MapWidth); GameLoop.GameDataManager.Stairs.Add(Downstairs); Hud.MapConsole.Children.Add(Downstairs); // **TEST this is just to guarantee an upstairs on the non-town level if (notTown) { Stair UpStairs = new Stair(Color.White, Color.Transparent, "Up Stairs", false, '<'); UpStairs.Position = SadConsole.Helpers.GetPointFromIndex((GameLoop.GameDataManager.GameMap.Height / 2) * Hud.MapWidth + (GameLoop.GameDataManager.GameMap.Width / 2 - 1), Hud.MapWidth); GameLoop.GameDataManager.Stairs.Add(UpStairs); Hud.MapConsole.Children.Add(UpStairs); } }
public void SpawnStair(Vector3 position, int direction) { if (stairQueue.Count == 0) // No stair to spawn { return; } GameObject stairObj = stairQueue.Dequeue(); Stair stair = stairObj.GetComponent <Stair>(); stair.SetOrientation(Stair.Orientation.Horizontal); Vector3 scale = stair.transform.localScale; scale.x = stair.transform.localScale.x * direction; stair.transform.localScale = scale; stairObj.transform.position = position; stairObj.SetActive(true); OnStairChange?.Invoke(stairQueue.Count); }
private void MoveLevel() { Stair stair = Map.current.GetTile(player.location) as Stair; Map old = Map.current; if (stair) { LoadMap(nextLevel); MoveMonsters(player, stair, Map.current); } else { UnityEngine.Debug.Log("You are unable to change levels."); } nextLevel = -1; LOS.lastCall.Deprint(old); LOS.lastCall = null; CameraTracking.singleton.JumpToPlayer(); LOS.GeneratePlayerLOS(Map.current, player.location, player.visionRadius); }
private void OnTriggerEnter2D(Collider2D other) { Stair stair = other.GetComponentInParent <Stair>(); if (stair != null) { focusedStair = other.GetComponentInParent <Stair>(); if (other.CompareTag("Stair")) { canClimb = true; } if (other.CompareTag("StairBase")) { canRotateStair = true; } } //if (layerWalkable == other.gameObject.layer /*other.CompareTag("Ground")*/) //{ // grounded = true; //} if (other.CompareTag("Pickup")) { Pickup pickup = other.GetComponent <Pickup>(); if (pickup.restore) { health.Restore(pickup.health); } SoundController.Instance.PlaySFX(10); Destroy(pickup.gameObject); } }
public void SpawnEntitys() { if (DisplayBlock) { BuildingBlock block = Entity.GetComponent <BuildingBlock>(); if (block != null) { } Entity.Spawn(); if (block != null) { block.SetGrade(BuildingGrade.Enum.TopTier); block.SetHealthToMax(); block.cachedStability = 100; } } if (Stair != null) { Stair.SpawnEntitys(); } if (FloorFrame != null) { FloorFrame.SpawnEntitys(); } if (LadderHatch != null) { LadderHatch.SpawnEntitys(); } if (Roof != null) { Roof.SpawnEntitys(); } foreach (Block wall in Walls) { wall.SpawnEntitys(); } }
public void UpdateStair(Stair stair) { _context.Entry(stair).State = EntityState.Modified; }
public async Task AddAsync(Stair stair) { await _context.AddAsync(stair); }
public void stair(int x, int y, TileData otherTileData) { Stair stair = otherTileData.gameObject.GetComponent <Stair>(); _GM.changeFloor(stair.floor); }
public void ChangeFloor(Stair curStair) { StartCoroutine(ChangeFloorCoroutine(curStair)); }
public override void AddStair(WorldLayer _enterFromLayer, Point _worldCoords, Stair _stair) { var blockId = BaseMapBlock.GetBlockId(EnterCoords); var inBlockCoords = BaseMapBlock.GetInBlockCoords(EnterCoords); var block = this[blockId]; if (_stair is StairUp) { block.AddEssence(new StairDown(_enterFromLayer, EssenceHelper.GetFirstFoundedMaterial <MineralMaterial>()), inBlockCoords); } else { block.AddEssence(new StairUp(_enterFromLayer, EssenceHelper.GetFirstFoundedMaterial <MineralMaterial>()), inBlockCoords); } }
private IfcStair CreateIfcStair(IfcStore model, Stair stair) { //begin a transaction using (var trans = model.BeginTransaction("Create Stair")) { IfcStair stairToCreate = model.Instances.New <IfcStair>(); stairToCreate.Name = " stair - Wall:UC305x305x97:" + 1500; IfcDirection extrusionDir = model.Instances.New <IfcDirection>(); extrusionDir.SetXYZ(0, 0, -1); //Create a Definition shape to hold the geometry of the Stair 3D body IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body"); for (int i = 0; i < stair.LstStep.Count; i++) { IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (stair.LstStep[i].Vertices /*.Select(v => v * 1000)*/).ToList()); IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, stair.Thickness, stepProfile, extrusionDir); body.BodyPlacementSet(model, 0, 0, stair.IsUp ? stair.Thickness * i : stair.Thickness * -i); shape.Items.Add(body); } //Create a Product Definition and add the model geometry to the wall IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>(); prDefShape.Representations.Add(shape); IfcStairFlight flight = model.Instances.New <IfcStairFlight>(); flight.Representation = prDefShape; IfcRelAggregates relAggregate = model.Instances.New <IfcRelAggregates>(); relAggregate.RelatingObject = stairToCreate; relAggregate.RelatedObjects.Add(flight); //Create Local axes system and assign it to the column IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>(); location3D.SetXYZ(0, 0, 0); //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir); IfcDirection localXDir = model.Instances.New <IfcDirection>(); localXDir.SetXYZ(1, 0, 0); IfcDirection localZDir = model.Instances.New <IfcDirection>(); localZDir.SetXYZ(0, 0, 1); IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir); //now place the slab into the model IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D); flight.ObjectPlacement = lp; trans.Commit(); return(stairToCreate); } }
public override void PostActivation(Map m) { int c = 0; for (int i = 0; i < stairsUp.Count; i++) { for (int j = 0; j < stairsUp[i].numConnections; j++) { Stair stairs = m.GetTile(ups[c]) as Stair; if (stairs) { if (stairsUp[i].next) { stairs.connectsToFloor = m.depth - 1; } else { stairs.connectsToFloor = LevelLoader.singleton.GetDepthOf(stairsUp[i].connectsTo); } stairs.stairPair = stairsUp[i].connectionsStartAt + j; } else { Debug.LogError("Grabbed tile that was not stair!", this); } c++; } } for (int i = 0; i < ups.Count; i++) { m.entrances.Add(ups[i]); } c = 0; for (int i = 0; i < stairsDown.Count; i++) { for (int j = 0; j < stairsDown[i].numConnections; j++) { Stair stairs = m.GetTile(downs[c]) as Stair; if (stairs) { if (stairsDown[i].next) { stairs.connectsToFloor = m.depth + 1; } else { stairs.connectsToFloor = LevelLoader.singleton.GetDepthOf(stairsDown[i].connectsTo); } stairs.stairPair = stairsDown[i].connectionsStartAt + j; } else { Debug.LogError("Grabbed tile that was not stair!", this); } c++; } } for (int i = 0; i < downs.Count; i++) { m.exits.Add(downs[i]); } m.numStairsUp = stairsUp.Sum(x => x.numConnections); m.numStairsDown = stairsDown.Sum(x => x.numConnections); }