Ejemplo n.º 1
0
        public override void OnActivated()
        {
            var sprites = (ISpriteSheets)Game.Services.GetService (typeof(ISpriteSheets));

            m_life = sprites.GetSprite ("health_01");
            m_antitod = sprites.GetSprite ("antitod_potion_01");

            var infoEnt = CreateEntity ();
            infoEnt.Register (new Execute ());
            var infoMsg = new Loop (new ActionEntity(infoEnt, (_) => {
                UpdateInfoMessage (infoEnt);
            }));
            infoEnt.Get<Execute> ().Add (infoMsg, "info_loop");

            var feedbackEnt = CreateEntity ("hud_feedback");
            feedbackEnt.Register (new Execute ());
            feedbackEnt.Register (new Text (sprites.GetFont ("SpriteFont1")));
            feedbackEnt.Register (new Drawable (new Vector2 (570, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT), Color.Yellow));

            var hudIcon = CreateEntity ();
            hudIcon.Register (new Sprite (sprites.GetSprite("health_01")));
            hudIcon.Register (new Drawable (new Vector2 (0, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT)));

            hudIcon = CreateEntity ();
            hudIcon.Register (new Sprite (sprites.GetSprite("money_01")));
            hudIcon.Register (new Drawable (new Vector2 (100, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT)));

            hudIcon = CreateEntity ();
            hudIcon.Register (new Sprite (sprites.GetSprite("weapon_01")));
            hudIcon.Register (new Drawable (new Vector2 (200, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT)));

            hudIcon = CreateEntity ();
            hudIcon.Register (new Sprite (sprites.GetSprite("armor_01")));
            hudIcon.Register (new Drawable (new Vector2 (300, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT)));

            var textMsg = CreateEntity ("hud_health");
            textMsg.Register (new Text(sprites.GetFont ("SpriteFont1")));
            textMsg.Register (new Drawable (new Vector2 (40, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT), Color.Green));

            textMsg = CreateEntity ("hud_weapon");
            textMsg.Register (new Text(sprites.GetFont ("SpriteFont1")));
            textMsg.Register (new Drawable (new Vector2 (240, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT), Color.Green));

            textMsg = CreateEntity ("hud_money");
            textMsg.Register (new Text(sprites.GetFont ("SpriteFont1")));
            textMsg.Register (new Drawable (new Vector2 (140, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT), Color.Green));

            textMsg = CreateEntity ("hud_armor");
            textMsg.Register (new Text(sprites.GetFont ("SpriteFont1")));
            textMsg.Register (new Drawable (new Vector2 (340, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT), Color.Green));

            textMsg = CreateEntity ("hud_time");
            textMsg.Register (new Text(sprites.GetFont ("SpriteFont1")));
            textMsg.Register (new Drawable (new Vector2 (440, Globals.CELL_HEIGHT * Globals.WORLD_HEIGHT), Color.Green));
        }
Ejemplo n.º 2
0
        protected override void OnInitialized()
        {
            var sprites = (ISpriteSheets)Game.Services.GetService (typeof(ISpriteSheets));

            int backBufWidth = Game.GraphicsDevice.PresentationParameters.BackBufferWidth;
            int backBufHeight = Game.GraphicsDevice.PresentationParameters.BackBufferHeight;

            m_lightTarget = new RenderTarget2D (Game.GraphicsDevice, backBufWidth, backBufHeight);
            m_lightSpritePointSmall = sprites.GetSprite("lightmask_small");
            m_lightSpritePointNormal = sprites.GetSprite ("lightmask_normal");
            m_lightSpritePointBig = sprites.GetSprite ("lightmask_big");
            m_lightSpriteDirectUp = sprites.GetSprite ("lightmask_up");
            m_lightSpriteDirectDown = sprites.GetSprite ("lightmask_down");
            m_lightSpriteDirectLeft = sprites.GetSprite ("lightmask_left");
            m_lightSpriteDirectRight = sprites.GetSprite ("lightmask_right");
            m_lightEffect = sprites.GetEffect ("light");
        }
Ejemplo n.º 3
0
 public AnimSprite(Entity entity, float duration)
 {
     m_entity = entity;
     m_duration = duration;
     m_sprite = m_entity.Get<Sprite> ().Image;
 }
Ejemplo n.º 4
0
 public AnimSprite(Entity entity, Sprite2D sprite, float duration)
 {
     m_entity = entity;
     m_duration = duration;
     m_sprite = sprite;
 }
Ejemplo n.º 5
0
 private void DrawPointLightMasks(IEnumerable<Entity> toLight, Sprite2D lightSprite, SpriteBatch spriteBatch)
 {
     foreach (var pe in toLight) {
         var lightPos = pe.Get<Drawable>().DrawPos;
         var lightColor = pe.Get<PointLight> ().LightColor;
         lightPos.X -= (lightSprite.Rect.Width - Globals.CELL_WIDTH)/2;
         lightPos.Y -= (lightSprite.Rect.Height - Globals.CELL_HEIGHT)/2;
         spriteBatch.Draw(lightSprite.Texture, lightPos, lightSprite.Rect, lightColor);
     }
 }
Ejemplo n.º 6
0
        private void LoadSheetData(SheetData sheetData)
        {
            var texture = Game.Content.Load<Texture2D> (sheetData.Texture);
            var stream = TitleContainer.OpenStream(sheetData.PList);

            #if __IOS__
            PlistDocument pinfo = new PlistDocument(stream);
            PlistDictionary frames = pinfo.Root.AsDictionary["frames"].AsDictionary;

            foreach (var frame in frames) {
                string spriteName = frame.Key.Split('.')[0];
                string texRect = frame.Value.AsDictionary["frame"].AsString;
                var sp = new Sprite2D (spriteName, texture, RectangleFromString (texRect), sheetData.FrameWidth, sheetData.FrameHeight);
                m_sprites.Add (spriteName, sp);
            }
            #else
            PList pinfo = new PList (stream);
            PList frames = pinfo ["frames"] as PList;

            foreach (var frmName in frames.Keys) {
                PList frame = frames [frmName] as PList;
                string texRect = frame ["frame"] as string;
                string spriteName = frmName.Split('.')[0];
                var sp = new Sprite2D (spriteName, texture, RectangleFromString (texRect), sheetData.FrameWidth, sheetData.FrameHeight);
                m_sprites.Add (spriteName, sp);
            }
            #endif
        }
Ejemplo n.º 7
0
 public Sprite(Sprite2D sprite, bool spriteSheet = true)
 {
     m_spriteSheet = spriteSheet;
     FrameId = 0;
     Image = sprite;
 }