Example #1
0
        private void DrawMapBorders(GraphicsContext graphicsContext, ICamera2D camera)
        {
            // Room borders
            const int RoomBorderThickness = 2;
            for(int x = 0; x < _map.WidthInRooms; x++)
            {
                for(int y = 0; y < _map.HeightInRooms; y++)
                {
                    Vector2i roomSize = new Vector2i(Room.Width * Tile.Size, Room.Height * Tile.Size);

                    // Draw room sub-borders
                    for (int x1 = 0; x1 < 4; x1++)
                    {
                        for (int y1 = 0; y1 < 4; y1++)
                        {
                            graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(
                                graphicsContext,
                                new RectangleF(x * roomSize.X + x1 * roomSize.X / 4f, y * roomSize.Y + y1 * roomSize.Y / 4f, roomSize.X / 4f, roomSize.Y / 4f),
                                Color.RoyalBlue.MultiplyRGB(0.5f) * 0.5f,
                                RoomBorderThickness / camera.Zoom);
                        }
                    }

                    // Draw room borders
                    graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(graphicsContext, new Rectangle(x * roomSize.X, y * roomSize.Y, roomSize.X, roomSize.Y), Color.RoyalBlue, RoomBorderThickness / camera.Zoom);
                }
            }

            // Full map borders
            const int MapBorderThickness = 4;
            graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(graphicsContext, new Rectangle(0, 0, _map.Width * Tile.Size, _map.Height * Tile.Size), Color.White, MapBorderThickness / camera.Zoom);
        }
Example #2
0
        public void DrawUI(GraphicsContext graphicsContext, BasicUiContainer levelUiContainer)
        {
            const float FadeSpeed = 4;
            float fadeAmount = graphicsContext.DeltaSeconds * FadeSpeed;

            IGameContainer gameContainer = _world.EntityWorld.Services.Get<IGameContainer>();

            // player ui shouldn't fade out when paused, thus !gameContainer.IsGameOver check
            _playerUiAlpha += fadeAmount * ((gameContainer.IsActive || !gameContainer.IsGameOver) ? 1 : -1);
            _playerUiAlpha = _playerUiAlpha.Clamp(0, 1);

            // all other ui should fade out when game over or paused
            _otherUiAlpha += fadeAmount * (gameContainer.IsActive ? 1 : -1);
            _otherUiAlpha = _otherUiAlpha.Clamp(0, 1);

            // draw with player UI alpha (player UI + booster)
            graphicsContext.SpriteBatch.Alpha.Push(_playerUiAlpha);
            _playerRenderer.DrawUI(graphicsContext);
            _boosterStateRenderer.Draw(graphicsContext);
            graphicsContext.SpriteBatch.Alpha.Pop();

            // draw all other UI (pause, thumbsticks, drop arrow, achievement)
            graphicsContext.SpriteBatch.Alpha.Push(_otherUiAlpha);

            levelUiContainer.Draw(graphicsContext, true);
            _virtualThumbStickRenderer.Draw(graphicsContext);
            _dropArrowRenderer.Draw(graphicsContext);
            _achievementRenderer.Draw(graphicsContext);

            graphicsContext.SpriteBatch.Alpha.Pop();
        }
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     if (_adComponent != null)
     {
         _adComponent.Draw(graphicsContext.GameTime);
     }
 }
Example #4
0
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     foreach (Spring spring in _springs)
     {
         graphicsContext.PrimitiveRenderer.DrawLine(graphicsContext, spring.StartPoint, spring.EndPoint, (spring.IsTriggered ? Color.DarkGray : Color.White) * 0.625f, Spring.Thickness);
     }
 }
Example #5
0
 public void Draw(GraphicsContext graphicsContext)
 {
     if (_visible)
     {
         this.DrawInner(graphicsContext);
     }
 }
Example #6
0
 public void Draw(GraphicsContext graphicsContext)
 {
     if (_visible && this.Initialized )
     {
         this.DrawInner(graphicsContext);
     }
 }
Example #7
0
 protected override void Draw(GraphicsContext graphicsContext)
 {
     graphicsContext.SpriteBatch.Begin();
     graphicsContext.SpriteBatch.DrawFullscreen(graphicsContext.BlankTexture, Color.Black * 0.4f);
     _uiContainer.Draw(graphicsContext, true);
     graphicsContext.SpriteBatch.End();
 }
Example #8
0
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     if (_playerWeapon.Weapon.Type == WeaponType.Laser)
     {
         this.DrawLaser(graphicsContext, (Laser)_playerWeapon.Weapon);
     }
 }
 protected sealed override void Draw(GraphicsContext graphicsContext, ReadOnlyBag<Entity> entities)
 {
     foreach (Entity entity in entities)
     {
         this.Draw(graphicsContext, entity);
     }
 }
Example #10
0
        // using _spatialMap.GetAllIntersecting(CCamera2D.Active.GetArea(graphicsContext.ScreenSize))) causes all kinds of problems (render order changes when zombies move from cell and pretty sure other things too)
        protected override void Draw(GraphicsContext graphicsContext, ReadOnlyBag<Entity> entities)
        {
            // the texture size is actually 63x63, but the area in the texture that is of the actual zombie (no shadows) is 48x48
            const float BaseTextureSize = 48;

            RectangleF cameraArea = CCamera2D.Active.GetArea(graphicsContext.ScreenSize);
            foreach (Entity zombie in entities)
            {
                CZombieInfo zombieInfo = zombie.Get<CZombieInfo>();
                if (zombieInfo.AreaRectangle.Intersects(cameraArea))
                {
                    float scale = zombieInfo.Size / BaseTextureSize;
                    graphicsContext.SpriteBatch.DrawCentered(this.GetTexture(zombieInfo.Type), zombie.Transform.Position, ZombieRenderer.GetColor(zombieInfo), zombie.Transform.Rotation, scale);
                }

                // draw golden goblin glow
                if (zombieInfo.Type == ZombieType.GoldenGoblin)
                {
                    graphicsContext.SpriteBatch.DrawCentered(graphicsContext.ContentProvider.DefaultManager.LoadTexture("GoldenGoblinGlow"), zombie.Transform.Position, Color.Gold * 0.5f, 0, 3f + FlaiMath.Sin(graphicsContext.TotalSeconds * 2));

                    // DEBUG //
                  /*  CGoldenGoblinAI goldenGoblinAI = zombie.Get<CGoldenGoblinAI>();
                    if (goldenGoblinAI.State == GoldenGoblinState.TravellingToWaypoint)
                    {
                        graphicsContext.PrimitiveRenderer.DrawLine(goldenGoblinAI.Transform.Position, goldenGoblinAI.CurrentWaypoint, Color.Red, 2f);
                    }

                    for (int i = 0; i < goldenGoblinAI.Waypoints.Length - 1; i++)
                    {
                        graphicsContext.PrimitiveRenderer.DrawLine(goldenGoblinAI.Waypoints[i], goldenGoblinAI.Waypoints[i + 1], Color.Red, 4f);
                    } */
                }
            }
        }
Example #11
0
 private void DrawBullet(GraphicsContext graphicsContext, Entity entity, CBullet bullet)
 {
     TextureDefinition texture = this.GetTexture(bullet.Weapon.Type);
     if (bullet.Weapon.Type == WeaponType.RocketLauncher)
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, Color.White, entity.Transform.Rotation, 2);
     }
     else if (bullet.Weapon.Type == WeaponType.Bouncer)
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(160, 160, 160), entity.Transform.Rotation, 1);
     }
     else if (bullet.Weapon.Type == WeaponType.Flamethrower)
     {
         CLifeTime lifeTime = entity.Get<CLifeTime>();
         Color color = Color.Lerp(Color.LightGoldenrodYellow, Color.OrangeRed, 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
         graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
     }
     else if (bullet.Weapon.Type == WeaponType.Waterblaster)
     {
         CLifeTime lifeTime = entity.Get<CLifeTime>();
         Color color = Color.Lerp(Color.AliceBlue, new Color(0, 69, 255), 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
         graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
     }
     else
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(255, 255, 128) * 0.625f, entity.Transform.Rotation, 4);
     }
 }
        private void DrawThumbStick(GraphicsContext graphicsContext, CVirtualThumbstick virtualThumbstickComponent)
        {
            VirtualThumbstick thumbstick = virtualThumbstickComponent.Thumbstick;

            // if the thumbstick style is relative and the user isn't pressing down, the CenterPosition doesn't have a value.
            // don't draw the thumbstick in that case
            if (thumbstick.CenterPosition.HasValue)
            {
                TextureDefinition thumbstickTexture = SkypieaViewConstants.LoadTexture(_contentProvider, "ThumbstickBase");
                float alpha = thumbstick.IsPressed ? 0.5f : 1f;

                // base
                graphicsContext.SpriteBatch.DrawCentered(thumbstickTexture, thumbstick.CenterPosition.Value, Color.Gray * 0.75f * alpha);
                if (thumbstick.Direction.HasValue)
                {
                    // draw the "position"/direction texture only if the thumbstick is actually pressed
                    if (thumbstick.IsPressed)
                    {
                        const float MaxDistance = 60f;
                        graphicsContext.SpriteBatch.DrawCentered(thumbstickTexture, thumbstick.CenterPosition.Value + thumbstick.Direction.Value * MaxDistance, Color.LightGray * 0.5f * alpha, 0, 0.5f);
                    }
                    // otherwise draw the text on the thumbstick
                    else
                    {
                        string name = (virtualThumbstickComponent.Entity.Name == EntityNames.MovementThumbStick) ? "MOVEMENT" : "SHOOTING";
                        graphicsContext.SpriteBatch.DrawStringCentered(graphicsContext.FontContainer["Minecraftia.24"], name, thumbstick.CenterPosition.Value, Color.White * 0.5f * alpha);
                    }
                }
            }
        }
        protected override void DrawInner(GraphicsContext graphicsContext)
        {
            if (_currentAchievement != null)
            {
                const float OffsetFromBorder = 8;
                const float TextOffset = 8;
                const float Height = 96;
                const float VerticalPosition = 90;

                const float BackgroundAlpha = 0.3f;
                const float TextAlpha = 0.75f;

                float alpha = this.GetAlpha();

                SpriteFont font = graphicsContext.FontContainer["Minecraftia.16"];
                float maxWidth = FlaiMath.Max(font.GetStringWidth(_currentAchievement.Name), font.GetStringWidth(_currentAchievement.ShortDescription)) + TextOffset * 2;

                float left = graphicsContext.ScreenSize.Width - OffsetFromBorder - maxWidth + (1 - alpha) * maxWidth / 2f;
                float centerX = left + maxWidth / 2f;
                RectangleF backgroundArea = new RectangleF(left, VerticalPosition, maxWidth, Height);

                // background & outlines
                graphicsContext.PrimitiveRenderer.DrawRectangle(backgroundArea, Color.Black * BackgroundAlpha * alpha);
                graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(backgroundArea, Color.Black * TextAlpha * alpha, 1);

                // name
                graphicsContext.SpriteBatch.DrawStringCentered(
                    font, _currentAchievement.Name, new Vector2(centerX, VerticalPosition + TextOffset + font.GetCharacterHeight() / 2f), Color.White * alpha * TextAlpha);

                // description
                graphicsContext.SpriteBatch.DrawStringCentered(
                    font, _currentAchievement.ShortDescription, new Vector2(centerX, VerticalPosition + TextOffset * 2 + font.GetCharacterHeight() * 3 / 2f), Color.White * alpha * TextAlpha);
            }
        }
Example #14
0
        protected override void DrawInner(GraphicsContext graphicsContext)
        {
            ICamera2D camera = graphicsContext.Services.GetService<ICameraManager2D>().ActiveCamera;
            RectangleF cameraArea = camera.GetArea(graphicsContext.GraphicsDevice);

            this.DrawTiles(graphicsContext, cameraArea);
            this.DrawMapBorders(graphicsContext, camera);
        }
 public override void Draw(GraphicsContext graphicsContext)
 {
     if (_takeScreenshot)
     {
         this.TakeScreenShot();
         _takeScreenshot = false;
     }
 }
Example #16
0
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     // draws the actual map texture
     Vector2i size = SkypieaConstants.MapSizeInPixels / SkypieaViewConstants.PixelSize + Vector2i.One * SkypieaViewConstants.FadeLength / SkypieaViewConstants.PixelSize * 2;
     graphicsContext.SpriteBatch.Draw(
          SkypieaViewConstants.LoadTexture(_contentProvider, _mapTextureName),
          -Vector2.One * SkypieaViewConstants.FadeLength, new Rectangle(0, 0, size.X, size.Y), _color, 0, Vector2.Zero, SkypieaViewConstants.PixelSize, _spriteEffects, 0f);
 }
Example #17
0
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     foreach (Door door in _doors)
     {
         Texture2D lockTexture = graphicsContext.ContentProvider.DefaultManager.LoadTexture("Lock");
         graphicsContext.SpriteBatch.DrawCentered(lockTexture, door.Area.Center, Color.White * door.Alpha, 0, (Tile.Size / (float)lockTexture.Width) + 2 * (1 - door.Alpha));
     }
 }
Example #18
0
        protected override void DrawInner(GraphicsContext graphicsContext)
        {
            ICamera2D camera = graphicsContext.Services.GetService<ICameraManager2D>().ActiveCamera;
            RectangleF cameraArea = camera.GetArea(graphicsContext.GraphicsDevice);

            this.DrawTiles(graphicsContext, cameraArea);
            graphicsContext.PrimitiveRenderer.DrawLine(graphicsContext, new Vector2(0, _map.Height * Tile.Size), new Vector2(_map.Width * Tile.Size, _map.Height * Tile.Size), Color.White, 4f);
        }
Example #19
0
 // Draw without camera
 public void DrawOther(GraphicsContext graphicsContext)
 {
     const string FontName = "Minecraftia40";
     Color color = _gameClock.RemainingTime > 2f ? new Color(224, 224, 224) : new Color(255, 64, 64);
     graphicsContext.SpriteBatch.Begin(SamplerState.PointClamp);
     graphicsContext.SpriteBatch.DrawStringFadedCentered(graphicsContext.FontContainer[FontName], _gameClock.RemainingTimeString, new Vector2(graphicsContext.ScreenSize.X / 2f, 48), Color.Black, color);
     graphicsContext.SpriteBatch.End();
 }
Example #20
0
        protected override void Draw(GraphicsContext graphicsContext)
        {
            graphicsContext.GraphicsDevice.Clear(_backgroundColor);

            graphicsContext.SpriteBatch.Begin();
            graphicsContext.SpriteBatch.DrawStringCentered(_font, _text, graphicsContext.ScreenSize.ToVector2i() / 2f);
            graphicsContext.SpriteBatch.End();
        }
Example #21
0
        public override void Draw(GraphicsContext graphicsContext)
        {
            Texture2D texture = graphicsContext.ContentProvider.DefaultManager.LoadTexture("ResizeIcon");

            bool isToggled = _player.EditorMode == EditorMode.Resizing;
            graphicsContext.SpriteBatch.Draw(graphicsContext.BlankTexture, _area, isToggled ? Color.White : Color.DimGray * 0.75f);
            graphicsContext.SpriteBatch.Draw(texture, _area, isToggled ? Color.DimGray : Color.White);
        }
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     if (_adManager != null)
     {
         Vector2i topLeftPosition = _position - AdManager.AdSize / 2;
         _adManager.Draw(graphicsContext.SpriteBatch.InnerSpriteBatch, topLeftPosition);
     }
 }
Example #23
0
        // size = radius, not diameter!
        public void DrawCircle(GraphicsContext graphicsContext, Vector2 position, Color color, float size)
        {
            _effect.FillColor = color;
            _effect.StrokeColor = Color.Transparent;
            _effect.StrokeSize = Vector2.Zero;
            _effect.UseStrokeSmoothing = false;

            graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, position, color, 0, size * 2);
        }
Example #24
0
        protected override void Draw(GraphicsContext graphicsContext)
        {
            graphicsContext.SpriteBatch.Begin(SamplerState.PointClamp);
            _uiContainer.Draw(graphicsContext, true);

            const string FontName = "Minecraftia18";
            graphicsContext.SpriteBatch.DrawString(graphicsContext.FontContainer[FontName], "Jaakko Lipsanen/Flai", new Vector2(4, graphicsContext.ScreenSize.Y - 40), Color.White);
            graphicsContext.SpriteBatch.End();
        }
Example #25
0
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     if (_sprite != null)
     {
         graphicsContext.SpriteBatch.Begin();
         graphicsContext.SpriteBatch.Draw(_sprite, base.DisplayArea);
         graphicsContext.SpriteBatch.End();
     }
 }
Example #26
0
        // size = radius, not diameter!
        public void DrawCircle(GraphicsContext graphicsContext, Vector2 position, Color color, Vector2 size, Color strokeColor, float strokeSize, bool smoothStroke)
        {
            _effect.FillColor = color;
            _effect.StrokeColor = strokeColor;
            _effect.StrokeSize = new Vector2(strokeSize / (size.X * 2), strokeSize / (size.Y * 2));
            _effect.UseStrokeSmoothing = smoothStroke;

            graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, position, color, 0, size * 2);
        } 
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     _particleRenderer.RenderEffect(graphicsContext, _particleEngine[ParticleEffectID.ZombieExplosion]);
     _particleRenderer.RenderEffect(graphicsContext, _particleEngine[ParticleEffectID.ZombieBloodSplatter]);
     _particleRenderer.RenderEffect(graphicsContext, _particleEngine[ParticleEffectID.RocketSmoke]);
     _particleRenderer.RenderEffect(graphicsContext, _particleEngine[ParticleEffectID.RocketExplosion]);
     _particleRenderer.RenderEffect(graphicsContext, _particleEngine[ParticleEffectID.GoldenGoblinSpray]);
     _particleRenderer.RenderEffect(graphicsContext, _particleEngine[ParticleEffectID.GoldenGoblinExplosion]);
 }
Example #28
0
 private void DrawBullets(GraphicsContext graphicsContext, ReadOnlyCollection<Bullet> bullets)
 {
     foreach (Bullet bullet in bullets)
     {
         float scaleAlpha = FlaiMath.Max(0.25F, bullet.Alpha * bullet.Alpha);
         graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, bullet.Position, new Color(228, 228, 288) * bullet.Alpha, bullet.Rotation, Bullet.Size * (bullet.IsAlive ? scaleAlpha : (2 * (1-scaleAlpha))));
         //graphicsContext.PrimitiveRenderer.DrawRectangleOutlines(graphicsContext, bullet.Area, Color.White * bullet.Alpha * a, 1f);
     }
 }
Example #29
0
 protected override void DrawInner(GraphicsContext graphicsContext)
 {
     _mapRenderer.Draw(graphicsContext);
     _doorRenderer.Draw(graphicsContext);
     _cannonRenderer.Draw(graphicsContext);
     _timeBonusRenderer.Draw(graphicsContext);
     _keyRenderer.Draw(graphicsContext);
     _portalRenderer.Draw(graphicsContext);
 }
Example #30
0
        public static void DrawRectangle(GraphicsContext graphicsContext, Vector2 min, Vector2 max, Color color)
        {
            if (min.X > max.X || min.Y > max.Y)
            {
                throw new ArgumentOutOfRangeException("min max");
            }

            DebugRenderer.DrawRectangle(new RectangleF(min, max), color);
        }