Beispiel #1
0
        private void MovePlayerToLocation_Internal(Staircase sendingStairs, DungeonLocation location, bool suppressMovementEvents)
        {
            if (location == null)
            {
                location = sendingStairs.Destination;
            }

            // Make sure that this dungeon branch does in fact exist.
            if (DungeonBranches.Contains(location.Branch))
            {
                SetCurrentBranch(location.Branch, suppressMovementEvents);

                if (!CurrentBranch.DungeonLevelExists(location.DungeonBranchLevel))
                {
                    CurrentBranch.CreateNewLevel(location.DungeonBranchLevel);
                    if (sendingStairs != null)
                    {
                        // The map position shoud be populated on the staircase now.
                        location = sendingStairs.Destination;
                    }
                }

                CurrentMapState = CurrentBranch.GetDungeonLevel(location.DungeonBranchLevel);
                Game.Current.Player.Position = location.MapPosition;

                // Update the dungeon level.
                CurrentDungeonLevel = _dungeonBranches[CurrentBranch] + CurrentMapState.DungeonBranchIndex;
            }
            else
            {
                throw new InvalidOperationException(string.Format(ErrorMessages.DungeonBranchNotFound, location.Branch.Name));
            }
        }
Beispiel #2
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));
         }
     }
 }