示例#1
0
 public void Move_from_directional_input(Keys key, CmdDirection direction)
 {
     Queue(key);
     Cmd = _strategy.GetCommand(__being);
     Assert.That(Cmd.Action, Is.EqualTo(CmdAction.Direction));
     Assert.That(Cmd.Direction, Is.EqualTo(direction));
 }
示例#2
0
 public Command(CmdAction action, CmdDirection direction, IItem item = null, IUsable usable = null)
 {
     Action    = action;
     Direction = direction;
     Item      = item;
     Usable    = usable;
 }
示例#3
0
        public void Direction_commands_take_time(CmdDirection direction, int tickOff)
        {
            player.MoveTo((2, 2));
            var cmd = new Command(CmdAction.Direction, direction, null);

            _controls.CommandBeing(player, cmd);

            __schedule.Received().AddAgent(player, tickOff);
        }
示例#4
0
        public void Direction_commands_change_location(CmdDirection direction, int newX, int newY)
        {
            var newCoord = new Coord(newX, newY);

            player.MoveTo((2, 2));
            var cmd = new Command(CmdAction.Direction, direction, null);

            _controls.CommandBeing(player, cmd);

            Assert.That(player.GetPosition(), Is.EqualTo(newCoord));
            var mapPosition = _gameState.Map.BeingMap.GetPosition(player);

            Assert.That(mapPosition, Is.EqualTo(newCoord));
        }
示例#5
0
        public void Moving_to_unwalkable_tile_does_nothing(CmdDirection direction)
        {
            __describer.Describe("").ReturnsForAnyArgs("a wall");

            player.MoveTo((3, 2));
            player.IsPlayer = true;
            var cmd = new Command(CmdAction.Direction, direction, null);

            _controls.CommandBeing(player, cmd);

            var curPosition = player.GetPosition();

            Assert.That(curPosition, Is.EqualTo(new Coord(3, 2)));

            __messager.Received().WriteLineIfPlayer(player, "I can't walk through a wall.");
        }
示例#6
0
        public Command(ScsiCommandCode code, byte cdbsize, IntPtr buffer, int bufsize, CmdDirection dir, int timeout)
        {
            m_cdb    = new byte[cdbsize];
            m_cdb[0] = (byte)code;

            m_buffer_size = bufsize;
            if (bufsize == 0)
            {
                m_buffer = IntPtr.Zero;
            }
            else
            {
                m_delete_buffer = false;
                m_buffer        = buffer;
            }

            m_dir     = dir;
            m_timeout = timeout;
        }
        private Command Direction(IBeing being, CmdDirection dir)
        {
            var newPosition = Controls.CoordInDirection(being.GetPosition(), dir);

            var targetRot = gameState.Map.RotMap.GetItem(newPosition);

            if (targetRot != null)
            {
                //0.1.STORY  increase impact--this is an early landmark in the story
                if (!Story.HasClearedRot)
                {
                    rotDirection = dir;
                    Messager.WriteLine("The filth covering the ground sets my teeth on edge.  I'm growling.");
                    return(NextStepIs(Direction_decide_to_Clear_Rot, "Am I going after this stuff bare-handed? ", being));
                }
            }

            return(FinishedCommand(CmdAction.Direction, dir));
        }
示例#8
0
        public Command(ScsiCommandCode code, byte cdbsize, int bufsize, CmdDirection dir, int timeout)
        {
            Debug.Assert(bufsize < UInt16.MaxValue);

            m_cdb = new byte[cdbsize];
            m_cdb[0] = (byte)code;

            m_buffer_size = bufsize;
            if (bufsize == 0)
                m_buffer = IntPtr.Zero;
            else
            {
                m_delete_buffer = true;
                m_buffer = Marshal.AllocHGlobal(bufsize);
                RtlZeroMemory(m_buffer, bufsize);
            }

            m_dir = dir;
            m_timeout = timeout;
        }
示例#9
0
        public Command(ScsiCommandCode code, byte cdbsize, int bufsize, CmdDirection dir, int timeout)
        {
            Debug.Assert(bufsize < UInt16.MaxValue);

            m_cdb    = new byte[cdbsize];
            m_cdb[0] = (byte)code;

            m_buffer_size = bufsize;
            if (bufsize == 0)
            {
                m_buffer = IntPtr.Zero;
            }
            else
            {
                m_delete_buffer = true;
                m_buffer        = Marshal.AllocHGlobal(bufsize);
                RtlZeroMemory(m_buffer, bufsize);
            }

            m_dir     = dir;
            m_timeout = timeout;
        }
        public Command Direction_decide_to_Clear_Rot(AsciiKey press, IBeing being)
        {
            //  Decision mechanic: hit 'y', or travel in a direction
            // towards rot (in which case, the decision direction will
            // be the attack direction, even if different from the original
            // direction).  Any other response cancels move/attack.
            bool affirm = press.Key == Keys.Y;

            if (!affirm)
            {
                var dir = DirectionOf(press);
                if (dir != CmdDirection.None)
                {
                    var dirCoord = Controls.CoordInDirection(being.GetPosition(), dir);
                    var dirRot   = gameState.Map.RotMap.GetItem(dirCoord);

                    affirm = (dirRot != null);
                    if (affirm)
                    {
                        rotDirection = dir;
                    }
                }
            }

            if (affirm)
            {
                Story.HasClearedRot = true;
                WriteLine("Yes.  Now.");
                Log.Info("Decided to clear Rot.");
                return(FinishedCommand(CmdAction.Direction, rotDirection));
            }
            else
            {
                return(CancelMultiStep("Not yet."));
            }
        }
        public Coord CoordInDirection(Coord start, CmdDirection direction)
        {
            int newX = start.X;
            int newY = start.Y;

            if (direction.HasFlag(CmdDirection.North))
            {
                newY--;
            }
            if (direction.HasFlag(CmdDirection.South))
            {
                newY++;
            }
            if (direction.HasFlag(CmdDirection.West))
            {
                newX--;
            }
            if (direction.HasFlag(CmdDirection.East))
            {
                newX++;
            }

            return(newX, newY);
        }
示例#12
0
        public Command(ScsiCommandCode code, byte cdbsize, IntPtr buffer, int bufsize, CmdDirection dir, int timeout)
        {
            m_cdb = new byte[cdbsize];
            m_cdb[0] = (byte)code;

            m_buffer_size = bufsize;
            if (bufsize == 0)
                m_buffer = IntPtr.Zero;
            else
            {
                m_delete_buffer = false;
                m_buffer = buffer;
            }

            m_dir = dir;
            m_timeout = timeout;
        }
示例#13
0
 public virtual void ApplyTo(Coord position, IControlPanel controls, ILogWindow output, CmdDirection direction)
 {
     //output.Add($"Can't use a {Name} on {tile.TileType} to my {direction}.");
 }
 private Command FinishedCommand(CmdAction action, CmdDirection direction, IItem item = null, IUsable usable = null)
 {
     nextStep = null;
     return(new Command(action, direction, item, usable));
 }