Ejemplo n.º 1
0
        public void FinalizeBranchDungeonPosition(IDungeonBranch fromBranch, int fromIndex, int destIndex, Map.Staircase.StaircaseDirection stairDirection)
        {
            int indexDiff = fromIndex - destIndex + (stairDirection == Staircase.StaircaseDirection.Down ? 1 : -1);

            int fromPosition = Game.Current.Dungeon.GetBranchPosition(fromBranch);

            Game.Current.Dungeon.SetBranchPosition(this, fromPosition + indexDiff);

            PositionFinalized = true;
        }
        public DungeonBranchConnection(IDungeonBranch destination, Map.Staircase.StaircaseDirection direction, int earliestAppearance, int lastAppearance, int minDestIndex, int maxDestIndex)
        {
            DestinationBranch       = destination;
            StairDirection          = direction;
            EarliestIndex           = earliestAppearance;
            LatestIndex             = lastAppearance;
            MinimumDestinationIndex = minDestIndex;
            MaximumDestinationIndex = maxDestIndex;

            StaircaseCreated = false;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the specified branch to be the currently occupied branch. If the branch does not exist in the dungeon,
 /// an exception will be thrown.
 /// </summary>
 /// <param name="branch"></param>
 public void SetCurrentBranch(IDungeonBranch branch, bool suppressMovementEvents = false)
 {
     if (branch != CurrentBranch)
     {
         if (DungeonBranches.Contains(branch))
         {
             CurrentBranch = branch;
             if (!suppressMovementEvents)
             {
                 CurrentBranch.EnterDungeonBranch();
             }
         }
         else
         {
             throw new InvalidOperationException(string.Format(ErrorMessages.DungeonBranchNotFound, branch.Name));
         }
     }
 }
Ejemplo n.º 4
0
        private void EnterDungeon()
        {
            IDungeonBranch startingBranch = Dungeon.DungeonBranches.FirstOrDefault();

            startingBranch.EnterDungeonBranch();

            Dungeon.SetCurrentMap(startingBranch.CreateNewLevel(0));

            // Generate a monster to fight for now./
            Dungeon.CurrentMapState.GenerateNewMonster();

            DungeonLocation startingLocation = new DungeonLocation(
                startingBranch,
                0,
                Dungeon.CurrentMapState.SelectRandomWalkableTile(false));

            // Place the player.
            Dungeon.MovePlayerToLocation(startingLocation, true);
        }
Ejemplo n.º 5
0
        public override void CreateDungeonBranchConnections(IEnumerable <IDungeonBranch> branches)
        {
            base.CreateDungeonBranchConnections(branches);

            IDungeonBranch debugBranch = branches.Where(b => b is DebugDungeonBranch).FirstOrDefault();

            if (debugBranch != null)
            {
                DungeonBranchConnection connection = new DungeonBranchConnection(
                    debugBranch,
                    Map.Staircase.StaircaseDirection.Down,
                    1,
                    3,
                    0,
                    3
                    );

                AddBranchConnection(connection);
            }
            else
            {
                Game.Current.Messages.AddDebugMessage(ErrorMessages.MissingBranchForConnection, "DebugDungeonBranch");
            }
        }
Ejemplo n.º 6
0
 public DungeonLocation(IDungeonBranch branch, int levelIndex, Position position)
 {
     Branch             = branch;
     DungeonBranchLevel = levelIndex;
     MapPosition        = position;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds a dungeon branch to the dungeon.
 /// </summary>
 /// <param name="branch">The new branch to add.</param>
 /// <param name="topLevel">The dungeon level that the top level of this branch is on.</param>
 public void AddDungeonBranch(IDungeonBranch branch, int topLevel)
 {
     _dungeonBranches.Add(branch, topLevel);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets the number of levels from the dungeon start of a branch.
 /// </summary>
 /// <param name="branch"></param>
 /// <returns></returns>
 public int GetBranchPosition(IDungeonBranch branch)
 {
     return(_dungeonBranches[branch]);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Sets the number of levels from the top of the dungeon the branch is.
 /// </summary>
 /// <param name="branch">The branch to update.</param>
 /// <param name="position">The number of levels from the dungeon start.</param>
 public void SetBranchPosition(IDungeonBranch branch, int position)
 {
     _dungeonBranches[branch] = position;
 }