Пример #1
0
        //* -----------------------------------------------------------------------*
        /// <summary>1フレーム分の更新処理を実行します。</summary>
        ///
        /// <param name="entity">この状態を適用されているオブジェクト。</param>
        /// <param name="privateMembers">
        /// オブジェクトと状態クラスのみがアクセス可能なフィールド。
        /// </param>
        /// <param name="gameTime">前フレームが開始してからの経過時間。</param>
        public override void update(CInputAdapterAdapter entity,
                                    CInputAdapterAdapter.CPrivateMembers privateMembers, GameTime gameTime)
        {
            IList <IInputAdapter> lower   = entity.lowerInput;
            IList <int>           assigns = entity.assignList;
            List <SInputInfo>     btns    = privateMembers.buttonList;
            int lLength = lower.Count;

            for (int j = lLength; --j >= 0; lower[j].update(gameTime))
            {
                ;
            }
            for (int i = assigns.Count; --i >= 0;)
            {
                int     id       = assigns[i];
                Vector3 velocity = Vector3.Zero;
                float   vm       = 0;
                for (int j = lLength; --j >= 0;)
                {
                    SInputInfo src = lower[j].buttonList[id];
                    velocity += src.velocity;
                    vm        = MathHelper.Max(vm, src.velocity.Length());
                }
                if (vm > 0)
                {
                    velocity.Normalize();
                }
                btns[id] = btns[id].updateVelocity(velocity * vm);
            }
        }
Пример #2
0
        //* -----------------------------------------------------------------------*
        /// <summary>方向キーの情報を取得します。</summary>
        ///
        /// <param name="prev">前回の入力情報。</param>
        /// <param name="state">低位入力クラスから取得した最新の情報。</param>
        /// <param name="up">上ボタンとして割り当てられたキー。</param>
        /// <param name="down">下ボタンとして割り当てられたキー。</param>
        /// <param name="left">左ボタンとして割り当てられたキー。</param>
        /// <param name="right">右ボタンとして割り当てられたキー。</param>
        /// <returns>最新の入力情報。</returns>
        private SInputInfo updateAxis(SInputInfo prev, KeyboardState state,
                                      Keys up, Keys down, Keys left, Keys right)
        {
            Vector3 v =
                Convert.ToInt32(state.IsKeyDown(up)) * -Vector3.UnitY +
                Convert.ToInt32(state.IsKeyDown(down)) * Vector3.UnitY +
                Convert.ToInt32(state.IsKeyDown(left)) * -Vector3.UnitX +
                Convert.ToInt32(state.IsKeyDown(right)) * Vector3.UnitX;

            if (v.Length() > 0)
            {
                v.Normalize();
            }
            return(prev.updateVelocity(v));
        }
Пример #3
0
        //* -----------------------------------------------------------------------*
        /// <summary>1フレーム分の更新処理を実行します。</summary>
        ///
        /// <param name="entity">この状態を適用されているオブジェクト。</param>
        /// <param name="privateMembers">
        /// オブジェクトと状態クラスのみがアクセス可能なフィールド。
        /// </param>
        /// <param name="gameTime">前フレームが開始してからの経過時間。</param>
        public override void update(CCursor entity, object privateMembers, GameTime gameTime)
        {
            entity.aiView.update(gameTime);
            SInputInfo move = inputData[(int)EInputActionMap.cursor];

            if (move.pushLoop(24, 6))
            {
                entity.level +=
                    (short)Math.Sign(inputData[(int)EInputActionMap.cursor].velocity.X);
            }
            if (inputData[(int)EInputActionMap.enter].push)
            {
                entity.Dispose();
            }
        }