public void MoveBy(Point positionChange) { Npc monster = GameLoop.World.CurrentMap.GetEntityAt <Npc>(Position + positionChange); BodyPart bodyPart = GameLoop.World.CurrentMap.GetEntityAt <BodyPart>(Position + positionChange); TileDoor door = GameLoop.World.CurrentMap.GetTileAt <TileDoor>(Position + positionChange); if (monster != null) { Combat.BumpAttack(this, monster); } else if (bodyPart != null) { Mouth.Mastication(bodyPart); } else if (door != null && !door.IsOpen) { UseDoor(door); } else if (GameLoop.World.CurrentMap.IsTileWalkable(Position + positionChange)) { Position += positionChange; GameLoop.UIManager.MapConsole.CenterViewPortOnPoint(GameLoop.World.Player.Position); } else { return; } GameLoop.GSManager.turnTaken = true; }
public override void Populate() { var txtFileLines = File.ReadAllLines(DataManager.Location.LocalPath + "doors.txt"); var typeNames = txtFileLines[1].Split(Separators); for (int i = 2; i < txtFileLines.Length; i++) { var infos = txtFileLines[i].Split('\t'); var category = new TileCategory(); category.Name = infos.Last(); var style = new TileStyle(); category.AddStyle(style); for (int j = 1; j < typeNames.Length - 2; j++) { if (infos[j] != "0") { var tile = new TileDoor { Id = uint.Parse(infos[j]) }; style.List.Add(tile); } } Categories.Add(category); } TilesCategorySDKModule.Supp.PositionCheck(Categories); }
public StateDoorOpen(TileDoor tile) { _tile = tile; tile.DoCollisions = false; Sprite = EnvironmentSpriteFactory.Instance.CreateDoorSprite(true); Sprite.X = (int)tile.Position.X; Sprite.Y = (int)tile.Position.Y; Sprite.FacingRight = tile.FacingRight; }
public bool UseDoor(TileDoor door) { if (door.Locked) { return(false); // TODO } if (!door.Locked && !door.IsOpen) { door.Open(); return(true); } return(false); }
public void Execute(IGameObject gameObject, IGameObject collidedWith) { TileDoor door = (TileDoor)collidedWith; if (!door.FacingRight && door.State is StateDoorClosed && Game1.GetLevel().CurrentWorldState == WorldUtil.WorldState.Transitioning) { door.OnInteract(); } else { ICommandCollision tileCollision = new CommandPlayerTileFromLeftCollision(); tileCollision.Execute(gameObject, collidedWith); } }
public void OpenDoor(Actor actor, TileDoor door, Point pos) { if (!door.IsLocked) { door.Open(); GameLoop.UIManager.MapConsole.IsDirty = true; GameLoop.NetworkingManager.SendNetMessage(0, System.Text.Encoding.UTF8.GetBytes("t_data|door|" + pos.X + "|" + pos.Y + "|open|unlock")); } else { GameLoop.UIManager.MessageLog.Add("The door is locked."); } }
// Triggered when an Actor attempts to move into a doorway. // A closed door opens when used by an Actor. public void UseDoor(Actor actor, TileDoor door) { // Handle a locked door if (door.Locked) { // TODO: make it possible to unlock a door though magic or magic of lockpicks. } // Handled an unlocked door that is closed else if (!door.Locked && !door.IsOpen) { door.Open(); GameLoop.UIManager.MessageLog.Add($"{actor.Name} opened a {door.Name}"); } }
private void CreateDoor(Rectangle room) { List <Point> borderCells = GetPerimiterSquare(room); foreach (Point location in borderCells) { int locationIndex = location.ToIndex(_map.Width); if (IsPotentialDoor(location)) { TileDoor newDoor = new TileDoor(false, false); _map.Tiles[locationIndex] = newDoor; } } }
//Tries to create a TileDoor object in a specified Rectangle //perimeter. Reads through the entire list of tiles comprising //the perimeter, and determines if each position is a viable //candidate for a door. //When it finds a potential position, creates a closed and //unlocked door. private void CreateDoor(Rectangle room) { List <Point> borderCells = GetBorderCellLocations(room); //go through every border cell and look for potential door candidates foreach (Point location in borderCells) { //int locationIndex = location.ToIndex(_map.Width); if (IsPotentialDoor(location)) { // Create a new door that is closed and unlocked. TileDoor newDoor = new TileDoor(false, false, location, "stone"); _map.SetTerrain(newDoor); } } }
// Moves the Actor BY positionChange tiles in any X/Y direction // returns true if actor was able to move, false if failed to move // Checks for Monsters, and allows the Actor to commit // an action if one is present. // TODO: an autopickup feature for items public bool MoveBy(Point positionChange) { // Check the current map if we can move to this new position if (GameLoop.World.CurrentMap.IsTileWalkable(Position + positionChange)) { // if there's a monster here, // do a bump attack Monster monster = GameLoop.World.CurrentMap.GetEntityAt <Monster>(Position + positionChange); //Item item = GameLoop.World.CurrentMap.GetEntityAt<Item>(Position + positionChange); if (monster != null) { GameLoop.CommandManager.Attack(this, monster); return(true); } // if there's an item here, // try to pick it up // implement this like an option // if settings allow auto pickup for example /*else if (item != null) * { * GameLoop.CommandManager.PickUp(this, item); * return true; * }*/ Position += positionChange; return(true); } // Handle situations where there are non-walkable tiles that CAN be used else { // Check for the presence of a door TileDoor door = GameLoop.World.CurrentMap.GetTileAt <TileDoor>(Position + positionChange); // if there's a door here, // try to use it if (door != null) { GameLoop.CommandManager.UseDoor(this, door); return(true); } return(false); } }
/// <summary> /// Triggered when an Actor attempts to move into a doorway. /// A closed door opens when used by an Actor, it takes a full turn because there can be 2 combination, locked and /// unlocked, and im lazy to properly separate the time taken. /// </summary> /// <param name="actor"></param> /// <param name="door"></param> /// <returns></returns> public static bool UseDoor(Actor actor, TileDoor door) { // Handle a locked door if (door.Locked) { // TODO: make it possible to unlock a door though magic or magic of lockpicks. } // Handled an unlocked door that is closed else if (!door.Locked && !door.IsOpen) { door.Open(); GameLoop.UIManager.MessageLog.Add($"{actor.Name} opened a {door.Name}"); GameLoop.World.CurrentMap.ForceFovCalculation(); return(true); } return(false); }
/// <summary> /// Closes an open door /// </summary> /// <param name="actor">Actor that closes the door</param> /// <param name="door">Door that wil be closed></param> public static bool CloseDoor(Actor actor) { Point[] allDirections = SadConsole.PointExtensions.GetDirectionPoints(actor.Position); foreach (Point points in allDirections) { TileDoor possibleDoor = GameLoop.World.CurrentMap.GetTileAt <TileDoor>(points); if (possibleDoor != null) { if (possibleDoor.IsOpen) { possibleDoor.Close(); GameLoop.UIManager.MessageLog.Add($"{actor.Name} closed a {possibleDoor.Name}"); GameLoop.World.CurrentMap.ForceFovCalculation(); return(true); } } } return(false); }