public override void begin(Entity holder) { var holder_pos = holder.get_component <Position>(); var holder_vel = holder.get_component <Velocity>(); var holder_angle = holder.get_component <Angle>(); for (int i = 0; i < 20; i++) { var bot = Fab5_Game.inst().create_entity(nanobot()); var pos = bot.get_component <Position>(); var vel = bot.get_component <Velocity>(); var theta = holder_angle.angle + 3.141592f - 0.15f + 0.3f * (float)rand.NextDouble(); var theta2 = holder_angle.angle + 3.141592f - 0.15f + 0.3f * (float)rand.NextDouble(); var theta3 = holder_angle.angle + 3.141592f - 0.5f * 3.141592f + 3.141592f * rand.Next(0, 2); var speed1 = (0.5f + 0.5f * (float)rand.NextDouble()); var speed2 = (0.3f + 1.5f * (float)rand.NextDouble()); pos.x = holder_pos.x + 40.0f * (float)Math.Cos(theta); pos.y = holder_pos.y + 40.0f * (float)Math.Sin(theta); vel.x = holder_vel.x + speed1 * 350.0f * (float)Math.Cos(theta2) + (float)Math.Cos(theta3) * 360.0f * speed2; vel.y = holder_vel.y + speed1 * 350.0f * (float)Math.Sin(theta2) + (float)Math.Sin(theta3) * 360.0f * speed2; } }
public static Entity create(float t, Action cb) { return(Fab5_Game.inst().create_entity(new Component[] { new TTL { destroy_cb = cb, max_time = t } })); }
public override void end() { var e = Fab5_Game.inst().get_entity(effect_id); if (e != null) { e.destroy(); } }
public override void begin(Entity holder) { var weapon = holder.get_component <Primary_Weapon>(); holder_id = holder.id; Bullet_Factory.fire_burst_powerup(holder, weapon); Fab5_Game.inst().message("weapon_fired", new { name = weapon.sound, entity1 = holder, varying_pitch = true }); }
public override void end() { var holder = Fab5_Game.inst().get_entity(holder_id); //if (holder != null) { var v = holder.get_component<Velocity>(); v.ax = 0.0f; v.ay = 0.0f; //} }
private void activate_effect(Entity holder) { var pos = holder.get_component <Position>(); var vel = holder.get_component <Velocity>(); effect_id = Fab5_Game.inst().create_entity(new Component [] { 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 = 10.0f * (float)(0.05f + rand.NextDouble()); Color col = new Color(0.0f, 0.5f, 1.0f, 1.0f); if ((float)rand.NextDouble() < 0.2f) { col = new Color(0.7f, 0.8f, 1.0f, 1.0f); } return(new Component [] { new Mass { drag_coeff = 1.9f }, new Position { x = pos.x + (float)Math.Cos(theta1) * radius, y = pos.y + (float)Math.Sin(theta1) * radius }, new Velocity { x = vel.x * 0.5f + (float)Math.Cos(theta2) * speed, y = vel.y * 0.5f + (float)Math.Sin(theta2) * speed }, new Sprite { blend_mode = Sprite.BM_ADD, color = col, layer_depth = 0.3f, scale = 0.6f + (float)rand.NextDouble() * 0.4f, texture = Fab5_Game.inst().get_content <Texture2D>("particle") }, new TTL { alpha_fn = (x, max) => 1.0f - (x * x) / (max * max), max_time = 0.55f + 1.5f * (float)Math.Pow((rand.NextDouble() * 0.9f), 2.0f) } }); }, interval = 0.02f, num_particles_per_emit = 1 } }).id; }
public override void end() { var e = Fab5_Game.inst().get_entity(effect_id); if (e != null) { e.destroy(); } var holder = Fab5_Game.inst().get_entity(holder_id); var ship_mass = holder.get_component <Mass>(); ship_mass.mass = old_mass; }
public override void end() { var e = Fab5_Game.inst().get_entity(effect_id); if (e != null) { e.destroy(); } var holder = Fab5_Game.inst().get_entity(holder_id); var si = holder.get_component <Ship_Info>(); si.top_energy = old_top_energy; si.recharge_rate = old_recharge_rate; }
public override void end() { var e = Fab5_Game.inst().get_entity(effect_id); if (e != null) { e.destroy(); } var holder = Fab5_Game.inst().get_entity(holder_id); //if (holder != null) { var ship_info = holder.get_component <Ship_Info>(); ship_info.acceleration = old_acc; ship_info.top_velocity = old_vel; //} }
public static Component[] create(Powerup_Impl impl) { Position pos; Velocity vel; Angle ang; var powerup = new Component[] { new Bounding_Circle { radius = 16.0f, ignore_collisions = Bullet_Factory.IG_BULLET }, pos = new Position { x = -1800.0f, y = 1600.0f }, new Sprite { texture = Fab5_Game.inst().get_content <Texture2D>("powerup") }, new Powerup { impl = impl }, vel = new Velocity { x = 0.0f, y = 0.0f }, ang = new Angle { ang_vel = 3.14f * 0.7f, drag = 0.0f }, new Light_Source { color = new Color(0.0f, 1.0f, 0.31f), intensity = 0.5f }, new TTL { max_time = 60.0f }, // auto-respawn lingering powerups new Particle_Emitter { emit_fn = () => { if ((float)rand.NextDouble() > 0.8f) { return(null); } var theta1 = (2.0f / 5.0f) * 3.1415f * (float)rand.Next(0, 6); var theta2 = 2.0f * 3.1415f * (float)rand.NextDouble(); var radius = 10.0f * (float)rand.NextDouble(); var speed = 150.0f * (float)(0.5f + rand.NextDouble()); var color = Color.White; return(new Component [] { new Mass { drag_coeff = 5.9f }, new Position { x = pos.x + (float)Math.Cos(theta1) * radius, y = pos.y + (float)Math.Sin(theta1) * radius }, new Velocity { x = vel.x * 0.5f + (float)Math.Cos(theta2) * speed, y = vel.y * 0.5f + (float)Math.Sin(theta2) * speed }, new Sprite { blend_mode = Sprite.BM_ADD, color = color, layer_depth = 0.3f, scale = 0.4f + (float)rand.NextDouble() * 0.7f, texture = Fab5_Game.inst().get_content <Texture2D>("particle2") }, new TTL { alpha_fn = (x, max) => (1.0f - ((x * x * x) / (max * max * max))), max_time = 0.55f + (float)Math.Pow((rand.NextDouble() * 1.2f), 2.0f) } }); }, interval = 0.3f, num_particles_per_emit = 2 }, }; return(powerup); }