示例#1
0
        public void MoveBoat(Point3D p)
        {
            if (m_Galleon == null || m_Galleon.Contains(p))
            {
                return;
            }

            int x = p.X;
            int y = p.Y;
            int speed;
            int flee = Aggressive ? 1 : -1;

            //Direction d = Utility.GetDirectionTo(p.X, p.Y);
            Direction dir = m_Galleon.GetMovementFor(x, y, out speed);
            Direction f   = m_Galleon.Facing;

            if (!Aggressive)
            {
                dir = (Direction)(((int)dir + -4) & 0x7);
            }

            if (dir == Direction.West || dir == Direction.Left || dir == Direction.South)
            {
                m_Galleon.Turn(-2 * flee, true);
                m_NextMoveCheck = DateTime.UtcNow + TimeSpan.FromSeconds(m_Galleon.TurnDelay);
                return;
            }

            if (dir == Direction.East || dir == Direction.Down)
            {
                m_Galleon.Turn(2 * flee, true);
                m_NextMoveCheck = DateTime.UtcNow + TimeSpan.FromSeconds(m_Galleon.TurnDelay);
                return;
            }

            m_Galleon.StartMove(dir, true);
        }