private void moveLeft() { var entities = Starburst.inst().get_entities_fast(typeof(Position)); Entity entity = entities[0]; var cursorPosition = entity.get_component <Position>(); if (cursorPosition.y == (int)options.map) { currentMapIndex = (currentMapIndex == 0) ? maps.Count - 1 : currentMapIndex - 1; updateMapSettings(); } else if (cursorPosition.y == (int)options.time) { gameTime = gameTime == 0 ? GameTime.Thirty : gameTime - 1; } else if (cursorPosition.y == (int)options.asteroids) { asteroidCount = asteroidCount == 0 ? Amount.many : asteroidCount - 1; } else if (cursorPosition.y == (int)options.powerups) { powerupCount = powerupCount == 0 ? Amount.many : powerupCount - 1; } else if (cursorPosition.y == (int)options.redBots) { redBots = redBots == 0 ? MaxNumBots : redBots - 1; } else if (cursorPosition.y == (int)options.blueBots) { blueBots = blueBots == 0 ? MaxNumBots : blueBots - 1; } Starburst.inst().message("play_sound_asset", new { name = "menu_click" }); }
public override void init() { splash = Starburst.inst().get_content <Texture2D>("splash"); font = Starburst.inst().get_content <SpriteFont>("sector034"); outDelay = delay + duration + displayTime; splashTime = outDelay + duration; }
public static Component[] create_components(Input inputhandler) { string sprite = "keys2"; if (inputhandler.up == Keys.W) { sprite = "keys1"; } if (inputhandler.device == Input.InputType.Controller) { sprite = "controller" + (int)(inputhandler.gp_index + 1); } var playerpos = new Position() { x = 0, y = 0 }; return(new Component[] { inputhandler, playerpos, new Sprite() { texture = Starburst.inst().get_content <Texture2D>("menu/" + sprite) } }); }
public override void init() { Gamepad_Util.vibrate(0, 0.0f, 0.0f); Gamepad_Util.vibrate(1, 0.0f, 0.0f); Gamepad_Util.vibrate(2, 0.0f, 0.0f); Gamepad_Util.vibrate(3, 0.0f, 0.0f); graphicsDevice = Starburst.inst().GraphicsDevice; sprite_batch = new SpriteBatch(graphicsDevice); add_subsystems( new Menu_Input_Handler(), new Sound() ); font = Starburst.inst().get_content <SpriteFont>("sector034"); // hämta inputs från föregående state var inputs = last_state.get_entities_fast(typeof(Input)); for (int i = 0; i < inputs.Count; i++) { var input = inputs[i].get_component <Input>(); var gamepadPlayer = create_entity(Player.create_components(input)); } restore_vol = MediaPlayer.Volume; MediaPlayer.Volume *= 0.4f; }
private void moveRight() { var entities = Starburst.inst().get_entities_fast(typeof(Input)); Entity cursor = entities[0]; Position cursorPosition = cursor.get_component <Position>(); if (cursorPosition.y == (int)options.map) { currentMapIndex = (currentMapIndex == maps.Count - 1) ? 0 : currentMapIndex + 1; updateMapSettings(); } else if (cursorPosition.y == (int)options.time) { gameTime = gameTime == GameTime.Thirty ? 0 : gameTime + 1; } else if (cursorPosition.y == (int)options.asteroids) { asteroidCount = asteroidCount == Amount.many ? 0 : asteroidCount + 1; } else if (cursorPosition.y == (int)options.powerups) { powerupCount = powerupCount == Amount.many ? 0 : powerupCount + 1; } else if (cursorPosition.y == (int)options.redBots) { redBots = redBots == MaxNumBots ? 0 : redBots + 1; } else if (cursorPosition.y == (int)options.blueBots) { blueBots = blueBots == MaxNumBots ? 0 : blueBots + 1; } Starburst.inst().message("play_sound_asset", new { name = "menu_click" }); }
private void select() { if (!can_leave_state) { return; } can_leave_state = false; var entities = get_entities_fast(typeof(Input)); Entity cursor = entities[0]; Position cursorPosition = cursor.get_component <Position>(); if (cursorPosition.y == (int)options.resume) { resume(); } else if (cursorPosition.y == (int)options.quit) { Playing_State gameState = (Playing_State)last_state; var scoreEntities = gameState.get_entities_fast(typeof(Score)); List <Entity> players = new List <Entity>(); for (int i = 0; i < scoreEntities.Count; i++) { if ((scoreEntities[i].get_component <Ship_Info>() != null)) { players.Add(scoreEntities[i]); } } Starburst.inst().leave_state(); Starburst.inst().leave_state(); Starburst.inst().enter_state(new Results_State(players, gameState.game_conf)); } }
private void tryStartGame() { // om minsta antal spelare är klara, starta spel if (haveEnoughPlayers() && canStartGame) { canStartGame = false; // hämta inputhandlers, lägg dem i en lista för att vidarebefordra till spel-statet // (sorterade efter position) List <Input> inputs = new List <Input>(playerCount); for (int i = 0; i < 4; i++) { inputs.Add(null); } var entites = Starburst.inst().get_entities_fast(typeof(Input)); for (int i = 0; i < entites.Count; i++) { Input input = entites[i].get_component <Input>(); Position position = entites[i].get_component <Position>(); if (position.y == 2) { inputs[(int)position.x] = input; } } btnDelay = BTN_DELAY; Starburst.inst().message("play_sound_asset", new { name = "menu_positive" }); Starburst.inst().leave_state(); // ta bort nuvarande state för att man ska gå till "huvudmeny" från spelläge Starburst.inst().enter_state(new Playing_State(inputs, parent.gameConfig)); } }
private void moveUp() { var entities = Starburst.inst().get_entities_fast(typeof(Position)); Entity entity = entities[0]; var position = entity.get_component <Position>(); if (position.y == (int)options.exit) { if (maps[currentMapIndex].bots) { position.y = (maps[currentMapIndex].gameMode == Playing.Game_Config.GM_DEATHMATCH) ? (int)options.redBots : position.y - 1; } else { position.y = (int)options.powerups; } } else if (position.y == 0) { position.y = (int)options.exit; } else if (position.y > 0) { position.y--; Starburst.inst().message("play_sound_asset", new { name = "menu_click" }); } }
private void tile_asteroid(Entity a, Entity b, dynamic data) { state.create_entity(new Component[] { new TTL { max_time = 0.05f }, new Particle_Emitter { emit_fn = () => { return(new Component[] { new Position { x = data.c_x, y = data.c_y }, new Velocity { x = (float)Math.Cos((float)rand.NextDouble() * 6.28) * (100.0f + 50.0f * (float)rand.NextDouble()), y = (float)Math.Sin((float)rand.NextDouble() * 6.28) * (100.0f + 50.0f * (float)rand.NextDouble()) }, new Sprite { blend_mode = Sprite.BM_ADD, color = new Color(0.9f, 0.6f, 0.5f), layer_depth = 0.3f, scale = 0.9f + (float)rand.NextDouble() * 0.9f, texture = Starburst.inst().get_content <Texture2D>("particle") }, new TTL { max_time = 0.2f + (float)(rand.NextDouble() * 0.1f) } }); }, interval = 0.01f, num_particles_per_emit = 10 + rand.Next(0, 20) } }); }
private void goBack() { if (!goingBack) { goingBack = true; Starburst.inst().leave_state(); } }
public override void draw(float t, float dt) { if (t > 2.0f) { Starburst.inst().leave_state(); Starburst.inst().enter_state(new Results_State(players, gameConfig)); } }
public override void init() { var sprite_batch = new SpriteBatch(Starburst.inst().GraphicsDevice); sprite_batch.Begin(); GFX_Util.fill_rect(sprite_batch, new Rectangle(0, 0, Starburst.inst().GraphicsDevice.Viewport.Width, Starburst.inst().GraphicsDevice.Viewport.Height), Color.Black * 0.45f); sprite_batch.End(); }
private void tryPause() { if (can_pause) { can_pause = false; Starburst.inst().enter_state(new Pause_State(renderer.backbuffer_target, this)); } }
public override void update(float t, float dt) { base.update(t, dt); elapsedTime += dt; if (btnCoolDown > 0) { btnCoolDown -= dt; } KeyboardState state = Keyboard.GetState(); var skip_button_pressed = state.IsKeyDown(Keys.Enter); for (int i = 0; i <= 3; i++) { if (GamePad.GetState((PlayerIndex)i).IsConnected&& GamePad.GetState((PlayerIndex)i).Buttons.Start == ButtonState.Pressed) { skip_button_pressed = true; break; } } if (!preloaded) { skip_button_pressed = false; } if (elapsedTime >= splashTime || skip_button_pressed) { if (!skip_button_pressed) { System.Threading.Thread.Sleep(700); } Starburst.inst().enter_state(new Main_Menu_State()); return; } if (btnCoolDown <= 0 && state.IsKeyDown(Keys.LeftAlt) && state.IsKeyDown(Keys.Enter)) { btnCoolDown = COOLDOWN_TIME; Starburst.inst().GraphicsMgr.ToggleFullScreen(); } if (!preloading && t > duration + 0.5f) { Starburst.inst().begin_preload_content((s, p) => { asset_name = s; percent_preloaded = (int)Math.Round(p * 100.0f); }); preloading = true; } if (preloading && !preloaded) { preloaded = !Starburst.inst().preload_next(); elapsedTime -= dt; // wait until loaded } }
public override void draw(float t, float dt) { graphicsDevice.Clear(Color.Black); Viewport vp = sprite_batch.GraphicsDevice.Viewport; // gamla init-saker //draw-grejer var w = Starburst.inst().GraphicsMgr.PreferredBackBufferWidth; var h = Starburst.inst().GraphicsMgr.PreferredBackBufferHeight; sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); sprite_batch.Draw(bg_tex, Vector2.Zero); GFX_Util.fill_rect(sprite_batch, new Rectangle(0, 0, w, h), Color.Black * 0.5f); var s = new[] { "one", "two", "three", "four" }; var text_size = GFX_Util.measure_string("Paused"); var tx = (w - text_size.X) * 0.5f; var ty = (h - text_size.Y) * 0.5f; var pl = last_state.get_entities_fast(typeof(Score)); int vertSpacing = 10; int startY = (int)(vp.Height * .25f); GFX_Util.draw_def_text(sprite_batch, "Paused", tx, ty); sprite_batch.End(); //hämta position från första input-entiteten var players = get_entities_fast(typeof(Position)); Position cursorPosition = players[0].get_component <Position>(); //spritebatch sprite_batch.Begin(); // resume String menuText = "Resume"; Vector2 menuTextSize = font.MeasureString(menuText); int totalMenuHeight = (int)(menuTextSize.Y * 2 + vertSpacing * 1); startY = (int)(vp.Height * .75f - totalMenuHeight * .5f); sprite_batch.DrawString(font, menuText, new Vector2(vp.Width * .5f - menuTextSize.X * .5f, startY), (cursorPosition.y == (int)options.resume ? Color.Gold : Color.White)); // quit menuText = "Quit"; menuTextSize = font.MeasureString(menuText); sprite_batch.DrawString(font, menuText, new Vector2(vp.Width * .5f - menuTextSize.X * .5f, startY + menuTextSize.Y + vertSpacing), (cursorPosition.y == (int)options.quit ? Color.Gold : Color.White)); sprite_batch.End(); Thread.Sleep(10); }
private void proceed() { if (!can_leave_state) { return; } can_leave_state = false; Starburst.inst().leave_state(); }
public static Component[] create_components() { frame *= 17; frame = (frame % 20); var ascale = 0.5f + (float)rand.NextDouble() * 1.0f; ascale *= 0.6f; int i = rand.Next(0, 2); string asset; if (i == 0) { asset = "asteroid"; } else { asset = "asteroid2"; } var col = new Color(0.50f + (float)rand.NextDouble() * 0.1f, 0.50f, 0.50f); return(new Component[] { //new Angle() { angle = 0.1f * (float)rand.NextDouble() }, new Position() { x = 600, y = 200 }, new Velocity() { x = 0.0f, y = 0.0f }, new Sprite() { texture = Starburst.inst().get_content <Texture2D>(asset), frame_width = 128, frame_height = 128, num_frames = 31, fps = 17.0f + (float)rand.NextDouble() * 15.0f, frame_timer = (float)rand.NextDouble(), frame_counter = frame, scale = ascale, color = col }, new Bounding_Circle() { radius = 46.0f * ascale }, new Mass() { mass = (30.0f * (ascale + 1.0f) * (ascale + 1.0f)) * 10.0f }, new Shadow() }); }
public override void on_message(string msg, dynamic data) { if (btnDelay <= 0) { if (msg.Equals("fullscreen")) { btnDelay = .5f; Starburst.inst().GraphicsMgr.ToggleFullScreen(); } else if (msg.Equals("up")) { moveUp(); } else if (msg.Equals("down")) { moveDown(); } else if (msg.Equals("left")) { moveLeft(); } else if (msg.Equals("right")) { moveRight(); } else if (msg.Equals("select")) { var entities = Starburst.inst().get_entities_fast(typeof(Input)); Entity cursor = entities[0]; Position cursorPosition = cursor.get_component <Position>(); if (cursorPosition.y == (int)options.proceed) { proceed(); } else if (cursorPosition.y == (int)options.exit) { Starburst.inst().Quit(); } else { moveRight(); } } else if (msg.Equals("start")) { proceed(); } else if (msg.Equals("escape")) { Starburst.inst().Quit(); } } }
private void soccerball_player(Entity a, Entity b, dynamic data) { var soccerball = (a.get_component <Sprite>().texture.Name == "soccerball") ? a : b; var player = (soccerball == a) ? b : a; var v_x = soccerball.get_component <Velocity>().x - player.get_component <Velocity>().x; var v_y = soccerball.get_component <Velocity>().y - player.get_component <Velocity>().y; var power = (float)Math.Sqrt(v_x * v_x + v_y * v_y); state.create_entity(new Component[] { new TTL { max_time = 0.05f }, new Particle_Emitter() { emit_fn = () => { var theta1 = 2.0f * 3.1415f * (float)rand.NextDouble(); var theta2 = 2.0f * 3.1415f * (float)rand.NextDouble(); var radius = 13.0f * (float)rand.NextDouble(); var speed = 200.0f * (float)(0.05f + rand.NextDouble()); return(new Component[] { new Position() { x = data.c_x + (float)Math.Cos(theta1) * radius, y = data.c_y + (float)Math.Sin(theta1) * radius }, new Velocity() { x = (float)Math.Cos(theta2) * speed, y = (float)Math.Sin(theta2) * speed }, new Sprite() { texture = Starburst.inst().get_content <Texture2D>("particle"), color = new Color(1.0f, 0.8f, 0.3f, 1.0f), scale = 0.4f + (float)rand.NextDouble() * 0.3f, blend_mode = Sprite.BM_ADD, layer_depth = 0.3f }, new TTL { alpha_fn = (x, max) => 1.0f - (x / max) * (x / max), max_time = 0.35f + (float)Math.Pow((float)(rand.NextDouble() * 0.7f), 3.0f) } }); }, interval = 0.01f, num_particles_per_emit = (int)(0.03f * power) } }); }
private void bullet2_player(Entity a, Entity b, dynamic data) { var bullet = (a.get_component <Sprite>().texture.Name == "beams2") ? a : b; var player = (bullet == a) ? b : a; state.create_entity(new Component[] { new TTL { max_time = 0.05f }, new Particle_Emitter { emit_fn = () => { var theta1 = 2.0f * 3.1415f * (float)rand.NextDouble(); var theta2 = 2.0f * 3.1415f * (float)rand.NextDouble(); var radius = 13.0f * (float)rand.NextDouble(); var speed = (500.0f + 180.0f * (float)Math.Pow(rand.NextDouble(), 2.0f)); return(new Component[] { new Mass { drag_coeff = 2.5f }, new Position { x = data.c_x + (float)Math.Cos(theta1) * radius, y = data.c_y + (float)Math.Sin(theta1) * radius }, new Velocity { x = (float)Math.Cos(theta2) * speed, y = (float)Math.Sin(theta2) * speed }, new Sprite { blend_mode = Sprite.BM_ADD, color = new Color(0.9f, 0.7f, 1.0f, 1.0f), layer_depth = 0.3f, scale = 0.4f + (float)rand.NextDouble() * 0.7f, texture = Starburst.inst().get_content <Texture2D>("particle2") }, new TTL { alpha_fn = (x, max) => 1.0f - x / max, max_time = 0.2f + (float)(rand.NextDouble() * 0.1f) } }); }, interval = 0.01f, num_particles_per_emit = 10 + rand.Next(0, 20) } }); bullet.destroy(); inflictBulletDamage(bullet, player, data); }
public override void draw(float t, float dt) { base.draw(t, dt); Starburst.inst().GraphicsDevice.Clear(Color.Black); SpriteBatch sprite_batch = new SpriteBatch(Starburst.inst().GraphicsDevice); Viewport vp = sprite_batch.GraphicsDevice.Viewport; int tex_h = (int)(vp.Height * 0.75f); int tex_w = tex_h; sprite_batch.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied); Rectangle destRect = new Rectangle((int)(vp.Width * .5 - tex_w * .5), (int)(vp.Height * .5 - tex_h * .5), tex_w, tex_h); if (elapsedTime > delay && elapsedTime < outDelay) { sprite_batch.Draw(splash, destRect, new Color(255, 255, 255, quadInOut(delay, 0, 1))); } else if (elapsedTime >= outDelay) { sprite_batch.Draw(splash, destRect, new Color(255, 255, 255, 1 - quadInOut(outDelay, 0, 1))); } if (preloaded || preloading) { String text = preloaded ? "Press enter to continue" : "Loading... " + percent_preloaded + "%"; Vector2 textSize = font.MeasureString(!preloaded ? "Loading... 100%" : "Press enter to continue"); var alpha = 1.0f; if (preloaded) { alpha = (float)Math.Cos(1.7f * t * 3.141592) * 0.5f + 0.5f; } alpha *= 1 - quadInOut(outDelay, 0, 1); sprite_batch.DrawString(font, text, new Vector2(vp.Width * .5f - textSize.X * .5f, vp.Height - textSize.Y - 20), Color.White * alpha); if (preloading && !preloaded) { GFX_Util.fill_rect(sprite_batch, new Rectangle(0, vp.Height - 4, (int)((float)percent_preloaded * vp.Width / 100.0f), 4), Color.White); } } else { String text = "Please wait..."; Vector2 textSize = font.MeasureString(text); sprite_batch.DrawString(font, text, new Vector2(vp.Width * .5f - textSize.X * .5f, vp.Height - textSize.Y - 20), Color.White); } sprite_batch.End(); System.Threading.Thread.Sleep(1); }
public override void on_message(string msg, dynamic data) { if (btnDelay <= 0) { if (msg.Equals("fullscreen")) { btnDelay = .5f; Starburst.inst().GraphicsMgr.ToggleFullScreen(); } else if (msg.Equals("select") || msg.Equals("start")) { proceed(); } } }
public override void on_message(string msg, dynamic data) { if (msg == "collision") { coll_handler.on_collision(data.entity1, data.entity2, data); return; } else if (msg.Equals("start")) { tryPause(); } else if (msg.Equals("fullscreen")) { Starburst.inst().GraphicsMgr.ToggleFullScreen(); System.Threading.Thread.Sleep(500); } }
public override void on_message(string msg, dynamic data) { if (btnDelay <= 0) { if (msg.Equals("fullscreen")) { btnDelay = .5f; Starburst.inst().GraphicsMgr.ToggleFullScreen(); } else if (msg.Equals("up")) { var entities = Starburst.inst().get_entities_fast(typeof(Position)); Entity entity = entities[0]; var position = entity.get_component <Position>(); if (position.y > 0) { position.y -= 1; position.x = 0; Starburst.inst().message("play_sound_asset", new { name = "menu_click" }); } } else if (msg.Equals("down")) { var entities = Starburst.inst().get_entities_fast(typeof(Position)); Entity entity = entities[0]; var position = entity.get_component <Position>(); if (position.y < (int)options.quit) { position.y += 1; Starburst.inst().message("play_sound_asset", new { name = "menu_click" }); } } else if (msg.Equals("select")) { select(); } else if (msg.Equals("start")) { select(); } else if (msg.Equals("escape")) { resume(); } } }
private void printScore(List <Entity> playerList, int currentOffset) { for (int i = 0; i < playerList.Count; i++) { Entity player = playerList[i]; Score player_score = player.get_component <Score>(); Ship_Info player_info = player.get_component <Ship_Info>(); int rowY = currentOffset + rowHeight * i + textOffset + vertSpacing * i; int iconY = (int)(rowY + rowHeight * .5f - iconSizeY * .5f - 3); if (player.get_component <Input>() == null) { GFX_Util.draw_def_text_small(sprite_batch, player_string(player), nameX, rowY); } else { var player_input = player.get_component <Input>(); if (player_input != null && player_input.device == Input.InputType.Controller) { Texture2D ph_icon = Starburst.inst().get_content <Texture2D>("menu/controller" + (int)(player_input.gp_index + 1)); sprite_batch.Draw(ph_icon, destinationRectangle: new Rectangle(iconX, iconY, iconSizeX, iconSizeY)); GFX_Util.draw_def_text(sprite_batch, player_string(player), nameX, rowY - (!lowRes ? 3 : 0)); } else { int key_index; if (player_input.up == Keys.W) { key_index = 1; } else { key_index = 2; } Texture2D ph_icon = Starburst.inst().get_content <Texture2D>("menu/keys" + key_index); sprite_batch.Draw(ph_icon, destinationRectangle: new Rectangle(iconX, iconY, iconSizeX, iconSizeY)); GFX_Util.draw_def_text(sprite_batch, player_string(player), nameX, rowY - (!lowRes ? 3 : 0)); } } GFX_Util.draw_def_text_small(sprite_batch, player_score.num_kills.ToString(), killsX, rowY); GFX_Util.draw_def_text_small(sprite_batch, player_score.num_deaths.ToString(), deathsX, rowY); GFX_Util.draw_def_text_small(sprite_batch, player_score.score.ToString(), scoreX, rowY); } }
public static Component[] create_components() { var pos = new Position { x = 0.0f, y = 0.0f }; var tex = Starburst.inst().get_content <Texture2D>("particle"); return(new Component[] { //new Light_Source { color = Color.Blue, intensity = 0.1f, size = 2.0f }, pos, new Particle_Emitter() { emit_fn = () => { var theta1 = 2.0f * 3.1415f * (float)rand.NextDouble(); var theta2 = 2.0f * 3.1415f * (float)rand.NextDouble(); var radius = 13.0f * (float)rand.NextDouble(); var speed = 50.0f * (float)(rand.NextDouble() + 0.05); return new Component[] { new Sprite { blend_mode = Sprite.BM_ADD, color = new Color(0.05f, 0.05f, 1.0f, 0.7f), layer_depth = 0.3f, scale = 2.5f, texture = tex }, new Position { x = pos.x + (float)Math.Cos(theta1) * radius, y = pos.y + (float)Math.Sin(theta1) * radius }, new Velocity { x = (float)Math.Cos(theta2) * speed, y = (float)Math.Sin(theta2) * speed }, new TTL { alpha_fn = (x, max) => 1.0f - (x * x) / (max * max), max_time = 0.35f + (float)(rand.NextDouble() * 0.7f) } }; }, interval = 0.05f, num_particles_per_emit = 1 } }); }
private Component[] nanobot() { var light_source = new Light_Source { lightcone = false, size = 0.5f, color = new Color(0.5f, 0.6f, 1.0f) }; return(new Component[] { light_source, new Sprite { texture = Starburst.inst().get_content <Texture2D>("nanobot") }, new Mass { mass = 10.0f, drag_coeff = 3.4f, restitution_coeff = 1.0f, friction = 0.0f }, new Bounding_Circle { radius = 7.0f }, new Position { }, new Velocity { }, new Brain { time_since_think = (float)rand.NextDouble() * 0.33f, think_interval = 1.0f / 3.0f, think_fn = (self) => { if ((int)self.get_component <Data>().get_data("state", 0) == 0) { self.get_component <Light_Source>().color = new Color(1.0f, 0.7f, 0.7f); self.get_component <Data>().data["state"] = 1; } else { self.get_component <Light_Source>().color = new Color(0.5f, 0.6f, 1.0f); self.get_component <Data>().data["state"] = 0; } } }, new TTL { max_time = 7.0f + 7.0f * (float)rand.NextDouble() }, new Data { } }); }
private void bullet1_player(Entity a, Entity b, dynamic data) { var bullet = (a.get_component <Sprite>().texture.Name == "beams1") ? a : b; var player = (bullet == a) ? b : a; state.create_entity(new Component[] { new TTL { max_time = 0.05f }, new Particle_Emitter { emit_fn = () => { return(new Component[] { new Position { x = data.c_x, y = data.c_y }, new Velocity { x = (float)Math.Cos((float)rand.NextDouble() * 6.28) * (100.0f + 80.0f * (float)rand.NextDouble()), y = (float)Math.Sin((float)rand.NextDouble() * 6.28) * (100.0f + 80.0f * (float)rand.NextDouble()) }, new Sprite { blend_mode = Sprite.BM_ADD, color = new Color(0.2f, 0.6f, 1.0f), layer_depth = 0.3f, scale = 0.2f + (float)rand.NextDouble() * 0.3f, texture = Starburst.inst().get_content <Texture2D>("particle") }, new TTL { alpha_fn = (x, max) => 1.0f - x / max, max_time = 0.1f + (float)(rand.NextDouble() * 0.1f) } }); }, interval = 0.01f, num_particles_per_emit = 10 + rand.Next(0, 20) } }); bullet.destroy(); inflictBulletDamage(bullet, player, data); }
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; } }
private void tryMoveDown(Entity entity) { var position = entity.get_component <Position>(); // loopa igenom spelare för att hitta om någon ledig x-koordinat finns var players = Starburst.inst().get_entities_fast(typeof(Input)); // prova de olika spelarpositionerna bool moved = false; bool all_up = true; for (int x = 0; x < 4; x++) { if (playerSlots[x] != SlotStatus.Empty) { all_up = false; break; } } for (int x = 0; x < 4; x++) { if (playerSlots[x] == SlotStatus.Empty) { moved = true; position.y++; position.x = x; playerSlots[x] = SlotStatus.Hovering; Starburst.inst().message("play_sound_asset", new { name = "menu_click" }); if (all_up) { elapsedTime = 0.5f; } break; } } if (!moved) { Starburst.inst().message("play_sound_asset", new { name = "menu_negative" }); } }