Пример #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <remarks>Every initial values come from <see cref="Constants.Player"/>.</remarks>
 internal Player() : base(
         0,
         Constants.Player.INITIAL_X,
         Constants.Player.INITIAL_Y,
         Constants.Player.SPRITE_WIDTH,
         Constants.Player.SPRITE_HEIGHT,
         Constants.Player.MAXIMAL_LIFE_POINTS,
         Constants.Player.HIT_LIFE_POINT_COST,
         Constants.Player.INITIAL_SPEED,
         Constants.Player.RECOVERY_TIME,
         nameof(Filename.Player),
         nameof(Filename.PlayerRecovery),
         Direction.Right)
 {
     NewScreenEntrance      = null;
     Inventory              = new Inventory();
     SwordHitSprite         = null;
     _hitElapser            = null;
     _currentWeaponHitDelay = Constants.Player.SWORD_HIT_DELAY;
     _movementTimeManager   = new Elapser(this, ElapserUse.PlayerMovement);
     _renderShield          = DefaultRender.BasicImage(this, nameof(Filename.PlayerShield));
     _renderRecoveryShield  = DefaultRender.AnimatedBasicImage(this,
                                                               nameof(Filename.PlayerRecoveryShield), ElapserUse.LifeSpriteRecovery, Constants.RECOVERY_BLINK_DELAY);
     _renderSword         = DefaultRender.BasicImage(this, nameof(Filename.PlayerSword));
     _renderRecoverySword = DefaultRender.AnimatedBasicImage(this,
                                                             nameof(Filename.PlayerRecoverySword), ElapserUse.LifeSpriteRecovery, Constants.RECOVERY_BLINK_DELAY);
 }
Пример #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="id"><see cref="Sprite.Id"/></param>
 /// <param name="x"><see cref="Sprite.X"/></param>
 /// <param name="y"><see cref="Sprite.Y"/></param>
 /// <param name="width"><see cref="Sprite.Width"/></param>
 /// <param name="height"><see cref="Sprite.Height"/></param>
 /// <param name="maximalLifePoints"><see cref="MaximalLifePoints"/></param>
 /// <param name="hitLifePointCost"><see cref="HitLifePointCost"/></param>
 /// <param name="speed"><see cref="_originalSpeed"/></param>
 /// <param name="recoveryTime"><see cref="_recoveryTime"/></param>
 /// <param name="renderFilename">File name for <see cref="Sprite._render"/>.</param>
 /// <param name="renderRecoveryFilename">File name for <see cref="_renderRecovery"/>.</param>
 /// <param name="defaultDirection">Default <see cref="Direction"/>.</param>
 protected LifeSprite(int id, double x, double y, double width, double height, double maximalLifePoints, double hitLifePointCost,
                      double speed, double recoveryTime, string renderFilename, string renderRecoveryFilename, Direction defaultDirection)
     : base(id, x, y, width, height, maximalLifePoints, RenderType.Image, new[] { renderFilename, nameof(Direction) })
 {
     Direction              = defaultDirection;
     MaximalLifePoints      = maximalLifePoints;
     HitLifePointCost       = hitLifePointCost;
     _originalSpeed         = speed;
     _recoveryManager       = null;
     _recoveryTime          = recoveryTime;
     ExplosionLifePointCost = Constants.Bomb.EXPLOSION_LIFE_POINT_COST;
     ArrowLifePointCost     = Constants.Arrow.LIFE_POINT_COST;
     _renderRecovery        = DefaultRender.AnimatedBasicImage(this, renderRecoveryFilename, ElapserUse.LifeSpriteRecovery, Constants.RECOVERY_BLINK_DELAY);
 }
Пример #3
0
        /// <summary>
        /// Computes and gets a <see cref="Renders.IRender"/> from given properties.
        /// </summary>
        /// <param name="renderType"><see cref="Enums.RenderType"/></param>
        /// <param name="renderProperties">Datas required to initialize the <see cref="Renders.IRender"/>.</param>
        /// <returns><see cref="Renders.IRender"/></returns>
        protected IRender GetRenderFromValues(RenderType renderType, params string[] renderProperties)
        {
            switch (renderType)
            {
            case RenderType.ImageMosaic:
                return(DefaultRender.ImageWithMosaic(this, renderProperties[0]));

            case RenderType.Image:
                return(DefaultRender.BasicImage(this, renderProperties[0]));

            case RenderType.Plain:
                return(DefaultRender.PlainColor(this, renderProperties[0]));

            case RenderType.ImageAnimated:
                return(DefaultRender.AnimatedBasicImage(this, renderProperties[0], (ElapserUse)System.Convert.ToInt32(renderProperties[1]), System.Convert.ToDouble(renderProperties[2])));

            case RenderType.ImageMosaicAnimated:
                return(DefaultRender.AnimatedImageWithMosaic(this, renderProperties[0], (ElapserUse)System.Convert.ToInt32(renderProperties[1]), System.Convert.ToDouble(renderProperties[2])));

            default:
                throw new System.NotImplementedException(Messages.NotImplementedRenderExceptionMessage);
            }
        }