/// <summary> /// Draw the layer. /// </summary> /// <param name="renderTime">Time since last render.</param> /// <remarks>include base.Render(renderTime); in overloads to preserve updating RenderTime field.</remarks> public override void Render(RenderTime renderTime) { base.Render(renderTime); if (MM_Repository.OverallDisplay.MapTiles == MM_MapTile.enumMapType.None) { return; } var tx = Surface.RenderTarget2D.Transform; Surface.RenderTarget2D.Transform = SharpDX.Matrix3x2.Identity; BaseMapTileProxy backgroundTile; Point topLeftTile = MM_Coordinates.XYToTile(Surface.Coordinates.TopLeftXY); Point bottomRightTile = MM_Coordinates.XYToTile(Surface.Coordinates.BottomRightXY); Point topLeftTileShift = new Point(Surface.Coordinates.TopLeftXY.X % MM_Repository.OverallDisplay.MapTileSize.Width, Surface.Coordinates.TopLeftXY.Y % MM_Repository.OverallDisplay.MapTileSize.Height); int extraRadius = 4; SharpDX.RectangleF tileSourceRect = new SharpDX.RectangleF(0, 0, MM_Repository.OverallDisplay.MapTileSize.Width, MM_Repository.OverallDisplay.MapTileSize.Height); if (MM_Repository.OverallDisplay.MapTiles != MM_MapTile.enumMapType.None) { int startX = topLeftTile.X - extraRadius; int endX = bottomRightTile.X + extraRadius; int startY = topLeftTile.Y - extraRadius; int endY = bottomRightTile.Y + extraRadius; foreach (var thisTile in Spiral(topLeftTile, bottomRightTile, extraRadius)) { TileCoordinates tileCoord = new TileCoordinates(MM_Repository.OverallDisplay.MapTiles, thisTile, (int)Surface.Coordinates.ZoomLevel); if (TryGetTile(tileCoord, out backgroundTile)) { if (!backgroundTile.IsReady) { continue; } var targetRect = new SharpDX.RectangleF(((thisTile.X - topLeftTile.X) * MM_Repository.OverallDisplay.MapTileSize.Width) - topLeftTileShift.X, ((thisTile.Y - topLeftTile.Y) * MM_Repository.OverallDisplay.MapTileSize.Height) - topLeftTileShift.Y, MM_Repository.OverallDisplay.MapTileSize.Width, MM_Repository.OverallDisplay.MapTileSize.Height); Surface.RenderTarget2D.DrawBitmap(backgroundTile.Bitmap, targetRect, MM_Repository.OverallDisplay.MapTransparency, BitmapInterpolationMode.NearestNeighbor, tileSourceRect); } } //for (Point thisTile = new Point(topLeftTile.X - extraRadius, topLeftTile.Y - extraRadius); thisTile.X <= bottomRightTile.X + extraRadius; thisTile.X++, thisTile.Y = topLeftTile.Y) //{ // for (; thisTile.Y <= bottomRightTile.Y + extraRadius; thisTile.Y++) // { // TileCoordinates tileCoord = new TileCoordinates(MM_Repository.OverallDisplay.MapTiles, thisTile, (int)Surface.Coordinates.ZoomLevel); // if (TryGetTile(tileCoord, out backgroundTile)) // { // if (!backgroundTile.IsReady) continue; // // var targetRect = new SharpDX.RectangleF(((thisTile.X - topLeftTile.X) * MM_Repository.OverallDisplay.MapTileSize.Width) - topLeftTileShift.X, ((thisTile.Y - topLeftTile.Y) * MM_Repository.OverallDisplay.MapTileSize.Height) - topLeftTileShift.Y, MM_Repository.OverallDisplay.MapTileSize.Width, MM_Repository.OverallDisplay.MapTileSize.Height); // Surface.RenderTarget2D.DrawBitmap(backgroundTile.Bitmap, targetRect, MM_Repository.OverallDisplay.MapTransparency, BitmapInterpolationMode.NearestNeighbor, tileSourceRect); // } // } //} } Surface.RenderTarget2D.Transform = tx; }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; FrameTime += elapsedTime; if (Distance >= TotalDistance) { TimeSinceArrival += elapsedTime; } if (FrameTime >= FrameLength) { FrameTime = FrameTime - FrameLength; Frame++; } if (Frame >= TextureManager.GetSpellSheet(TextureManager.SpellAnimType.Beam, AnimationIndex).TotalFrames) { Frame = 0; if (Distance < TotalDistance) { Distance++; } } if (TimeSinceArrival >= LastingTime) { ActionDone = true; } }
public NormalMoveAnimation(Loc2D tileLoc, int animIndex, RenderTime animTime, int loops) { AnimationIndex = animIndex; FrameLength = animTime; TotalLoops = loops; StartLoc = new Loc2D(tileLoc.X, tileLoc.Y); }
/// <summary> /// Draw the layer. /// </summary> /// <param name="renderTime">Time since last render.</param> /// <remarks>include base.Render(renderTime); in overloads to preserve updating RenderTime field.</remarks> public override void Render(RenderTime renderTime) { base.Render(renderTime); var tx = Surface.RenderTarget2D.Transform; Surface.RenderTarget2D.Transform = Matrix3x2.Translation(-Surface.Coordinates.TopLeftXY.X, -Surface.Coordinates.TopLeftXY.Y); var coordinateBounds = Surface.Coordinates.GetBounds(); if (MM_Repository.OverallDisplay.DisplayCounties) { foreach (var dxRegion in regions) { var region = dxRegion.Value; if (coordinateBounds.Overlaps(region.Bounds)) { Surface.RenderTarget2D.DrawGeometry(region.Geometry, brushes.GetBrush(region.Color), region.Width); } } } if (MM_Repository.OverallDisplay.DisplayStateBorder && state != null) { if (coordinateBounds.Overlaps(state.Bounds)) { Surface.RenderTarget2D.DrawGeometry(state.Geometry, brushes.GetBrush(state.Color), state.Width); } } Surface.RenderTarget2D.Transform = tx; }
/// <summary> /// Draw the layer. /// </summary> /// <param name="renderTime">Time since last render.</param> /// <remarks>include base.Render(renderTime); in overloads to preserve updating RenderTime field.</remarks> public override void Render(RenderTime renderTime) { base.Render(renderTime); int vertical = 0; if (_alignment == ContentAlignment.MiddleLeft || _alignment == ContentAlignment.MiddleCenter || _alignment == ContentAlignment.MiddleRight) { vertical = 1; } else if (_alignment == ContentAlignment.BottomLeft || _alignment == ContentAlignment.BottomCenter || _alignment == ContentAlignment.BottomRight) { vertical = 2; } int horizontal = 0; if (_alignment == ContentAlignment.TopCenter || _alignment == ContentAlignment.MiddleCenter || _alignment == ContentAlignment.BottomCenter) { horizontal = 1; } else if (_alignment == ContentAlignment.TopRight || _alignment == ContentAlignment.MiddleRight || _alignment == ContentAlignment.BottomRight) { horizontal = 2; } var currentPosition = _startPosition; foreach (var message in _messages.ToList()) { if (message.IsDisposed || message.Layout == null || message.Layout.IsDisposed) { continue; } var size = message.LayoutSize; var brush = Surface.Brushes.GetBrush(message.Color, message.Opacity); // shift upward before if bottom aligned if (vertical == 2) { currentPosition.Y -= size.Y; } // set our horizontal origin if (horizontal == 2) { currentPosition.X = _startPosition.X - size.X; } Surface.RenderTarget2D.DrawTextAtPoint(message.Layout, brush, currentPosition.X, currentPosition.Y, centerX: horizontal == 1, centerY: vertical == 1); // shift downward after if top aligned if (vertical == 0) { currentPosition.Y += size.Y; } } }
/// <summary> /// Draw the layer. /// </summary> /// <param name="renderTime">Time since last render.</param> /// <remarks>include base.Render(renderTime); in overloads to preserve updating RenderTime field.</remarks> public override void Render(RenderTime renderTime) { // if we don't have a data provider, don't render if (DataProvider == null || _kdProxy == null || MM_Repository.OverallDisplay.Contour == MM_Display.MM_Contour_Enum.None) { return; } base.Render(renderTime); var displayView = Surface.Coordinates.GetViewXY(); var displayRect = Surface.DisplayRectangle; var size = Surface.RenderTarget2D.PixelSize; bool resized = _displayRect != displayRect; bool viewSizeMatchesDisplaySize = displayView.Width == displayRect.Width && displayView.Height == displayRect.Height; if ((displayView != _displayView || _bmp == null || _bmp.IsDisposed || resized) && !((MM_Network_Map_DX)Surface).HandlingMouse && viewSizeMatchesDisplaySize && !isRendering) { _displayRect = displayRect; _displayView = displayView; _size = size; DrawBitmap(Surface.RenderTarget2D.PixelSize.Height / 10, Surface.RenderTarget2D.PixelSize.Width / 10, (float)MM_Coordinates.GConstants[_zoomLevel][1] * _zoomLevel * _zoomLevel, _displayView); } if (_bmp != null && Surface.RenderTarget2D != null && !((MM_Network_Map_DX)Surface).HandlingMouse) { var stateLayer = Surface.GetLayers <StateRegionsLayer>().FirstOrDefault(); var tx = Surface.RenderTarget2D.Transform; Surface.RenderTarget2D.Transform = Matrix3x2.Translation(-Surface.Coordinates.TopLeftXY.X, -Surface.Coordinates.TopLeftXY.Y); var dest = new SharpDX.RectangleF(-Surface.RenderTarget2D.Transform.M31, -Surface.RenderTarget2D.Transform.M32, Surface.RenderTarget2D.Size.Width, Surface.RenderTarget2D.Size.Height); if (MM_Repository.OverallDisplay.ClipContours && stateLayer != null && stateLayer.State != null && stateLayer.State.Geometry != null && !(DataProvider is LineLoadingPercentageContourData)) { var layerParameters = new LayerParameters() { ContentBounds = RectangleF.Infinite, GeometricMask = stateLayer.State.Geometry, Opacity = 1, MaskTransform = tx }; using (var layer = new Layer(Surface.RenderTarget2D, Surface.RenderTarget2D.Size)) { Surface.RenderTarget2D.PushLayer(ref layerParameters, layer); Surface.RenderTarget2D.DrawBitmap(_bmp, dest, 0.5f, BitmapInterpolationMode.Linear); Surface.RenderTarget2D.PopLayer(); } } else { Surface.RenderTarget2D.DrawBitmap(_bmp, dest, 0.5f, BitmapInterpolationMode.Linear); } Surface.RenderTarget2D.Transform = tx; } }
public override void Process(Input input, ActiveChar character, ref bool moveMade) { if (input[Input.InputType.Enter] && !Processor.InputState[(int)Processor.InputType.Enter]) { Choose(character, ref moveMade); } else if (input[Input.InputType.X] && !Processor.InputState[(int)Processor.InputType.X]) { Choose(character, ref moveMade); } else if (input[Input.InputType.Z] && !Processor.InputState[(int)Processor.InputType.Z]) { MenuManager.Menus.RemoveAt(0); } else { bool chooseDown = (input.Direction == Direction8.Down || input.Direction == Direction8.DownLeft || input.Direction == Direction8.DownRight); bool prevDown = (Processor.oldDirection == Direction8.Down || Processor.oldDirection == Direction8.DownLeft || Processor.oldDirection == Direction8.DownRight); bool chooseUp = (input.Direction == Direction8.Up || input.Direction == Direction8.UpLeft || input.Direction == Direction8.UpRight); bool prevUp = (Processor.oldDirection == Direction8.Up || Processor.oldDirection == Direction8.UpLeft || Processor.oldDirection == Direction8.UpRight); if (chooseDown && (!prevDown || Processor.InputTime >= RenderTime.FromMillisecs(40))) { currentChoice = (currentChoice + 1) % Choices.Count; } else if (chooseUp && (!prevUp || Processor.InputTime >= RenderTime.FromMillisecs(40))) { currentChoice = (currentChoice + Choices.Count - 1) % Choices.Count; } } }
public OverlayMoveAnimation(int animIndex, RenderTime animTime, int loops, byte transparency) { AnimationIndex = animIndex; FrameLength = animTime; TotalLoops = loops; Alpha = (byte)(255 - transparency); }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; FrameTime += elapsedTime; if (FrameTime >= FrameLength) { FrameTime = FrameTime - FrameLength; Frame++; } if (Frame >= TextureManager.GetSpellSheet(TextureManager.SpellAnimType.Arrow, AnimationIndex).TotalFrames) { Frame = 0; } Distance = ActionTime.ToMillisecs() * TravelSpeed / 1000; if (Distance >= TotalDistance) { ActionDone = true; } else { Loc2D mapLoc = new Loc2D(StartLoc.X * TextureManager.TILE_SIZE, StartLoc.Y * TextureManager.TILE_SIZE); Operations.MoveInDirection8(ref mapLoc, Direction, Distance); MapLoc = mapLoc; } }
public static void Process(RenderTime elapsedTime) { if (DebugSpeed == GameSpeed.Pause) { return; } else if (DebugSpeed == GameSpeed.Instant) { ForceReady(); ProcessActions(elapsedTime); } else { int speedFactor = 1000; speedFactor = (int)(speedFactor * Math.Pow(2, (int)DebugSpeed)); RenderTime newElapsed = elapsedTime * speedFactor / 1000; ProcessActions(newElapsed); } //if actions are ready for queue, get a new result ProcessTaskQueue(true); //update actions at 0 time ProcessActions(new RenderTime()); }
public CharacterOriginAnimation(int charIndex, int animIndex, RenderTime animTime, int loops) { AnimationIndex = animIndex; FrameLength = animTime; TotalLoops = loops; CharIndex = charIndex; }
/// <summary> /// Perform calculations and update data. /// </summary> /// <param name="updateTime">Time since last update.</param> /// <remarks>include base.Update(renderTime); in overloads to preserve updating UpdateTime field.</remarks> public override void Update(RenderTime updateTime) { base.Update(updateTime); var textFormat = Surface.Fonts.GetTextFormat(MM_Repository.OverallDisplay.NetworkMapFont, 2); foreach (var message in _messages.ToList()) { if (message.IsDisposed) { _messages.Remove(message); continue; } if ((message.SecondsRemaining -= (float)updateTime.ElapsedTime.TotalSeconds) < 0) { message.Dispose(); _messages.Remove(message); } else { // set opacity, fade out the last second message.Opacity = MathUtil.Clamp(((int)(message.SecondsRemaining * 20)) / 20f, 0, 1); // rebuild text layouts if (message.Layout == null || message.Layout.IsDisposed) { message.Layout = new TextLayout(Surface.FactoryDirectWrite, message.Message, textFormat, 350, 50); message.LayoutSize = new Vector2(message.Layout.Metrics.Width, message.Layout.Metrics.Height); } } } }
private void nudFrameLength_TextChanged(object sender, EventArgs e) { int millisecs = 0; SetIntFromNumeric(ref millisecs, nudFrameLength); chosenAnim.FrameLength = RenderTime.FromMillisecs(millisecs); ChangeAnimationTimer(); }
public static void ForceReady() { while (!outContainer.IsFinished() || resultContainers.Count > 0) { ProcessActions(RenderTime.FromMillisecs(1000)); ProcessTaskQueue(false); } }
/// Perform calculations and update data. /// </summary> /// <param name="updateTime">Time since last update.</param> /// <remarks>include base.Update(renderTime); in overloads to preserve updating UpdateTime field.</remarks> public virtual void Update(RenderTime updateTime) { UpdateTime = updateTime; if (!_isLoaded || _isUnloading) { return; } }
/// <summary> /// Draw the layer. /// </summary> /// <param name="renderTime">Time since last render.</param> /// <remarks>include base.Render(renderTime); in overloads to preserve updating RenderTime field.</remarks> public virtual void Render(RenderTime renderTime) { RenderTime = renderTime; if (!_isLoaded || _isUnloading) { return; } }
public TileAnim(Loc2D texture, int sheet) { Frames = new List <TileTexture> { new TileTexture(texture, sheet) }; FrameLength = RenderTime.FromMillisecs(1); }
/// <summary> /// Perform calculations and update data. /// </summary> /// <param name="updateTime">Time since last update.</param> /// <remarks>include base.Update(renderTime); in overloads to preserve updating UpdateTime field.</remarks> public override void Update(RenderTime updateTime) { base.Update(updateTime); if (!MM_Repository.OverallDisplay.ShowWeather) { return; } }
/// <summary> /// Draw the layer. /// </summary> /// <param name="renderTime">Time since last render.</param> /// <remarks>include base.Render(renderTime); in overloads to preserve updating RenderTime field.</remarks> public override void Render(RenderTime renderTime) { base.Render(renderTime); if (!MM_Repository.OverallDisplay.ShowWeather) { return; } }
public BeamMoveAnimation(Loc2D startLoc, int animIndex, RenderTime animTime, Maps.Direction8 dir, int distance, RenderTime lastingTime) { StartLoc = startLoc; AnimationIndex = animIndex; FrameLength = animTime; Direction = dir; TotalDistance = distance; LastingTime = lastingTime; }
public TileAnim(TileAnim oldTileAnim) { Frames = new List <TileTexture>(); for (int i = 0; i < oldTileAnim.Frames.Count; i++) { Frames.Add(oldTileAnim.Frames[i]); } FrameLength = oldTileAnim.FrameLength; }
public ArrowMoveAnimation(Loc2D startLoc, int animIndex, RenderTime animTime, Maps.Direction8 dir, int distance, int speed) { StartLoc = startLoc; AnimationIndex = animIndex; FrameLength = animTime; Direction = dir; TotalWaves = distance; TotalDistance = distance * TextureManager.TILE_SIZE; TravelSpeed = speed; }
public void ProcessDelay(RenderTime time) { foreach (KeyValuePair <int, ResultBranch> entry in branches) { entry.Value.Delay -= time; if (entry.Value.Delay < RenderTime.Zero) { entry.Value.Delay = RenderTime.Zero; } } }
public void ProcessDelay(RenderTime time) { for (int i = 0; i < BranchCount; i++) { branches[i].Delay -= time; if (branches[i].Delay < RenderTime.Zero) { branches[i].Delay = RenderTime.Zero; } } }
public FountainEmitter(Loc2D startLoc, int animIndex, int grainsPerBurst, RenderTime burstTime, int bursts, RenderTime animTime, int startDistance, int speed, RenderTime totalTime) { StartLoc = startLoc; AnimationIndex = animIndex; FrameLength = animTime; TotalTime = totalTime; GrainsPerBurst = grainsPerBurst; BurstTime = burstTime; TotalBursts = bursts; StartDistance = startDistance; Speed = speed; }
public ThrowMoveAnimation(Loc2D startLoc, Loc2D endLoc, int animIndex, RenderTime animTime, int speed, bool dropDown) { StartLoc = startLoc; EndLoc = endLoc; AnimationIndex = animIndex; FrameLength = animTime; Loc2D diffLoc = startLoc - endLoc; TotalDistance = (int)(TextureManager.TILE_SIZE * Math.Sqrt(Math.Pow(diffLoc.X, 2) + Math.Pow(diffLoc.Y, 2))); TravelSpeed = speed; DropDown = dropDown; }
public void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; RenderTime totalTime = ITEM_ACTION_TIME[(int)Action]; if (ActionTime >= totalTime && Action != ItemAnimType.None) { ActionDone = true; } else { switch (Action) { case ItemAnimType.None: { MapHeight = 0; MapLoc = StartLoc; break; } case ItemAnimType.Drop: { MapHeight = DrawHelper.GetArc(TextureManager.TILE_SIZE / 4, totalTime.Ticks, ActionTime.Ticks); MapHeight += TextureManager.TILE_SIZE * (totalTime - ActionTime).Ticks / 2 / totalTime.Ticks; Loc2D mapDiff = (EndLoc - StartLoc) * TextureManager.TILE_SIZE; mapDiff = new Loc2D(mapDiff.X * ActionTime.Ticks / totalTime.Ticks, mapDiff.Y * ActionTime.Ticks / totalTime.Ticks); MapLoc = mapDiff + StartLoc * TextureManager.TILE_SIZE; } break; case ItemAnimType.Bounce: { MapHeight = DrawHelper.GetArc(TextureManager.TILE_SIZE / 2, totalTime.Ticks, ActionTime.Ticks); Loc2D mapDiff = (EndLoc - StartLoc) * TextureManager.TILE_SIZE; mapDiff = new Loc2D(mapDiff.X * ActionTime.Ticks / totalTime.Ticks, mapDiff.Y * ActionTime.Ticks / totalTime.Ticks); MapLoc = mapDiff + StartLoc * TextureManager.TILE_SIZE; } break; case ItemAnimType.Deflect: { MapHeight = DrawHelper.GetArc(TextureManager.TILE_SIZE / 2, totalTime.Ticks, ActionTime.Ticks); MapHeight += TextureManager.TILE_SIZE * (totalTime.Ticks - ActionTime.Ticks) / 2 / totalTime.Ticks; Loc2D mapDiff = (EndLoc - StartLoc) * TextureManager.TILE_SIZE; mapDiff = new Loc2D(mapDiff.X * ActionTime.Ticks / totalTime.Ticks, mapDiff.Y * ActionTime.Ticks / totalTime.Ticks); MapLoc = mapDiff + StartLoc * TextureManager.TILE_SIZE; } break; } } }
public TileMoveAnimation(Loc2D startLoc, int animIndex, RenderTime animTime, int loops, Enums.RangeType rangeType, Maps.Direction8 dir, int range, RenderTime stallTime) { AnimationIndex = animIndex; FrameLength = animTime; TotalLoops = loops; StartLoc = startLoc; RangeType = rangeType; Direction = dir; TotalDistance = range; StallTime = stallTime; FrameTime = StallTime; }
//float scale; //float scaleSpeed; //float rotation; //float rotationSpeed; public ParticleAnimation(int animationIndex, RenderTime frameLength, Loc2D newPosition, Loc2D newSpeed, Loc2D newAcceleration, Color4 newAlpha, Color4 newAlphaSpeed, RenderTime newMaxTime) { AnimationIndex = animationIndex; FrameLength = frameLength; MapLoc = newPosition; StartLoc = MapLoc; Speed = newSpeed; StartSpeed = Speed; Acceleration = newAcceleration; Color = newAlpha; ColorChange = newAlphaSpeed; TotalTime = newMaxTime; }
public static void UpdateInput(RenderTime elapsedTime, int ups) { if (CurrentInput.InputChanged) { InputTime += elapsedTime; } else { InputTime = RenderTime.FromMillisecs(0); } Display.Screen.UpdatesPerSecond = ups; ProcessMeta(); }