protected override void OnProgress(OverworldNode_SCCM node, float progress, SAMTime gameTime, InputState istate) { for (int i = 0; i < _colors.Count; i++) { node.Blocks[i].Item2 = ColorMath.Blend(_colors[i], Color.White, progress); } }
protected override void DoUpdate(SAMTime gameTime, InputState istate) { _server.Update(gameTime, istate); _btnStart.BackgroundNormal = _btnStart.BackgroundNormal.WithColor(ColorMath.Blend(FlatColors.Emerald, FlatColors.GreenSea, FloatMath.PercSin(gameTime.TotalElapsedSeconds * 5))); if (_server.Mode == SAMNetworkConnection.ServerMode.Error) { Remove(); Owner.HUD.ShowToast(null, L10NImplHelper.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f); } if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped) { Remove(); } if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby && _server.SessionCount == _server.SessionCapacity) { _btnStart.IsVisible = true; } if (_server.Mode == SAMNetworkConnection.ServerMode.InGame) { MainGame.Inst.SetMultiplayerServerLevelScreen(Levels.LEVELS[_server.LevelID], _server.Speed, _server.MusicIndex, _server); } }
private void GetState(float time, out FRectangle rect, out Color col, out float rot) { rect = _rect0; foreach (var tf in transformationsBounding) { if (time < tf.TimeStart) { // nothing } else if (time > tf.TimeEnd) { rect = tf.BoundingsFinal; } else { var p = tf.TimeTransform((time - tf.TimeStart) / (tf.TimeEnd - tf.TimeStart)); rect = FRectangle.Lerp(tf.BoundingsStart, tf.BoundingsFinal, p); } } col = _col0; foreach (var tf in transformationsColor) { if (time < tf.TimeStart) { // nothing } else if (time > tf.TimeEnd) { col = tf.ColorFinal; } else { var p = tf.TimeTransform((time - tf.TimeStart) / (tf.TimeEnd - tf.TimeStart)); col = ColorMath.Blend(tf.ColorStart, tf.ColorFinal, p); } } rot = _rot0; foreach (var tf in transformationsRotation) { if (time < tf.TimeStart) { // nothing } else if (time > tf.TimeEnd) { rot = tf.RotationFinal; } else { var p = tf.TimeTransform((time - tf.TimeStart) / (tf.TimeEnd - tf.TimeStart)); rot = FloatMath.Lerp(tf.RotationStart, tf.RotationFinal, p); } } }
private void DrawColoredNormal(IBatchRenderer sbatch) { sbatch.FillRectangle(VAdapter.VirtualTotalBoundingBox, FlatColors.Background); int offX = (int)(Owner.MapOffsetX / TILE_WIDTH); int offY = (int)(Owner.MapOffsetY / TILE_WIDTH); int extensionX = FloatMath.Ceiling(VAdapter.VirtualGuaranteedBoundingsOffsetX / TILE_WIDTH) + 2; int extensionY = FloatMath.Ceiling(VAdapter.VirtualGuaranteedBoundingsOffsetY / TILE_WIDTH) + 2; int countX = FloatMath.Ceiling(VAdapter.VirtualGuaranteedWidth / TILE_WIDTH); int countY = FloatMath.Ceiling(VAdapter.VirtualGuaranteedHeight / TILE_WIDTH); for (int x = -extensionX; x < countX + extensionX; x++) { for (int y = -extensionY; y < countY + extensionY; y++) { var color = FlatColors.Background; var rx = x - offX; var ry = y - offY; float perc; if (_tileValues.TryGetValue(100000 * rx + ry, out perc)) { color = ColorMath.Blend(FlatColors.Background, FlatColors.BackgroundGreen, (((int)(perc * GRADIENT_RESOLUTION) * 1f) / GRADIENT_RESOLUTION) * BackgroundPercentageOverride); } sbatch.DrawStretched( Textures.TexPixel, new FRectangle( rx * GDConstants.TILE_WIDTH, ry * GDConstants.TILE_WIDTH, GDConstants.TILE_WIDTH, GDConstants.TILE_WIDTH), color); if (GridLineAlpha > 0) { sbatch.DrawStretched( Textures.TexTileBorder, new FRectangle( rx * GDConstants.TILE_WIDTH, ry * GDConstants.TILE_WIDTH, GDConstants.TILE_WIDTH, GDConstants.TILE_WIDTH), Color.White * GridLineAlpha); } } } }
public override void Draw(IBatchRenderer sbatch) { int offX = TILE_WIDTH * (int)(Owner.MapOffsetX / TILE_WIDTH); int offY = TILE_WIDTH * (int)(Owner.MapOffsetY / TILE_WIDTH); int extensionX = FloatMath.Ceiling(VAdapter.VirtualGuaranteedBoundingsOffsetX / TILE_WIDTH) + 2; int extensionY = FloatMath.Ceiling(VAdapter.VirtualGuaranteedBoundingsOffsetY / TILE_WIDTH) + 2; int countX = FloatMath.Ceiling(VAdapter.VirtualGuaranteedWidth / TILE_WIDTH); int countY = FloatMath.Ceiling(VAdapter.VirtualGuaranteedHeight / TILE_WIDTH); if (MainGame.Inst.Profile.EffectsEnabled) { for (int x = -(extensionX + 1); x < countX + extensionX; x++) { for (int y = -(extensionY + 1); y < countY + extensionY; y++) { int cx = ARRAY_EXTEND + x; int cy = ARRAY_EXTEND + y; var color = FlatColors.Background; if (cx >= 0 && cy >= 0 && cx < CELL_W && cy < CELL_H) { var c = _cells[cx, cy]; if (c.Power > 0) { color = ColorMath.Blend(FlatColors.Background, FlatColors.BackgroundGreen, FloatMath.FunctionEaseInOutCubic(c.Power)); } } sbatch.DrawStretched(Textures.TexPixel, new FRectangle(x * GDConstants.TILE_WIDTH - offX, y * GDConstants.TILE_WIDTH - offY, GDConstants.TILE_WIDTH, GDConstants.TILE_WIDTH), color); sbatch.DrawStretched(Textures.TexTileBorder, new FRectangle(x * GDConstants.TILE_WIDTH - offX, y * GDConstants.TILE_WIDTH - offY, GDConstants.TILE_WIDTH, GDConstants.TILE_WIDTH), Color.White); } } } else { var r = new FRectangle(-extensionX * TILE_WIDTH - offX, -extensionY * TILE_WIDTH - offY, (countX + 2 * extensionX) * TILE_WIDTH, (countY + 2 * extensionY) * TILE_WIDTH); sbatch.DrawStretched(Textures.TexPixel, r, FlatColors.Background); for (int x = -extensionX; x < countX + extensionX; x++) { for (int y = -extensionY; y < countY + extensionY; y++) { sbatch.DrawStretched(Textures.TexTileBorder, new FRectangle(x * TILE_WIDTH - offX, y * TILE_WIDTH - offY, TILE_WIDTH, TILE_WIDTH), Color.White); } } } }
protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds) { var radiusOuter = Height / 2f; var radiusInner = radiusOuter * KNOB_SCALE; var knobPosition = new FPoint(bounds.Left + radiusOuter + (Width - 2 * radiusOuter) * _knobPosition, bounds.CenterY); var knobColor = ColorMath.Blend(ColorStateOff, ColorStateOn, _knobPosition); var textHeight = Height / 2; // Background SimpleRenderHelper.DrawRoundedRect(sbatch, bounds, ColorBackground, radiusOuter); // Text[On] if (!string.IsNullOrWhiteSpace(TextStateOn) && _knobPosition > 0) { var pos = new FPoint(bounds.Left + radiusOuter / 2, bounds.CenterY); var alpha = FloatMath.Clamp(1.5f * _knobPosition, 0f, 1f); if (alpha > 0) { FontRenderHelper.DrawTextVerticallyCentered(sbatch, Font, textHeight, TextStateOn, FontColor * alpha, pos); } } // Text[Off] if (!string.IsNullOrWhiteSpace(TextStateOff) && _knobPosition < 1) { var pos = new FPoint(bounds.Right - radiusOuter / 2, bounds.CenterY); var alpha = FloatMath.Clamp(1 - 1.5f * _knobPosition, 0f, 1f); if (alpha > 0) { FontRenderHelper.DrawTextVerticallyCenteredRightAligned(sbatch, Font, textHeight, TextStateOff, FontColor * alpha, pos); } } // Knob sbatch.DrawCentered(StaticTextures.MonoCircle, knobPosition, radiusInner * 2, radiusInner * 2, knobColor); }
public override void OnInitialize() { base.OnInitialize(); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTER, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(0, 0), Size = new FSize(WIDTH, 100), Font = Textures.HUDFontBold, FontSize = 64, L10NText = L10NImpl.STR_MENU_CAP_LOBBY, TextColor = FlatColors.Clouds, }); AddElement(new MultiplayerConnectionStateControl(_server) { Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(16, 16) }); if (_server.ConnType == MultiplayerConnectionType.PROXY) { var gridDisplay = new HUDFixedUniformGrid { Alignment = HUDAlignment.TOPCENTER, RelativePosition = new FPoint(0, 100), GridWidth = 8, GridHeight = 1, ColumnWidth = 84, RowHeight = 84, Padding = 16, }; AddElement(gridDisplay); for (int i = 0; i < 8; i++) { CharDisp[i] = new HUDCharacterControl(1) { Background = HUDBackgroundDefinition.CreateSimpleOutline(FlatColors.Clouds, Color.Black, 4f), TextPadding = 2, TextColor = Color.Black }; gridDisplay.AddElement(i, 0, CharDisp[i]); } var scode = KiddieCryptography.SpiralHexEncode(_server.SessionID, _server.SessionSecret); for (int i = 0; i < 8; i++) { if (i < scode.Length) { CharDisp[i].Character = scode[i]; } } AddOperation(new CharacterControlWaveOperation(CharDisp)); AddElement(new HUDLabel { TextAlignment = HUDAlignment.BOTTOMRIGHT, Alignment = HUDAlignment.BOTTOMRIGHT, RelativePosition = new FPoint(16, FOOTER_HEIGHT + 16), Size = new FSize(320, 128), MaxWidth = 320, WordWrap = HUDWordWrap.WrapByWordTrusted, Font = Textures.HUDFontRegular, FontSize = 32, L10NText = L10NImpl.STR_MENU_MP_LOBBYINFO, TextColor = ColorMath.Blend(FlatColors.Clouds, FlatColors.Background, 0.5f), }); } AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 0 * 32), Size = new FSize(INFO_C1_WIDTH, 32), Font = Textures.HUDFontRegular, FontSize = 32, L10NText = L10NImpl.STR_MENU_MP_LOBBY_PING, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 1 * 32), Size = new FSize(INFO_C1_WIDTH, 32), Font = Textures.HUDFontRegular, FontSize = 32, L10NText = L10NImpl.STR_MENU_MP_LOBBY_USER, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 2 * 32), Size = new FSize(INFO_C1_WIDTH, 32), Font = Textures.HUDFontRegular, FontSize = 32, L10NText = L10NImpl.STR_MENU_MP_LOBBY_LEVEL, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 3 * 32), Size = new FSize(INFO_C1_WIDTH, 32), Font = Textures.HUDFontRegular, FontSize = 32, L10NText = L10NImpl.STR_MENU_MP_LOBBY_MUSIC, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 4 * 32), Size = new FSize(INFO_C1_WIDTH, 32), Font = Textures.HUDFontRegular, FontSize = 32, L10NText = L10NImpl.STR_MENU_MP_LOBBY_SPEED, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C1_LEFT, 208 + 5 * 32), Size = new FSize(INFO_C1_WIDTH, 32), Font = Textures.HUDFontRegular, FontSize = 32, L10NText = L10NImpl.STR_MENU_MP_LOBBY_COLOR, TextColor = FlatColors.Clouds, }); AddElement(new HUDLambdaLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 0 * 32), Size = new FSize(INFO_C2_WIDTH, 32), MaxWidth = INFO_C2_WIDTH, Font = Textures.HUDFontRegular, FontSize = 32, Lambda = () => $"{(int)(_server.ProxyPing.Value * 1000)}ms", WordWrap = HUDWordWrap.Ellipsis, TextColor = FlatColors.Clouds, }); AddElement(new HUDLambdaLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 1 * 32), Size = new FSize(INFO_C2_WIDTH, 32), MaxWidth = INFO_C2_WIDTH, Font = Textures.HUDFontRegular, FontSize = 32, Lambda = () => $"{_server.SessionCount} / {_server.SessionCapacity}", WordWrap = HUDWordWrap.Ellipsis, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 2 * 32), Size = new FSize(INFO_C2_WIDTH, 32), MaxWidth = INFO_C2_WIDTH, Font = Textures.HUDFontRegular, FontSize = 32, Text = Levels.LEVELS[_server.LevelID].FullName, WordWrap = HUDWordWrap.Ellipsis, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 3 * 32), Size = new FSize(INFO_C2_WIDTH, 32), MaxWidth = INFO_C2_WIDTH, Font = Textures.HUDFontRegular, FontSize = 32, Text = (_server.MusicIndex + 1).ToString(), WordWrap = HUDWordWrap.Ellipsis, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 4 * 32), Size = new FSize(INFO_C2_WIDTH, 32), MaxWidth = INFO_C2_WIDTH, Font = Textures.HUDFontRegular, FontSize = 32, Text = Fmt(_server.Speed), WordWrap = HUDWordWrap.Ellipsis, TextColor = FlatColors.Clouds, }); AddElement(new HUDLabel { TextAlignment = HUDAlignment.CENTERLEFT, Alignment = HUDAlignment.TOPLEFT, RelativePosition = new FPoint(INFO_C2_LEFT, 208 + 5 * 32), Size = new FSize(INFO_C2_WIDTH, 32), MaxWidth = INFO_C2_WIDTH, Font = Textures.HUDFontRegular, FontSize = 32, L10NText = Fraction.NAME_PLAYER, WordWrap = HUDWordWrap.Ellipsis, TextColor = Fraction.COLOR_PLAYER, }); AddElement(new HUDRectangle(0) { Alignment = HUDAlignment.BOTTOMRIGHT, Size = new FSize(WIDTH, FOOTER_HEIGHT), Definition = HUDBackgroundDefinition.CreateRounded(FlatColors.BackgroundHUD2, 16, false, false, true, true), }); AddElement(new HUDTextButton(2) { Alignment = HUDAlignment.BOTTOMLEFT, RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 0.5f * GDConstants.TILE_WIDTH), Size = new FSize(6.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH), L10NText = L10NImpl.STR_MENU_DISCONNECT, TextColor = Color.White, Font = Textures.HUDFontBold, FontSize = 55, TextAlignment = HUDAlignment.CENTER, TextPadding = 8, BackgroundNormal = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Asbestos, 16), BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.MidnightBlue, 16), Click = OnClickCancel, }); AddElement(_btnStart = new HUDTextButton(2) { Alignment = HUDAlignment.BOTTOMRIGHT, RelativePosition = new FPoint(0.5f * GDConstants.TILE_WIDTH, 0.5f * GDConstants.TILE_WIDTH), Size = new FSize(5.5f * GDConstants.TILE_WIDTH, 1.0f * GDConstants.TILE_WIDTH), L10NText = L10NImpl.STR_MENU_MP_START, TextColor = Color.White, Font = Textures.HUDFontBold, FontSize = 55, TextAlignment = HUDAlignment.CENTER, TextPadding = 8, BackgroundNormal = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Emerald, 16), BackgroundPressed = HUDBackgroundDefinition.CreateRoundedBlur(FlatColors.Nephritis, 16), IsVisible = false, Click = OnClickStart, }); }