Ejemplo n.º 1
0
        /// <summary>
        /// Посылка команд в соответствии с координатами ThumbStick-джойстика.
        /// </summary>
        /// <param name="x">x-координата ThumbStick-джойстика.</param>
        /// <param name="y">y-координата ThumbStick-джойстика.</param>
        public void Look(float x, float y)
        {
            this.CheckCommunicationHelper();

            if (!this.controlSettings.ReverseHeadTangage)
            {
                y = -y;
            }

            LookHelper.CorrectCoordinatesFromCyrcleToSquareArea(ref x, ref y);

            if ((x != this.lookX) || (y != this.lookY))
            {
                if (this.horizontalFixedControl)
                {
                    this.horizontalFixedControl = false;
                    this.fixedLookX             = this.controlSettings.HorizontalForwardDegree;
                }

                if (this.verticalFixedControl)
                {
                    this.verticalFixedControl = false;
                    this.fixedLookY           = this.controlSettings.VerticalForwardDegree;
                }
            }

            if ((this.horizontalFixedControl == false) && (this.verticalFixedControl == false))
            {
                // x = f(x)...
                this.GenerateHorizontalServoCommand(x, out this.horizontalServoCommand);
                this.communicationHelper.SendMessageToRobot(this.horizontalServoCommand);
                this.lookX = x;

                // y = f(y)...
                this.GenerateVerticalServoCommand(y, out this.verticalServoCommand);
                this.communicationHelper.SendMessageToRobot(this.verticalServoCommand);
                this.lookY = y;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Генерация и передача команды очень-очень грустного настроения.
        /// </summary>
        /// <param name="lookHelper">
        /// Экземпляр класса для управления обзором.
        /// </param>
        public void ShowReadyToPlay(LookHelper lookHelper)
        {
            this.communicationHelper.SendNonrecurrentMessageToRobot("M0102", "M0000");
            this.mood = Mood.Normal;

            lookHelper.FixedLook(lookHelper.FixedLookX, this.controlSettings.VerticalReadyToPlayDegree);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Генерация и передача команды очень-очень грустного настроения.
        /// </summary>
        /// <param name="lookHelper">
        /// Экземпляр класса для управления обзором.
        /// </param>
        public void ShowDepression(LookHelper lookHelper)
        {
            this.communicationHelper.SendNonrecurrentMessageToRobot("M0103", "M0000");
            this.mood = Mood.Blue;

            lookHelper.FixedLook(lookHelper.FixedLookX, this.controlSettings.VerticalMinimumDegree);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the GameRobot class.
        /// </summary>
        public GameRobot()
        {
            this.IsFixedTimeStep = false;
            this.graphics = new GraphicsDeviceManager(this);
            this.graphics.SynchronizeWithVerticalRetrace = false;

            // this.graphics.IsFullScreen = true;
            // this.IsMouseVisible = false;
            Content.RootDirectory = "Content";

            this.controlSettingsHelper = new ControlSettingsHelper();
            this.controlSettingsHelper.Load();

            this.communicationHelper = new UdpCommunicationHelper(
                this.controlSettingsHelper.Settings.RoboHeadAddress,
                this.controlSettingsHelper.Settings.UdpSendPort,
                this.controlSettingsHelper.Settings.UdpReceivePort,
                this.controlSettingsHelper.Settings.SingleMessageRepetitionsCount);

            this.flashlightHelper = new FlashlightHelper(this.communicationHelper);
            this.driveHelper = new DriveHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.lookHelper = new LookHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.moodHelper = new MoodHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.gunHelper = new GunHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.videoHelper = new VideoHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
            this.audioHelper = new AudioHelper(this.communicationHelper, this.controlSettingsHelper.Settings);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Создание экземпляра класса LookHelper.
        /// </summary>
        /// <returns>
        /// Созданный и инициированный экземпляр.
        /// </returns>
        private LookHelper CreateLookHelper()
        {
            var mock = new Mock<ICommunicationHelper>();
            mock.Setup(x => x.SendMessageToRobot(It.IsAny<string>())).Returns(true);

            var result = new LookHelper(mock.Object, this.controlSettings);
            return result;
        }