Пример #1
0
        /// <summary>
        /// Move the team
        /// </summary>
        /// <param name="offset">Step offset</param>
        /// <returns>True if the team moved, or false</returns>
        private bool Move(Point offset)
        {
            // Can't move and force is false
            if (!CanMove)
            {
                return(false);
            }

            // Get informations about the destination square
            Point dst = Location.Coordinate;

            dst.Offset(offset);


            // Check all blocking states
            bool state = true;

            // Is blocking
            Square dstsquare = Maze.GetSquare(dst);

            if (dstsquare.IsBlocking)
            {
                state = false;
            }

            // Monsters
            if (dstsquare.MonsterCount > 0)
            {
                state = false;
            }

            // If can't pass through
            if (!state)
            {
                GameMessage.BuildMessage(1);
                return(false);
            }


            // Leave the current square
            if (Square != null)
            {
                Square.OnTeamLeave();
            }


            Location.Coordinate.Offset(offset);
            LastMove = DateTime.Now;
            HasMoved = true;

            // Enter the new square
            Square = Maze.GetSquare(Location.Coordinate);
            if (Square != null)
            {
                Square.OnTeamEnter();
            }


            return(true);
        }
Пример #2
0
        /// <summary>
        /// Teleport the team to a new location, but don't change direction
        /// </summary>
        /// <param name="location">Location in the dungeon</param>
        /// <returns>True if teleportion is ok, or false if M. Spoke failed !</returns>
        public bool Teleport(DungeonLocation location, Dungeon dungeon)
        {
            if (dungeon == null || location == null)
            {
                return(false);
            }

            // Destination maze
            Maze maze = dungeon.GetMaze(location.Maze);

            if (maze == null)
            {
                return(false);
            }

            Maze = maze;

            // Leave current square
            if (Square != null)
            {
                Square.OnTeamLeave();
            }

            // Change location
            Location.Coordinate = location.Coordinate;
            Location.Maze       = Maze.Name;
            Location.Direction  = location.Direction;


            // New block
            Square = Maze.GetSquare(location.Coordinate);

            // Enter new block
            Square.OnTeamEnter();

            return(true);
        }