Esempio n. 1
0
        public Popup(Game game, IRenderView renderView, Position position, int columns, int rows, bool transparent,
                     byte displayLayerOffset = 0)
        {
            if (columns < 3 || rows < 3)
            {
                throw new AmbermoonException(ExceptionScope.Application, "Popups must at least have 3 columns and 3 rows.");
            }

            DisplayLayer    = (byte)Math.Min(255, BaseDisplayLayer + displayLayerOffset);
            this.game       = game;
            this.renderView = renderView;
            textureAtlas    = TextureAtlasManager.Instance.GetOrCreate(Layer.UI);

            void AddBorder(PopupFrame frame, int column, int row)
            {
                var sprite = renderView.SpriteFactory.Create(16, 16, true, DisplayLayer) as ILayerSprite;

                sprite.Layer = renderView.GetLayer(Layer.UI);
                sprite.TextureAtlasOffset = textureAtlas.GetOffset(Graphics.GetPopupFrameGraphicIndex(frame));
                sprite.PaletteIndex       = game.UIPaletteIndex;
                sprite.X       = position.X + column * 16;
                sprite.Y       = position.Y + row * 16;
                sprite.Visible = true;
                borders.Add(sprite);
            }

            if (!transparent)
            {
                // 4 corners
                AddBorder(PopupFrame.FrameUpperLeft, 0, 0);
                AddBorder(PopupFrame.FrameUpperRight, columns - 1, 0);
                AddBorder(PopupFrame.FrameLowerLeft, 0, rows - 1);
                AddBorder(PopupFrame.FrameLowerRight, columns - 1, rows - 1);

                // top and bottom border
                for (int i = 0; i < columns - 2; ++i)
                {
                    AddBorder(PopupFrame.FrameTop, i + 1, 0);
                    AddBorder(PopupFrame.FrameBottom, i + 1, rows - 1);
                }

                // left and right border
                for (int i = 0; i < rows - 2; ++i)
                {
                    AddBorder(PopupFrame.FrameLeft, 0, i + 1);
                    AddBorder(PopupFrame.FrameRight, columns - 1, i + 1);
                }

                // fill
                // TODO: use named palette color
                fill = renderView.ColoredRectFactory.Create((columns - 2) * 16, (rows - 2) * 16,
                                                            game.GetUIColor(28), DisplayLayer);
                fill.Layer   = renderView.GetLayer(Layer.UI);
                fill.X       = position.X + 16;
                fill.Y       = position.Y + 16;
                fill.Visible = true;

                ContentArea = new Rect(fill.X, fill.Y, fill.Width, fill.Height);
            }
        }
Esempio n. 2
0
        public void LoadAllTextures(ContentManager content)
        {
            smallMarioRightStandingAtlas = new SingleFrameTextureAtlas(content.Load <Texture2D>("SmallMarioRightStandingNew"));
            smallMarioRightWalkingAtlas  = new ThreeFrameTextureAtlas(content.Load <Texture2D>("SmallMarioRightWalkingNew"));
            smallMarioRightJumpingAtlas  = new SingleFrameTextureAtlas(content.Load <Texture2D>("SmallMarioRightJumpingNew"));
            smallMarioLeftStandingAtlas  = new SingleFrameTextureAtlas(content.Load <Texture2D>("SmallMarioLeftStandingNew"));
            smallMarioLeftWalkingAtlas   = new ThreeFrameTextureAtlas(content.Load <Texture2D>("SmallMarioLeftWalkingNew1"));
            smallMarioLeftJumpingAtlas   = new SingleFrameTextureAtlas(content.Load <Texture2D>("SmallMarioLeftJumpingNew"));
            smallMarioDeadAtlas          = new SingleFrameTextureAtlas(content.Load <Texture2D>("SmallMarioDead"));
            smallMarioLeftFlagAtlas      = new SingleFrameTextureAtlas(content.Load <Texture2D>("SmallMarioLeftFlag"));

            bigMarioRightStandingAtlas  = new SingleFrameTextureAtlas(content.Load <Texture2D>("BigMarioRightStanding"));
            bigMarioRightCrouchingAtlas = new SingleFrameTextureAtlas(content.Load <Texture2D>("BigMarioRightCrouching"));
            bigMarioRightJumpingAtlas   = new SingleFrameTextureAtlas(content.Load <Texture2D>("BigMarioRightJumping"));
            bigMarioRightWalkingAtlas   = new ThreeFrameTextureAtlas(content.Load <Texture2D>("BigMarioRightWalking"));
            bigMarioLeftStandingAtlas   = new SingleFrameTextureAtlas(content.Load <Texture2D>("BigMarioLeftStanding"));
            bigMarioLeftCrouchingAtlas  = new SingleFrameTextureAtlas(content.Load <Texture2D>("BigMarioLeftCrouching"));
            bigMarioLeftJumpingAtlas    = new SingleFrameTextureAtlas(content.Load <Texture2D>("BigMarioLeftJumping"));
            bigMarioLeftWalkingAtlas    = new ThreeFrameTextureAtlas(content.Load <Texture2D>("BigMarioLeftWalking"));
            bigMarioLeftFlagAtlas       = new SingleFrameTextureAtlas(content.Load <Texture2D>("BigMarioLeftFlag"));

            fireMarioRightStandingAtlas  = new SingleFrameTextureAtlas(content.Load <Texture2D>("FireMarioRightStandingNew"));
            fireMarioRightCrouchingAtlas = new SingleFrameTextureAtlas(content.Load <Texture2D>("FireMarioRightCrouchingNew"));
            fireMarioRightJumpingAtlas   = new SingleFrameTextureAtlas(content.Load <Texture2D>("FireMarioRightJumpingNew"));
            fireMarioRightWalkingAtlas   = new ThreeFrameTextureAtlas(content.Load <Texture2D>("FireMarioRightWalkingNew"));
            fireMarioLeftStandingAtlas   = new SingleFrameTextureAtlas(content.Load <Texture2D>("FireMarioLeftStandingNew"));
            fireMarioLeftCrouchingAtlas  = new SingleFrameTextureAtlas(content.Load <Texture2D>("FireMarioLeftCrouchingNew"));
            fireMarioLeftJumpingAtlas    = new SingleFrameTextureAtlas(content.Load <Texture2D>("FireMarioLeftJumpingNew"));
            fireMarioLeftWalkingAtlas    = new ThreeFrameTextureAtlas(content.Load <Texture2D>("FireMarioLeftWalkingNew"));
            fireMarioLeftFlagAtlas       = new SingleFrameTextureAtlas(content.Load <Texture2D>("FireMarioLeftFlag"));
        }
Esempio n. 3
0
 public void LoadAllTextures(ContentManager content)
 {
     nightmareKoopa            = content.Load <Texture2D>("rightNightmareKoopa");
     nightmareGoombaAtlas      = new NightmareThreeFrameTextureAtlas(content.Load <Texture2D>("goomba"));
     nightmareLeftTurtleAtlas  = new TwoFrameTextureAtlas(content.Load <Texture2D>("rightNightmareKoopa"));
     nightmareRightTurtleAtlas = new TwoFrameTextureAtlas(content.Load <Texture2D>("leftNightmareKoopa"));
 }
Esempio n. 4
0
        void UpdateTiles()
        {
            var backLayer  = renderView.GetLayer((Layer)((uint)Layer.MapBackground1 + tileset.Index - 1));
            var frontLayer = renderView.GetLayer((Layer)((uint)Layer.MapForeground1 + tileset.Index - 1));

            textureAtlas = TextureAtlasManager.Instance.GetOrCreate((Layer)((uint)Layer.MapBackground1 + tileset.Index - 1));
            int index = 0;

            for (uint row = 0; row < NUM_VISIBLE_TILES_Y; ++row)
            {
                for (uint column = 0; column < NUM_VISIBLE_TILES_X; ++column)
                {
                    var tile = this[ScrollX + column, ScrollY + row];

                    backgroundTileSprites[index].Layer             = backLayer;
                    backgroundTileSprites[index].TextureAtlasWidth = textureAtlas.Texture.Width;
                    backgroundTileSprites[index].PaletteIndex      = (byte)(Map.PaletteIndex - 1);
                    foregroundTileSprites[index].Layer             = frontLayer;
                    foregroundTileSprites[index].TextureAtlasWidth = textureAtlas.Texture.Width;
                    foregroundTileSprites[index].PaletteIndex      = (byte)(Map.PaletteIndex - 1);

                    if (tile.BackTileIndex == 0)
                    {
                        backgroundTileSprites[index].Visible = false;
                    }
                    else
                    {
                        var backTile         = tileset.Tiles[(int)tile.BackTileIndex - 1];
                        var backGraphicIndex = backTile.GraphicIndex;
                        backgroundTileSprites[index].TextureAtlasOffset = textureAtlas.GetOffset(backGraphicIndex - 1);
                        backgroundTileSprites[index].NumFrames          = (uint)backTile.NumAnimationFrames;
                        backgroundTileSprites[index].CurrentFrame       = 0;
                        backgroundTileSprites[index].Alternate          = backTile.Flags.HasFlag(Tileset.TileFlags.AlternateAnimation);
                        backgroundTileSprites[index].Visible            = true;
                        backgroundTileSprites[index].BaseLineOffset     = 0;
                    }

                    if (tile.FrontTileIndex == 0)
                    {
                        foregroundTileSprites[index].Visible = false;
                    }
                    else
                    {
                        var frontTile         = tileset.Tiles[(int)tile.FrontTileIndex - 1];
                        var frontGraphicIndex = frontTile.GraphicIndex;
                        foregroundTileSprites[index].TextureAtlasOffset = textureAtlas.GetOffset(frontGraphicIndex - 1);
                        foregroundTileSprites[index].NumFrames          = (uint)frontTile.NumAnimationFrames;
                        foregroundTileSprites[index].CurrentFrame       = 0;
                        foregroundTileSprites[index].Visible            = true;
                        foregroundTileSprites[index].Alternate          = frontTile.Flags.HasFlag(Tileset.TileFlags.AlternateAnimation);
                        foregroundTileSprites[index].BaseLineOffset     = frontTile.BringToFront ? TILE_HEIGHT + 2 : frontTile.Background ? -1 : 0;
                    }

                    ++index;
                }
            }

            Update(0, game.GameTime, false, null);
        }
 public BigMarioRightJumpingState(IMario mario)
 {
     container = mario;
     character = MarioFactory.bigMarioRightJumpingAtlas;
     Width     = character.Width;
     Height    = character.Height;
     IsBig     = true;
     IsFire    = false;
 }
Esempio n. 6
0
 public void LoadAllTextures(ContentManager content)
 {
     flowerAtlas           = new FourFrameTextureAtlas(content.Load <Texture2D>("Flower"));
     coinAtlas             = new ThreeFrameTextureAtlas(content.Load <Texture2D>("Coin"));
     starAtlas             = new FourFrameTextureAtlas(content.Load <Texture2D>("Star"));
     greenMushroomAtlas    = new SingleFrameTextureAtlas(content.Load <Texture2D>("GreenMushroom"));
     redMushroomAtlas      = new SingleFrameTextureAtlas(content.Load <Texture2D>("RedMushroom"));
     disappearingCoinAtlas = new FourFrameTextureAtlas(content.Load <Texture2D>("CoinDisappearing"));
 }
Esempio n. 7
0
 public RedMushroomObject(ITextureAtlas txt, Vector2 pos)
 {
     obj      = txt;
     Location = pos;
     locale   = pos;
     IsUsed   = false;
     Position = new Rectangle((int)Location.X, (int)Location.Y, obj.Width, obj.Height);
     move     = new Vector2(1, 0);
 }
Esempio n. 8
0
 public FlowerObject(ITextureAtlas texture, Vector2 pos)
 {
     obj      = texture;
     Width    = obj.Width;
     Height   = obj.Height;
     Location = pos;
     IsUsed   = false;
     Position = new Rectangle((int)Location.X, (int)Location.Y, Width, Height);
 }
Esempio n. 9
0
 public FireMarioRightStandingState(IMario mario)
 {
     container = mario;
     character = MarioFactory.fireMarioRightStandingAtlas;
     Height    = character.Height;
     Width     = character.Width;
     IsBig     = true;
     IsFire    = true;
 }
Esempio n. 10
0
 public SmallMarioRightJumpingState(IMario mario)
 {
     container = mario;
     character = MarioFactory.smallMarioRightJumpingAtlas;
     Height    = character.Height;
     Width     = character.Width;
     IsBig     = false;
     IsFire    = false;
 }
Esempio n. 11
0
 public SmallLeftFlagState(IMario mario)
 {
     container             = mario;
     character             = MarioFactory.smallMarioLeftFlagAtlas;
     Width                 = character.Width;
     Height                = character.Height;
     IsBig                 = false;
     IsFire                = false;
     container.FacingRight = true;
 }
Esempio n. 12
0
 public FireMarioLeftWalkingState(IMario mario)
 {
     container             = mario;
     character             = MarioFactory.fireMarioLeftWalkingAtlas;
     Width                 = character.Width;
     Height                = character.Height;
     IsBig                 = true;
     IsFire                = true;
     container.FacingRight = false;
 }
Esempio n. 13
0
 public ZombieWalkingLeftZombie(ITextureAtlas txt, Vector2 pos)
 {
     Multiplier   = false;
     TextureAtlas = txt;
     Location     = pos;
     posChange    = new Vector2(0, 0);
     move         = new Vector2(-1, 0);
     Position     = new Rectangle((int)Location.X, (int)Location.Y, TextureAtlas.Width, TextureAtlas.Height);
     SpawnTimer   = startTime;
 }
Esempio n. 14
0
 public BigLeftCrouchState(IMario mario)
 {
     container             = mario;
     character             = MarioFactory.bigMarioLeftCrouchingAtlas;
     Width                 = character.Width;
     Height                = character.Height;
     IsBig                 = true;
     IsFire                = false;
     container.FacingRight = false;
 }
Esempio n. 15
0
 public DisappearingCoinObject2(ITextureAtlas texture, Vector2 pos)
 {
     obj            = texture;
     Location       = pos;
     IsUsed         = false;
     Height         = obj.Height;
     Width          = obj.Width;
     positionChange = pos;
     counter        = 0;
     Position       = new Rectangle((int)Location.X, (int)Location.Y, Width, Height);
 }
Esempio n. 16
0
        /// <summary>
        /// Gets a texture atlas container based on the given Bones3 texture atlas object.
        /// </summary>
        /// <param name="atlas">The atlas object.</param>
        /// <returns>
        /// The Bones3 texture atlas object which manages this object, or null if it is
        /// not in this list.
        /// </returns>
        public Bones3TextureAtlas GetAtlas(ITextureAtlas atlas)
        {
            foreach (var a in m_AtlasList)
            {
                if (a.RawAtlas == atlas)
                {
                    return(a);
                }
            }

            return(null);
        }
Esempio n. 17
0
 //private Texture2D flag;
 public FlagPoleItem(ITextureAtlas flagPole, Vector2 pos)
 {
     falling       = false;
     timerStarted  = false;
     timerFinished = false;
     flag          = flagPole;
     SoundCounter  = 0;
     Location      = new Vector2(pos.X, pos.Y - flag.Height);
     Height        = flag.Height;
     Width         = flag.Width;
     Position      = new Rectangle((int)Location.X, (int)Location.Y, Width, Height);
 }
Esempio n. 18
0
 public StarObject(ITextureAtlas txt, Vector2 pos)
 {
     obj      = txt;
     Location = pos;
     IsUsed   = false;
     Height   = obj.Height;
     Width    = obj.Width;
     upCount  = 0;
     accCount = 0;
     Position = new Rectangle((int)Location.X, (int)Location.Y, Width, Height);
     move     = new Vector2(2, -4);
 }
Esempio n. 19
0
 static void EnsureTextures(IRenderView renderView, OutroData outroData, Font outroFont, Font outroFontLarge)
 {
     if (textureAtlas == null)
     {
         TextureAtlasManager.Instance.AddFromGraphics(Layer.OutroGraphics,
                                                      outroData.Graphics.Select((g, i) => new { Graphic = g, Index = i }).ToDictionary(g => (uint)g.Index, g => g.Graphic));
         textureAtlas = TextureAtlasManager.Instance.GetOrCreate(Layer.OutroGraphics);
         renderView.GetLayer(Layer.OutroGraphics).Texture = textureAtlas.Texture;
         TextureAtlasManager.Instance.AddFromGraphics(Layer.OutroText, outroFont.GlyphGraphics);
         TextureAtlasManager.Instance.AddFromGraphics(Layer.OutroText, outroFontLarge.GlyphGraphics);
         renderView.GetLayer(Layer.OutroText).Texture = TextureAtlasManager.Instance.GetOrCreate(Layer.OutroText).Texture;
     }
 }
Esempio n. 20
0
        public MapRenderer(IMap map, IKernel kernel, ITextureAtlasFactory textureAtlasFactory)
        {
            _config = Constants.Kernel.Get<RenderConfig>();
			
            Map = map;
            _textureAtlas = textureAtlasFactory.CreateTextureAtlas(new Size(_config.MaxTextureSize,_config.MaxTextureSize), new Size(_config.MaxTextureSize/16,_config.MaxTextureSize/16), 4);
            Map.ChunkChanged += new EventHandler<ChangedEventArgs<IChunk>>(Map_ChunkChanged);
            //Create renderers for all chunks that already exist
            foreach (IChunk chunk in Map.Chunks)
            {
                Map_ChunkChanged(this, new ChangedEventArgs<IChunk>(null, chunk));
            }
        }
Esempio n. 21
0
 public NightmareTurtleEnemy(ITextureAtlas leftTxt, ITextureAtlas rightTxt, Vector2 pos)
 {
     IsKilled    = false;
     FacingLeft  = leftTxt;
     FacingRight = rightTxt;
     Texture     = FacingLeft;
     Location    = pos;
     Position    = new Rectangle((int)Location.X, (int)Location.Y, FacingLeft.Width, FacingLeft.Height);
     posChange   = new Vector2(0, 0);    //posChange used to bounce  enemy in x/y direction
     move        = new Vector2(-1, 0);
     delayFlag   = false;
     facingRight = true;
 }
Esempio n. 22
0
 //private Boolean brickMarioCollision;
 public ZombieWalkingRightZombie(ITextureAtlas txt, Vector2 pos)
 {
     Multiplier      = false;
     TextureAtlas    = txt;
     locale.X        = pos.X;
     locale.Y        = pos.Y - txt.Height;
     Location        = locale;
     posChange       = new Vector2(0, 0);
     appearenceTimer = 0;
     move            = new Vector2(3, 0);
     SpawnTimer      = startTime;
     Position        = new Rectangle(0, 0, 0, 0);
 }
Esempio n. 23
0
        public SkyBox(IBitmap neg_x, IBitmap pos_x, IBitmap neg_y, IBitmap pos_y, IBitmap neg_z, IBitmap pos_z)
        {
            _config = Constants.Kernel.Get<RenderConfig>();
			
            ITextureAtlasFactory atlasFactory = Constants.Kernel.Get<ITextureAtlasFactory>();
            _atlas = atlasFactory.CreateTextureAtlas(new Size(_config.MaxTextureSize,_config.MaxTextureSize/2), new Size(_config.MaxTextureSize / 4, _config.MaxTextureSize / 4), 1);
            _neg_x = _atlas.AddSubImage(neg_x);
            _pos_x = _atlas.AddSubImage(pos_x);
            _pos_y = _atlas.AddSubImage(pos_y);
            _neg_y = _atlas.AddSubImage(neg_y);
            _pos_z = _atlas.AddSubImage(pos_z);
            _neg_z = _atlas.AddSubImage(neg_z);
        }
Esempio n. 24
0
        public NightmareGoombaEnemy(ITextureAtlas txt, Vector2 position)
        {
            IsKilled = false;
            Texture  = txt;

            Location = position;

            delay     = 60;
            delayFlag = false;
            posChange = new Vector2(0, 0);
            Position  = new Rectangle((int)position.X, (int)position.Y, Texture.Width, Texture.Height);
            move      = new Vector2(-1, 0);
        }
Esempio n. 25
0
 public FireballProjectile(ITextureAtlas texture, Vector2 pos, bool shotRight)
 {
     obj                     = texture;
     Width                   = obj.Width;
     Height                  = obj.Height;
     Location                = pos;
     isShotRight             = shotRight;
     turnPositionFireBall    = pos;
     currentPositionFireBall = pos;
     IsVisible               = true;
     xChange                 = 4;
     yChange                 = 2;
     accCount                = 0;
 }
Esempio n. 26
0
        public Cursor(IRenderView renderView, IReadOnlyList <Position> cursorHotspots, TextureAtlasManager textureAtlasManager = null)
        {
            this.renderView     = renderView;
            textureAtlas        = (textureAtlasManager ?? TextureAtlasManager.Instance).GetOrCreate(Layer.Cursor);
            sprite              = renderView.SpriteFactory.Create(16, 16, true);
            sprite.PaletteIndex = 0;
            sprite.Layer        = renderView.GetLayer(Layer.Cursor);

            for (int i = 0; i < cursorHotspots.Count; ++i)
            {
                this.cursorHotspots.Add((CursorType)i, cursorHotspots[i]);
            }

            UpdateCursor();
        }
Esempio n. 27
0
        /// <summary>
        /// Function to initialize the render data from the data context.
        /// </summary>
        /// <param name="dataContext">The current data context.</param>
        private void InitializeFromDataContext(ITextureAtlas dataContext)
        {
            if (dataContext?.Atlas == null)
            {
                _textureSprite = new GorgonSprite();
                return;
            }

            _textureSprite = new GorgonSprite
            {
                Texture        = dataContext.Atlas.Textures[0],
                TextureRegion  = new DX.RectangleF(0, 0, 1, 1),
                Size           = new DX.Size2F(dataContext.Atlas.Textures[0].Width, dataContext.Atlas.Textures[0].Height),
                TextureSampler = GorgonSamplerState.PointFiltering
            };
        }
Esempio n. 28
0
 public void LoadAllTextures(ContentManager content)
 {
     pipe                     = content.Load <Texture2D>("pipe");
     transitionPipe           = content.Load <Texture2D>("pipe");
     brickBlock               = content.Load <Texture2D>("BrickBlock");
     rockBlock                = content.Load <Texture2D>("RockBlock");
     usedBlock                = content.Load <Texture2D>("UsedBlock");
     mysteryBlock             = content.Load <Texture2D>("MysteryBlock");
     shadedBlock              = content.Load <Texture2D>("ShadedBlock");
     hiddenBlock              = content.Load <Texture2D>("HiddenBlock");
     coin                     = content.Load <Texture2D>("Coin");
     flower                   = content.Load <Texture2D>("Flower");
     brickBlockFallingRight   = content.Load <Texture2D>("BrickBlockPiecesFallingRight");
     brickBlockFallingLeft    = content.Load <Texture2D>("BrickBlockPiecesFallingLeft");
     flagPole                 = new FiveFrameTextureAtlas(content.Load <Texture2D>("flag8"));
     upsideDownTransitionPipe = content.Load <Texture2D>("UpsideDownTransition");
 }
Esempio n. 29
0
        public Button(IRenderView renderView, Position position,
                      TextureAtlasManager textureAtlasManager = null)
        {
            Area = new Rect(position, new Size(Width, Height));
            byte paletteIndex = (byte)(renderView.GraphicProvider.PrimaryUIPaletteIndex - 1);

            frameSprite    = renderView.SpriteFactory.Create(Width, Height, true, 3) as ILayerSprite;
            disableOverlay = renderView.SpriteFactory.Create(Width, Height - 6, true, 5) as ILayerSprite;
            iconSprite     = renderView.SpriteFactory.Create(Width, Height - 4, true, 4) as ILayerSprite;

            var layer = renderView.GetLayer(Layer.UI);

            frameSprite.Layer    = layer;
            disableOverlay.Layer = layer;
            iconSprite.Layer     = layer;

            textureAtlas = (textureAtlasManager ?? TextureAtlasManager.Instance).GetOrCreate(Layer.UI);
            frameSprite.TextureAtlasOffset    = textureAtlas.GetOffset(Graphics.GetUIGraphicIndex(UIGraphic.ButtonFrame));
            disableOverlay.TextureAtlasOffset = textureAtlas.GetOffset(Graphics.GetUIGraphicIndex(UIGraphic.ButtonDisabledOverlay));
            iconSprite.TextureAtlasOffset     = textureAtlas.GetOffset(Graphics.GetButtonGraphicIndex(ButtonType.Empty));

            frameSprite.PaletteIndex    = paletteIndex;
            disableOverlay.PaletteIndex = paletteIndex;
            iconSprite.PaletteIndex     = paletteIndex;

            frameSprite.X    = position.X;
            frameSprite.Y    = position.Y;
            disableOverlay.X = position.X;
            disableOverlay.Y = position.Y + 3;
            iconSprite.X     = position.X;
            iconSprite.Y     = position.Y + 2;

            frameSprite.Visible    = true;
            disableOverlay.Visible = false;
            iconSprite.Visible     = true;
        }
Esempio n. 30
0
 public ChunkRenderer(IChunk chunk, ITextureAtlas textureAtlas)
 {
     Chunk = chunk;
     _textureAtlas = textureAtlas;
     Chunk.BlockChanged += new EventHandler<BlockChangedEventArgs>(Chunk_BlockChanged);
     rebuild();
 }
Esempio n. 31
0
 /// <summary>Function to assign a data context to the view as a view model.</summary>
 /// <param name="dataContext">The data context to assign.</param>
 /// <remarks>Data contexts should be nullable, in that, they should reset the view back to its original state when the context is null.</remarks>
 public void SetDataContext(ITextureAtlas dataContext)
 {
     InitializeFromDataContext(dataContext);
     DataContext = dataContext;
 }
Esempio n. 32
0
        public RenderMap(uint numColumns, uint numRows, Map map,
                         ITriangleFactory triangleFactory, ISpriteFactory spriteFactory,
                         ITextureAtlas textureAtlasTiles, ITextureAtlas textureAtlasWaves,
                         DataSource dataSource)
        {
            CoordinateSpace = new CoordinateSpace(map, this);

            columnRowFactor = (map.Size % 2 == 0) ? 4 : 2;

            ScrollX                = 0;
            ScrollY                = 0;
            this.numColumns        = numColumns;
            this.numRows           = numRows;
            this.map               = map;
            this.textureAtlasTiles = textureAtlasTiles;
            this.textureAtlasWaves = textureAtlasWaves;

            // store map sprite offsets
            for (uint i = 0; i < 81; ++i)
            {
                var spriteInfo = dataSource.GetSpriteInfo(Data.Resource.MapMaskUp, i);

                if (spriteInfo != null)
                {
                    maskOffsets.Add(i, new Position(spriteInfo.OffsetX, spriteInfo.OffsetY));
                }

                spriteInfo = dataSource.GetSpriteInfo(Data.Resource.MapMaskDown, i);

                if (spriteInfo != null)
                {
                    maskOffsets.Add(81u + i, new Position(spriteInfo.OffsetX, spriteInfo.OffsetY));
                }
            }

            uint numTriangles = (numColumns + ADDITIONAL_X_TILES) * (numRows + ADDITIONAL_Y_TILES) * 2u;

            triangles = new List <ITriangle>((int)numTriangles);
            waves     = new List <IMaskedSprite>((int)numTriangles / 2);

            for (uint column = 0; column < numColumns + ADDITIONAL_X_TILES; ++column)
            {
                for (int i = 0; i < 2; ++i) // up and down row
                {
                    for (uint row = 0; row < numRows + ADDITIONAL_Y_TILES; ++row)
                    {
                        // the triangles are created with the max mask height of 41.
                        // also see comments in TextureAtlasManager.AddAll for further details.

                        var triangle = triangleFactory.Create(TILE_WIDTH, TILE_RENDER_MAX_HEIGHT, 0, 0);

                        triangle.X       = (int)(column * TILE_WIDTH) - TILE_WIDTH / 2 + i * TILE_WIDTH / 2;
                        triangle.Y       = (int)(row * TILE_HEIGHT);
                        triangle.Visible = true;

                        triangles.Add(triangle);
                    }
                }
            }

            for (uint column = 0; column < numColumns + ADDITIONAL_X_TILES; ++column)
            {
                for (uint row = 0; row < numRows + ADDITIONAL_Y_TILES; ++row)
                {
                    var wave = spriteFactory.Create(48, 19, 0, 0, true, false) as IMaskedSprite;

                    wave.X       = (int)(column * TILE_WIDTH) - TILE_WIDTH / 2;
                    wave.Y       = (int)(row * TILE_HEIGHT);
                    wave.Visible = false;

                    waves.Add(wave);
                }
            }

            UpdatePosition();
        }
Esempio n. 33
0
 public ChunkRenderer(IMeshFactory meshFactory, ITextureAtlas blockTextureAtlas)
 {
     this.meshFactory       = meshFactory;
     this.blockTextureAtlas = blockTextureAtlas;
 }