Exemplo n.º 1
0
        public Player(IContentManager contentManager, IViewport viewport, IAnimationFactory animationFactory, ISpriteBatch spriteBatch,
                      IPlayerConfiguration configuration)
            : base(spriteBatch)
        {
            _configuration = configuration;
            _viewport      = viewport.Viewport;
            _animation     = animationFactory.Build(
                contentManager.Load(@"Graphics\shipAnimation"),
                115, 30, 8);

            Position = new Vector2(_viewport.TitleSafeArea.X + 100, _viewport.TitleSafeArea.Y + _viewport.TitleSafeArea.Height / 2);

            BeforeDraw   += time => _animation.Update(time);
            BeforeUpdate += state =>
            {
                if (_health <= 0)
                {
                    _active = false;
                }
                UpdateVelocity(state);
            };

            _boundaries = new[]
            {
                new Rectangle(-100, 0, 100 + _configuration.LeftBoundary, _viewport.Height),
                new Rectangle(_viewport.Width - _configuration.RightBoundary, 0, 100, _viewport.Height),
                new Rectangle(0, -100, _viewport.Width, 100 + _configuration.TopBoundary),
                new Rectangle(0, _viewport.Height - _configuration.BottomBoundary, _viewport.Width, 100),
            };
        }
Exemplo n.º 2
0
        public void RemoveFromWindow()
        {
            if (Parent is ViewGroup parent)
            {
                parent.RemoveView(this);
            }


            if (_bitmap != null)
            {
                _bitmap.Recycle();
                _bitmap = null;
            }

            _eraser           = null;
            _animationFactory = null;
            _canvas           = null;
            _handler          = null;

            if ((int)Build.VERSION.SdkInt < 16)
            {
                ViewTreeObserver.RemoveGlobalOnLayoutListener(this);
            }
            else
            {
                ViewTreeObserver.RemoveOnGlobalLayoutListener(this);
            }
            //mLayoutListener = null;

            _prefsManager?.Close();

            _prefsManager = null;
        }
Exemplo n.º 3
0
        public UserInterfaceScene(GraphicsDevice graphicsDevice,
                                  IUserInterfaceRenderer userInterfaceRenderer,
                                  IContentLayoutEngine contentLayoutEngine,
                                  IFontProvider fontProvider,
                                  IStyleConfigurator styleConfigurator,
                                  IAnimationFactory animationFactory = null,
                                  IUserInterfaceAudio audio          = null,
                                  IDoubleBuffer doubleBuffer         = null,
                                  RenderTarget2D renderTarget        = null)
        {
            DrawBelow   = true;
            UpdateBelow = false;

            Animations     = animationFactory ?? new AnimationFactory();
            GraphicsDevice = graphicsDevice;

            renderContext = new UserInterfaceRenderContext(
                graphicsDevice,
                contentLayoutEngine,
                userInterfaceRenderer,
                styleConfigurator,
                fontProvider,
                Animations,
                renderTarget,
                null,
                doubleBuffer);

            driver = new UserInterfaceSceneDriver(
                renderContext,
                styleConfigurator,
                fontProvider,
                audio);

            driver.ScreenArea = new Rectangle(Point.Zero,
                                              GraphicsDeviceRenderTargetSize);

            driver.Desktop.Empty += () =>
            {
                if (ExitWhenEmpty)
                {
                    IsFinished = true;
                }
            };

            BlendState = new BlendState
            {
                ColorSourceBlend      = Blend.SourceAlpha,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                AlphaSourceBlend      = Blend.One,
                AlphaDestinationBlend = Blend.InverseSourceAlpha,
            };
        }
Exemplo n.º 4
0
        public static void Configure(this IAnimationFactory animationFactory, RenderElementDisplay display)
        {
            if (display.Style.Animation == null)
            {
                display.Animation.In     = display.Animation.In ?? animationFactory.Create("default", null);
                display.Animation.Out    = display.Animation.Out ?? animationFactory.Create("default", null);
                display.Animation.Static = display.Animation.Static ?? animationFactory.Create("default", null);

                return;
            }

            // Currently, we don't support updating animators when the style changes unless the name of the
            // animator type has changed. I don't see a good use case for supporting this at the moment. -EY
            if (display.Animation.InType != display.Style.Animation.EntryName)
            {
                display.Animation.InType = display.Style.Animation.EntryName;
                display.Animation.In     = animationFactory.Create(display.Style.Animation.EntryName, display.Style.Animation.EntryArgs);
            }

            if (display.Animation.OutType != display.Style.Animation.ExitName)
            {
                display.Animation.OutType = display.Style.Animation.ExitName;
                display.Animation.Out     = animationFactory.Create(display.Style.Animation.ExitName, display.Style.Animation.ExitArgs);
            }

            if (display.Animation.StaticType != display.Style.Animation.StaticName)
            {
                display.Animation.StaticType = display.Style.Animation.StaticName;
                display.Animation.Static     = animationFactory.Create(display.Style.Animation.StaticName, display.Style.Animation.StaticArgs);
            }

            if (display.Animation.In == null)
            {
                display.Animation.In = display.Animation.In ?? animationFactory.Create("default", null);
            }

            if (display.Animation.Out == null)
            {
                display.Animation.Out = display.Animation.Out ?? animationFactory.Create("default", null);
            }

            if (display.Animation.Static == null)
            {
                display.Animation.Static = display.Animation.Static ?? animationFactory.Create("default", null);
            }
        }
Exemplo n.º 5
0
 public UserInterfaceRenderContext(
     GraphicsDevice graphicsDevice,
     IContentLayoutEngine contentLayoutEngine,
     IUserInterfaceRenderer uiRenderer,
     IStyleConfigurator styleConfigurator,
     IFontProvider fonts,
     IAnimationFactory animation,
     RenderTarget2D renderTarget = null,
     SpriteBatch spriteBatch     = null,
     IDoubleBuffer doubleBuffer  = null)
 {
     this.GraphicsDevice        = graphicsDevice;
     this.contentLayoutEngine   = contentLayoutEngine;
     this.UserInterfaceRenderer = uiRenderer;
     this.fonts            = fonts;
     this.animationFactory = animation;
     this.RenderTarget     = renderTarget;
     this.SpriteBatch      = spriteBatch ?? new SpriteBatch(graphicsDevice);
     this.DoubleBuffer     = doubleBuffer ?? new DoubleBuffer();
 }
        public StrippingClientService()
        {
            try
            {
                _config = ConfigService.LoadConfig <Config>("GTA.Client.Stripper", "Config.json", "CLIENTSTRIPPER");
                //TODO implement IOC
                _animationFactory = new AnimationFactory(_config);

                if (_config.Debug)
                {
                    Debug.WriteLine($"Config was loaded with {JsonConvert.SerializeObject(_config)}");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error loading config {e.Message}");
            }

            Tick += StrippingClientService_Tick;
        }
Exemplo n.º 7
0
 public EnemyFactory(IContentManager contentManager, IAnimationFactory animationFactory, ISpriteBatch spriteBatch)
 {
     _animationFactory = animationFactory;
     _spriteBatch      = spriteBatch;
     _texture          = contentManager.Load("Graphics/mineAnimation");
 }
Exemplo n.º 8
0
 public void SetAnimationFactory(IAnimationFactory animationFactory) => _animationFactory = animationFactory;
Exemplo n.º 9
0
 public void addAnimation(XnaScrapId id, IAnimationFactory aa)
 {
     m_animationPlayer.Add(id, aa);
 }