Exemplo n.º 1
0
        //  ╔═╗╔═╗╔╦╗╔╦╗╦╔╗╔╔═╗╔═╗  ╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
        //  ╚═╗║╣  ║  ║ ║║║║║ ╦╚═╗  ╠═╣║   ║ ║║ ║║║║╚═╗
        //  ╚═╝╚═╝ ╩  ╩ ╩╝╚╝╚═╝╚═╝  ╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
        /// <summary>
        /// Apply Acceleration Action.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool ApplyAction(ActionAcceleration action)
        {
            if (action.relative)
            {
                this.acceleration += action.acceleration;
            }
            else
            {
                this.acceleration = action.acceleration;
            }

            if (this.acceleration < 0)
            {
                this.acceleration = 0;
            }

            return(true);
        }
Exemplo n.º 2
0
        //  ╔═╗╔═╗╔╦╗╔╦╗╦╔╗╔╔═╗╔═╗  ╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
        //  ╚═╗║╣  ║  ║ ║║║║║ ╦╚═╗  ╠═╣║   ║ ║║ ║║║║╚═╗
        //  ╚═╝╚═╝ ╩  ╩ ╩╝╚╝╚═╝╚═╝  ╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
        /// <summary>
        /// Apply Acceleration Action.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public bool ApplyAction(ActionAcceleration action)
        {
            if (action.relative)
            {
                this.acceleration += action.acceleration;
            }
            else
            {
                this.acceleration = action.acceleration;
            }

            if (this.acceleration < 0)
            {
                this.acceleration = 0;
            }

            if (_logRelativeActions && action.relative)
            {
                logger.Verbose("Acceleration set to " + this.acceleration);
            }

            return(true);
        }