コード例 #1
0
        /// <summary>
        /// Watch for arrow keys.
        /// </summary>
        private void HandleInput()
        {

            // Move editing focus to next bot parameter.
            if (this.m_input.IsNewKeyPress(Keys.Down))
            {

                // Select next parameter, but don't go out of range.
                this.m_currentParamIndex += 1;
                this.m_currentParamIndex = Math.Min(this.m_currentParamIndex, (this.m_botParams.Count - 1));

                // Note newly selected parameter.
                this.m_currentParam = this.m_botParams[this.m_currentParamIndex];

            }

            // Move editing focus to previous bot parameter.
            if (this.m_input.IsNewKeyPress(Keys.Up))
            {

                // Select previous parameter, but don't go out of range.
                this.m_currentParamIndex -= 1;
                this.m_currentParamIndex = Math.Max(this.m_currentParamIndex, 0);

                // Note newly selected parameter.
                this.m_currentParam = this.m_botParams[this.m_currentParamIndex];

            }

            // Increment current parameter value.
            if (this.m_input.IsNewKeyPress(Keys.Right))
            {
                this.m_currentParam.Value += 0.1f;
                if (this.m_currentParam.IsBoolean == true)
                {
                    this.m_currentParam.Value = 1f;
                }
            }

            // Decrement current parameter value.
            if (this.m_input.IsNewKeyPress(Keys.Left))
            {
                this.m_currentParam.Value -= 0.1f;
                this.m_currentParam.Value = Math.Max(this.m_currentParam.Value, 0);
                if (this.m_currentParam.IsBoolean == true)
                {
                    this.m_currentParam.Value = 0f;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="backgroundFadeAlpha"></param>
        public override bool Draw(float backgroundFadeAlpha)
        {
            if (base.Draw(backgroundFadeAlpha) == false) return false;

            const float TEXT_DISTANCE_Y = 0.025f;
            const float TEXT_SCALE = 0.5f;

            List<StringBuilder> texts = new List<StringBuilder>(20);
            texts.Add(new StringBuilder("BOT DEBUG SCREEN"));
            texts.Add(new StringBuilder(String.Empty));

            if (BotExists())
            {
                // Non-persistence disclaimer.
                texts.Add(new StringBuilder("Use this debug screen to test different bot settings in"));
                texts.Add(new StringBuilder("order to find those that 'feel' best. Note that these settings"));
                texts.Add(new StringBuilder("are just for experimentation and don't persist. Final changes"));
                texts.Add(new StringBuilder("must be made in the code itself."));
                texts.Add(new StringBuilder(String.Empty));

                // Camera.
                texts.Add(new StringBuilder("Camera.CameraAttachedTo = " + MyGuiScreenGamePlay.Static.CameraAttachedTo.ToString()));
                texts.Add(new StringBuilder("MySpectator.Position = " + MyUtils.GetFormatedVector3(MySpectator.Position,0)));
                texts.Add(new StringBuilder("Camera.ThirdPersonCamDelta = " + MyUtils.GetFormatedVector3( MyGuiScreenGamePlay.Static.ThirdPersonCameraDelta, 0 )));
                texts.Add(new StringBuilder(String.Empty));

                // Bot info.
                //double angle = this.m_bot.AngleBetweenForwardAndTarget( this.m_pl
                //texts.Add(new StringBuilder("Bot.AngleBetweenForwardAndPlayerPosition = " + angle.ToString("F0")));
                //texts.Add(new StringBuilder(String.Empty));


                // Bot debug key controls.
                texts.Add(new StringBuilder("Use UP/DOWN arrows keys to select a parameter."));
                texts.Add(new StringBuilder("Use RIGHT/LEFT arrows keys to adjust parameter value."));
                texts.Add(new StringBuilder("Press Shift-F12 to close this screen."));
                texts.Add(new StringBuilder(String.Empty));

                // List specific bot that we're modifying.
                StringBuilder botTitle = new StringBuilder();
                botTitle.Append("Selected bot:  ");
                //botTitle.Append(m_bot.Name);
                texts.Add(botTitle);
                texts.Add(new StringBuilder(String.Empty));

                // Walk through all settable parameters and list current names and values.
                // Add either spacing or tick mark prefix to each parameter listed.
                // The little tick marks indicates the currently editting parameter.
                for (int i = 0; i < this.m_botParams.Count; i++)
                {
                    StringBuilder sb = new StringBuilder();
                    BotParam param = this.m_botParams[i];
                    sb.Append((this.GetPrefix(i) + param.Name + " = "));
                    if (param.IsBoolean == false)
                    {
                        sb.Append((param.Value.ToString("F1")));
                    }
                    else
                    {
                        if (param.Value == 0.0f)
                        {
                            sb.Append("False");
                        }
                        else
                        {
                            sb.Append("True");
                        }
                    }
                    texts.Add(sb);
                }
                texts.Add(new StringBuilder(String.Empty));

                // Description what effect changing current parameter will have..
                texts.Add(new StringBuilder("Description:"));
                texts.Add(new StringBuilder(this.m_currentParam.Description));
                texts.Add(new StringBuilder(String.Empty));

            }

            // Where to start drawing text.
            Vector2 origin = this.GetScreenLeftTopPosition();

            // Draw our text on screen.
            for (int i = 0; i < texts.Count; i++)
            {
                MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), texts[i], origin + new Vector2(0, i * TEXT_DISTANCE_Y), TEXT_SCALE,
                    Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();

            return true;
        }