private void updateMapSettings() { MapConfig currentMap = maps[currentMapIndex]; map0 = maps[currentMapIndex > 0 ? currentMapIndex - 1 : maps.Count - 1].preview; map1 = currentMap.preview; map2 = maps[currentMapIndex < maps.Count - 1 ? currentMapIndex + 1 : 0].preview; gameMode = currentMap.gameMode; if (btnDelay <= 0) { animateMap = true; mapAnimationStartTime = Starburst.inst().get_time(); } if (redBots > MaxNumBots) { redBots = MaxNumBots; } }
public override void draw(float t, float dt) { if (vol < 0.7f) { vol += 0.7f * dt / 3.0f; if (vol > 0.7f) { vol = 0.7f; } MediaPlayer.Volume = vol; } if (fade < 1.0f) { fade += 1.0f * dt / 3.0f; if (fade > 1.0f) { fade = 1.0f; } } Starburst.inst().GraphicsDevice.Clear(Color.Black); base.draw(t, dt); Viewport vp = sprite_batch.GraphicsDevice.Viewport; int middleSpacing = 20; // hämta spelare och position var entities = Starburst.inst().get_entities_fast(typeof(Input)); Position position; if (entities.Count > 0) { position = entities[0].get_component <Position>(); } else { position = new Position(); } sprite_batch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); var s = "v" + Starburst.VERSION; var ts = GFX_Util.measure_string_small(s); GFX_Util.draw_def_text_small(sprite_batch, s, vp.Width - ts.X - 10, vp.Height - 10 - ts.Y); String logo = "Starburst"; Vector2 logoSize = largeFont.MeasureString(logo); if (!started) { startTime = t; started = true; } //logo-animation float logoY = (t - startTime < animateInTime) ? (float)Easing.BounceEaseOut((t - startTime), -70, 150, animateInTime) : 80; float opacity = (t - startTime < animateInTime * .5f) ? (float)Easing.QuadEaseInOut((t - startTime), 0, 1, animateInTime * .5f) : 1; sprite_batch.DrawString(largeFont, logo, new Vector2(vp.Width * .5f - logoSize.X * .5f, logoY), new Color(Color.Gold, opacity)); int currentTopY = 225; if (lowRes) { int endY = (int)(vp.Height * .5f - 15); currentTopY = 160; largeMapSize = endY - currentTopY; smallMapSize = (int)(largeMapSize * .75f); } // map-animation vid navigation int animDistance = 150; int startY = currentTopY - animDistance; if (t - startTime < animateInTime) { currentTopY = (int)Easing.CubicEaseOut((t - startTime), startY, animDistance, animateInTime); } // map-switch-animation float mapAnimationSize = smallMapSize; float currentMapSize = largeMapSize; if (animateMap) { currentMapSize = (float)Easing.BackEaseOut((t - mapAnimationStartTime), largeMapSize - mapAnimationSize, mapAnimationSize, mapAnimationDuration); } String map = "Map"; Vector2 mapTextSize = font.MeasureString(map); sprite_batch.DrawString(font, map, new Vector2(vp.Width * .5f - mapTextSize.X * .5f, currentTopY), Color.White); int mapY = currentTopY + 50; sprite_batch.Draw(map0, new Rectangle((int)(vp.Width * .5f - (currentMapSize * .85f + currentMapSize * .15f) * .5f - smallMapSize - 20), (int)(mapY + (largeMapSize - smallMapSize) * .5f), smallMapSize, smallMapSize), Color.White * 0.75f); sprite_batch.Draw(map2, new Rectangle((int)(vp.Width * .5f + (currentMapSize * .85f + currentMapSize * .15f) * .5f + 20), (int)(mapY + (largeMapSize - smallMapSize) * .5f), smallMapSize, smallMapSize), Color.White * 0.75f); sprite_batch.Draw(map1, new Rectangle((int)(vp.Width * .5f - currentMapSize * .5f), (int)(mapY + (largeMapSize - currentMapSize) * .5f), (int)currentMapSize, (int)currentMapSize), Color.White); String arrow = "<"; Vector2 arrowSize = font.MeasureString(arrow); sprite_batch.DrawString(font, "<", new Vector2((int)(vp.Width * .5f - largeMapSize * .5f - 20 - smallMapSize - 20 - arrowSize.X), mapY + largeMapSize * .5f - arrowSize.Y * .5f), (position.y == (int)options.map ? new Color(Color.Gold, textOpacity) : Color.White)); sprite_batch.DrawString(font, ">", new Vector2((int)(vp.Width * .5f + largeMapSize * .5f + 20 + smallMapSize + 20), mapY + largeMapSize * .5f - arrowSize.Y * .5f), (position.y == (int)options.map ? new Color(Color.Gold, textOpacity) : Color.White)); int settingOffset = (int)(vp.Height * .5f + 75); String ctfString = "Capture the flag"; Vector2 leftTextSize = font.MeasureString(ctfString); int leftTextX = (int)(vp.Width * .5f - leftTextSize.X - middleSpacing); int rightTextX = (int)(vp.Width * .5f + middleSpacing); int rowHeight = !lowRes ? 40 : 30; // settings-animation animDistance = -150; startY = settingOffset - animDistance; if (t - startTime < animateInTime) { settingOffset = (int)Easing.CubicEaseOut((t - startTime), startY, animDistance, animateInTime); } sprite_batch.DrawString(font, "Map mode", new Vector2(leftTextX, settingOffset), Color.White); sprite_batch.DrawString(font, maps[currentMapIndex].mapName, new Vector2(rightTextX, settingOffset), Color.White); settingOffset += (int)(rowHeight * .5f); sprite_batch.DrawString(font, "Game time", new Vector2(leftTextX, settingOffset + rowHeight * 1), Color.White); int time = 5; if (gameTime == GameTime.Ten) { time = 10; } else if (gameTime == GameTime.Twenty) { time = 20; } else if (gameTime == GameTime.Thirty) { time = 30; } String timeString = "< " + time + " minutes >"; sprite_batch.DrawString(font, timeString, new Vector2(rightTextX, settingOffset + rowHeight * 1), (position.y == (int)options.time ? new Color(Color.Gold, textOpacity) : Color.White)); sprite_batch.DrawString(font, "Asteroids", new Vector2(leftTextX, settingOffset + rowHeight * 2), Color.White); String asteroidString = "Off"; if (asteroidCount == Amount.few) { asteroidString = "Few"; } else if (asteroidCount == Amount.medium) { asteroidString = "Medium"; } else if (asteroidCount == Amount.many) { asteroidString = "Many"; } sprite_batch.DrawString(font, "< " + asteroidString + " >", new Vector2(rightTextX, settingOffset + rowHeight * 2), (position.y == (int)options.asteroids ? new Color(Color.Gold, textOpacity) : Color.White)); sprite_batch.DrawString(font, "Powerups", new Vector2(leftTextX, settingOffset + rowHeight * 3), Color.White); String powerupString = "Off"; if (powerupCount == Amount.few) { powerupString = "Few"; } else if (powerupCount == Amount.medium) { powerupString = "Medium"; } else if (powerupCount == Amount.many) { powerupString = "Many"; } sprite_batch.DrawString(font, "< " + powerupString + " >", new Vector2(rightTextX, settingOffset + rowHeight * 3), (position.y == (int)options.powerups ? new Color(Color.Gold, textOpacity) : Color.White)); MapConfig currentMap = maps[currentMapIndex]; if (currentMap.bots) { sprite_batch.DrawString(font, (currentMap.gameMode == Playing.Game_Config.GM_DEATHMATCH) ? "AI" : "Red AI", new Vector2(leftTextX, settingOffset + rowHeight * 4), Color.White); sprite_batch.DrawString(font, "< " + (currentMap.gameMode == Playing.Game_Config.GM_DEATHMATCH ? (redBots == 0 ? "off" : (redBots).ToString() + " bot" + (redBots != 1 ? "s" : "")) : redBots == 0 ? "off" : redBots.ToString() + " bot" + (redBots != 1 ? "s" : "")) + " >", new Vector2(rightTextX, settingOffset + rowHeight * 4), (position.y == (int)options.redBots ? new Color(Color.Gold, textOpacity) : Color.White)); if (currentMap.gameMode == Playing.Game_Config.GM_TEAM_DEATHMATCH) { sprite_batch.DrawString(font, "Blue AI", new Vector2(leftTextX, settingOffset + rowHeight * 5), Color.White); sprite_batch.DrawString(font, "< " + (blueBots == 0 ? "off" : blueBots.ToString() + " bot" + (blueBots != 1 ? "s" : "")) + " >", new Vector2(rightTextX, settingOffset + rowHeight * 5), (position.y == (int)options.blueBots ? new Color(Color.Gold, textOpacity) : Color.White)); } } // kontroll-"tutorial" if (gamepads.Contains(true)) { sprite_batch.Draw(controller_a_button, new Rectangle(20, yPos, controllerBtnSize, controllerBtnSize), Color.White); sprite_batch.DrawString(font, text_ok, new Vector2(20 + controllerBtnSize + 10, yPos + heightDiff * .5f), Color.White); sprite_batch.Draw(controller_l_stick, new Rectangle((int)(20 + controllerBtnSize + 10 + okSize.X + 10), yPos, controllerBtnSize, controllerBtnSize), Color.White); sprite_batch.DrawString(font, text_select, new Vector2(20 + controllerBtnSize + 10 + okSize.X + 10 + controllerBtnSize + 10, yPos + heightDiff * .5f), Color.White); } String text = "Continue to player selection"; Vector2 textSize = font.MeasureString(text); sprite_batch.DrawString(font, text, new Vector2((int)((vp.Width * .5f) - (textSize.X * .5f)), vp.Height - (lowRes ? 50 : 80)), (position.y == (int)options.proceed ? new Color(Color.Gold, textOpacity) : Color.White)); String exitText = "Exit game"; Vector2 exitTextSize = font.MeasureString(exitText); sprite_batch.DrawString(font, exitText, new Vector2((int)((vp.Width * .5f) - (exitTextSize.X * .5f)), vp.Height - (lowRes ? 25 : 40)), (position.y == (int)options.exit ? new Color(Color.Gold, textOpacity) : Color.White)); GFX_Util.fill_rect(sprite_batch, new Rectangle(0, 0, vp.Width, vp.Height), Color.Black * (1.0f - fade)); sprite_batch.End(); System.Threading.Thread.Sleep(10); // no need to spam menu }
private void proceed() { int time = 5; if (gameTime == GameTime.Ten) { time = 10; } else if (gameTime == GameTime.Twenty) { time = 20; } else if (gameTime == GameTime.Thirty) { time = 30; } int asteroid = (asteroidCount == 0) ? 0 : maps[currentMapIndex].asteroidAmounts[(int)asteroidCount - 1]; int powerup = 0; int powerupTime = 0; if (powerupCount == Amount.few) { powerup = 10; powerupTime = 20; } else if (powerupCount == Amount.medium) { powerup = 15; powerupTime = 15; } else if (powerupCount == Amount.many) { powerup = 20; powerupTime = 10; } btnDelay = BTN_DELAY; started = false; Starburst.inst().message("play_sound", new { name = "menu_positive" }); MapConfig selectedMap = maps[currentMapIndex]; gameConfig = new Playing.Game_Config() { match_time = time * 60, num_asteroids = asteroid, num_powerups = powerup == 0 ? 0 : redBots + blueBots + powerup, powerup_spawn_time = redBots + blueBots == 0 ? powerupTime : ((powerupTime - (int)((redBots + blueBots) * 0.5f)) <= 2 ? 2 : (powerupTime - (int)((redBots + blueBots) * 0.5f))), map_name = selectedMap.fileName, mode = selectedMap.gameMode, enable_soccer = selectedMap.soccerBall, soccer_mode = selectedMap.soccerMode, red_bots = (selectedMap.bots ? (selectedMap.gameMode == Playing.Game_Config.GM_TEAM_DEATHMATCH ? redBots : redBots) : 0), blue_bots = (selectedMap.bots ? (selectedMap.gameMode == Playing.Game_Config.GM_TEAM_DEATHMATCH ? blueBots : 0) : 0) }; MediaPlayer.Volume = 0.7f; vol = 0.7f; fade = 1.0f; Starburst.inst().enter_state(new Player_Selection_Menu(this)); }