protected override void OnTick(float interval) { if (_enemyEntities.Count < CVars.Get <int>("spawner_max_enemy_count")) { Vector2 spawnPosition = new Vector2(0, 0); do { spawnPosition.X = random.NextSingle(-CVars.Get <float>("screen_width") / 2 * 0.9f, CVars.Get <float>("screen_width") / 2 * 0.9f); spawnPosition.Y = random.NextSingle(-CVars.Get <float>("screen_height") / 2 * 0.9f, CVars.Get <float>("screen_height") / 2 * 0.9f); } while (IsTooCloseToPlayer(spawnPosition)); float facingNearestPlayer = AngleFacingNearestPlayerShip(spawnPosition); ChasingEnemyEntity.Spawn(Engine, ProcessManager, spawnPosition, facingNearestPlayer); } Interval = MathHelper.Max(Interval * CVars.Get <float>("spawner_chasing_enemy_period_multiplier"), CVars.Get <float>("spawner_chasing_enemy_period_min")); }
/// <summary> /// Retrieve a console variable by name - not case sensitive /// </summary> /// <param name="name">The name of the CVar to retrieve</param> /// <returns>null if not found, CVar instance if successful</returns> public static CVar Get(string name) { CVar cvar = CVars.FirstOrDefault(var => var.Name.Equals(name)); if (cvar != default(CVar)) { return(cvar); } if (Native.ConsoleInterop.HasCVar(name)) { CVars.Add(new ExternalCVar(name)); return(CVars.Last()); } return(null); }
/// <summary> /// Attemps to retrieve a CVar. /// </summary> /// <typeparam name="T">The datatype of the CVar.</typeparam> /// <param name="name">The name of the CVar.</param> /// <returns>The CVar, as it's actual datatype.</returns> public static T GetCVar <T>(string name) { if (name == null) { throw new ArgumentNullException("name"); } CVar cvar; if (CVars.TryGetValue(name, out cvar)) { return((T)cvar.value); } else { throw new Exception(String.Format("CVar \"{0}\" does not exist!", name)); } }
public static Entity CreateSpriteOnly(Engine engine, Vector2 position, float angle) { Entity entity = engine.CreateEntity(); entity.AddComponent(new TransformComponent()); entity.AddComponent(new VectorSpriteComponent(new RenderShape[] { new PolyRenderShape(GetOuterPoints(), 0.35f, CVars.Get <Color>("color_laser_enemy"), PolyRenderShape.PolyCapStyle.Filled, true), new PolyRenderShape(new Vector2[] { new Vector2(-3, 3), new Vector2(2, 0), new Vector2(-3, -3) }, 0.2f, CVars.Get <Color>("color_laser_enemy"), PolyRenderShape.PolyCapStyle.Filled) })); entity.GetComponent <VectorSpriteComponent>().RenderGroup = Constants.Render.RENDER_GROUP_GAME_ENTITIES; entity.GetComponent <TransformComponent>().SetPosition(position); entity.GetComponent <TransformComponent>().SetRotation(angle, true); entity.GetComponent <TransformComponent>().SetScale(CVars.Get <float>("laser_enemy_size"), true); entity.AddComponent(new ColoredExplosionComponent(CVars.Get <Color>("color_laser_enemy"))); return(entity); }
internal static CVar Register(CVarAttribute attribute, MemberInfo memberInfo, ref int value) { if (attribute.Name == null) { attribute.Name = memberInfo.Name; } Native.ConsoleInterop.RegisterCVarInt(attribute.Name, ref value, System.Convert.ToInt32(attribute.DefaultValue), attribute.Flags, attribute.Help); CVar.CVars.Add ( memberInfo.MemberType == MemberTypes.Field ? (CVar) new StaticCVarField(attribute, memberInfo as FieldInfo) : new StaticCVarProperty(attribute, memberInfo as PropertyInfo) ); return(CVars.Last()); }
/// <summary> /// Host_WriteConfiguration /// Writes key bindings and archived cvars to config.cfg /// </summary> private void WriteConfiguration( ) { // dedicated servers initialize the host but don't parse and set the // config.cfg cvars if (IsInitialised & !IsDedicated) { var path = Path.Combine(FileSystem.GameDir, "config.cfg"); using (var fs = FileSystem.OpenWrite(path, true)) { if (fs != null) { Keyboard.WriteBindings(fs); CVars.WriteVariables(fs); } } } }
void ProcessGravity(Entity affectedEntity, float dt) { TransformComponent transformComp = affectedEntity.GetComponent <TransformComponent>(); MovementComponent movementComp = affectedEntity.GetComponent <MovementComponent>(); foreach (Entity gravityEntity in _gravityEntities) { if ((transformComp.Position - gravityEntity.GetComponent <TransformComponent>().Position).Length() <= CVars.Get <float>("gravity_hole_enemy_radius")) { Vector2 gravityForceDirection = gravityEntity.GetComponent <TransformComponent>().Position - transformComp.Position; gravityForceDirection.Normalize(); gravityForceDirection *= CVars.Get <float>("gravity_hole_enemy_force") * dt; affectedEntity.GetComponent <MovementComponent>().MovementVector += gravityForceDirection; } } }
void HandleResize(int w, int h) { _bounds.Width = w; _bounds.Height = h; float newAspectRatio = (float)_bounds.Width / _bounds.Height; float desiredAspectRatio = CVars.Get <float>("screen_width") / CVars.Get <float>("screen_height"); if (newAspectRatio <= desiredAspectRatio) // Width is dominant { _compensationZoom = (float)_bounds.Width / CVars.Get <float>("screen_width"); } if (newAspectRatio > desiredAspectRatio) // Height is dominant { _compensationZoom = (float)_bounds.Height / CVars.Get <float>("screen_height"); } CalculateBoundingRect(); }
private void UpdateSuperShieldFromInput(Entity player, float dt) { PlayerComponent play = player.GetComponent <PlayerComponent>(); PlayerShipComponent ship = player.GetComponent <PlayerShipComponent>(); if (play.Player.InputMethod.GetSnapshot().SuperShield == true && ship.SuperShieldAvailable && ship.SuperShieldMeter > 0) { foreach (Entity shield in ship.ShipShields) { //shield.GetComponent<PlayerShieldComponent>().LaserReflectionActive = true; shield.GetComponent <VectorSpriteComponent>().Hidden = false; shield.GetComponent <CollisionComponent>().CollisionMask = (byte)(Constants.Collision.COLLISION_GROUP_ENEMIES | Constants.Collision.COLLISION_GROUP_RAYCAST); shield.GetComponent <CollisionComponent>().CollisionGroup = (byte)(Constants.Collision.COLLISION_GROUP_PLAYER); } ship.SuperShieldMeter = Math.Max(ship.SuperShieldMeter - CVars.Get <float>("player_super_shield_spend_rate") * dt, 0); //Console.WriteLine("Super shield meter at " + ship.SuperShieldMeter); } else { if (ship.SuperShieldMeter <= 0 || play.Player.InputMethod.GetSnapshot().SuperShield == false) { for (int i = 1; i < 4; i++) { //ship.ShipShields[i].GetComponent<PlayerShieldComponent>().LaserReflectionActive = false; ship.ShipShields[i].GetComponent <VectorSpriteComponent>().Hidden = true; ship.ShipShields[i].GetComponent <CollisionComponent>().CollisionMask = Constants.Collision.GROUP_MASK_NONE; ship.ShipShields[i].GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.GROUP_MASK_NONE; //Console.WriteLine("Super Shield collision mask set to NONE"); } } ship.SuperShieldMeter = MathHelper.Min(ship.SuperShieldMeter + CVars.Get <float>("player_super_shield_regen_rate") * dt, CVars.Get <float>("player_super_shield_max")); //Console.WriteLine("Super shield at " + ship.SuperShieldMeter); if (ship.SuperShieldMeter == CVars.Get <float>("player_super_shield_max")) { //Console.WriteLine("Super shield resource replenished"); ship.SuperShieldAvailable = true; } else { ship.SuperShieldAvailable = false; //Console.WriteLine("Player super shield out of resource"); } } }
private void DrawFieldFontEntities(Camera camera, byte groupMask, float dt, float betweenFrameAlpha, Camera debugCamera) { Matrix transformMatrix = debugCamera == null?camera.GetInterpolatedTransformMatrix(betweenFrameAlpha) : debugCamera.GetInterpolatedTransformMatrix(betweenFrameAlpha); if (_fieldFontEntities.Count > 0) { CheckUpdateProjections(); Matrix wvp = transformMatrix * _fieldFontRendererProjection; FieldFontRenderer.Begin(wvp); foreach (Entity entity in _fieldFontEntities) { FieldFontComponent fieldFontComp = entity.GetComponent <FieldFontComponent>(); if (fieldFontComp.Hidden || (fieldFontComp.RenderGroup & groupMask) == 0) { continue; } TransformComponent transformComp = entity.GetComponent <TransformComponent>(); BoundingRect boundRect = new BoundingRect(transformComp.Position.X - (fieldFontComp.Font.MeasureString(fieldFontComp.Content).X *transformComp.Scale / 2), transformComp.Position.Y - (fieldFontComp.Font.MeasureString(fieldFontComp.Content).Y *transformComp.Scale / 2), fieldFontComp.Font.MeasureString(fieldFontComp.Content).X *transformComp.Scale, fieldFontComp.Font.MeasureString(fieldFontComp.Content).Y *transformComp.Scale); if (!boundRect.Intersects(camera.BoundingRect) && CVars.Get <bool>("debug_show_render_culling")) { continue; } Vector2 position; float rotation; float transformScale; transformComp.Interpolate(betweenFrameAlpha, out position, out rotation, out transformScale); FieldFontRenderer.Draw(fieldFontComp.Font, fieldFontComp.Content, position, rotation, fieldFontComp.Color, transformScale, fieldFontComp.EnableKerning); } FieldFontRenderer.End(); } }
public override T Load <T>(string cvarAssetName) { string assetName; try { assetName = CVars.Get <string>(cvarAssetName); } catch (Exception) { throw new Exception(string.Format("Can not load content (CVar does not exist): `${0}`.", cvarAssetName)); } if (Locked && !LoadedAssets.ContainsKey(assetName)) { throw new ContentLockedException(); } return(base.Load <T>(assetName)); }
private void ChangeShieldColor(Entity ship) { switch (ship.GetComponent <PlayerShipComponent>().LifeRemaining) { case 2: foreach (Entity shield in ship.GetComponent <PlayerShipComponent>().ShipShields) { shield.GetComponent <VectorSpriteComponent>().ChangeColor(CVars.Get <Color>("color_player_shield_middle")); } break; case 1: foreach (Entity shield in ship.GetComponent <PlayerShipComponent>().ShipShields) { shield.GetComponent <VectorSpriteComponent>().ChangeColor(CVars.Get <Color>("color_player_shield_low")); } break; } }
private void SpawnEntity() { float zoom = Camera.TotalZoom; Entity entity = _entityCreationFunctions[_random.Next(0, _entityCreationFunctions.Length - 1)].Invoke(Engine); TransformComponent transformComp = entity.GetComponent <TransformComponent>(); transformComp.SetPosition(CVars.Get <float>("entity_background_spawner_x") / zoom, _random.NextSingle(CVars.Get <float>("entity_background_spawner_y_min"), CVars.Get <float>("entity_background_spawner_y_max")), true); transformComp.SetRotation((float)(_random.NextSingle() * Math.PI * 2), true); entity.AddComponent(new MovementComponent(new Vector2(-1, 0), _random.NextSingle(CVars.Get <float>("entity_background_entity_speed_min"), CVars.Get <float>("entity_background_entity_speed_max")))); entity.GetComponent <MovementComponent>().UpdateRotationWithDirection = false; entity.AddComponent(new RotationComponent(_random.NextSingle(CVars.Get <float>("entity_background_entity_angular_speed_min"), CVars.Get <float>("entity_background_entity_angular_speed_max")))); entity.AddComponent(new MenuBackgroundComponent()); }
private void CreateCPUExplosion(Vector2 explosionLocation, Color color) { for (int i = 0; i < CVars.Get <int>("particle_explosion_count"); i++) { float speed = CVars.Get <float>("particle_explosion_strength") * NextRandomSingle(CVars.Get <float>("particle_explosion_variety_min"), CVars.Get <float>("particle_explosion_variety_max")); float dir = NextRandomSingle(0, MathHelper.TwoPi); ref VelocityParticleInfo info = ref _CPUParticleManager.CreateParticle(_particleTexture, explosionLocation.X, -explosionLocation.Y, // For various reasons, ParticleManager is flipped color, float.PositiveInfinity, 1, 0.5f); info.Velocity.X = (float)(speed * Math.Cos(dir)); info.Velocity.Y = (float)(speed * Math.Sin(dir)); info.LengthMultiplier = 1f; }
private void DrawConsole() { if (CVars.Get <bool>("debug_show_console")) { ImGui.SetNextWindowSize(new System.Numerics.Vector2(300, 300), ImGuiCond.FirstUseEver); ImGui.Begin("Developer Console", ref CVars.Get <bool>("debug_show_console")); float footer_height_to_reserve = ImGui.GetStyle().ItemSpacing.Y + ImGui.GetFrameHeightWithSpacing(); ImGui.BeginChild("ConsoleScrollingRegion", new System.Numerics.Vector2(0, -footer_height_to_reserve), false, ImGuiWindowFlags.AlwaysVerticalScrollbar); ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new System.Numerics.Vector2(4, 1)); for (int i = 0; i < _consoleItems.Count; i++) { ImGui.TextUnformatted(_consoleItems[i]); } if (ImGui.GetScrollY() >= ImGui.GetScrollMaxY()) { ImGui.SetScrollHereY(1.0f); } ImGui.PopStyleVar(); ImGui.EndChild(); ImGui.Separator(); if (ImGui.InputText("##ConsoleInput", _consoleCmdLine, (uint)_consoleCmdLine.Length, ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.EnterReturnsTrue)) { string cmd = Encoding.UTF8.GetString(_consoleCmdLine).TrimEnd((Char)0); ExecuteCommand(cmd); for (int i = 0; i < _consoleCmdLine.Length; i++) { _consoleCmdLine[i] = 0; } } ImGui.End(); } }
public static Process CreateLaserEnemyProcessChain(ProcessManager processManager, Engine engine, Entity entity, float waitTime, bool loop) { Process chain = new WaitProcess(waitTime); Process loopProcess = null; if (loop) { loopProcess = new DelegateProcess(() => { processManager.Attach(CreateLaserEnemyProcessChain(processManager, engine, entity, CVars.Get <float>("laser_enemy_successive_wait_period"), true)); }); } chain.SetNext(new LaserEnemyFreezeRotation(engine, entity)) .SetNext(new LaserWarmUpProcess(engine, entity)) .SetNext(new WaitProcess(CVars.Get <float>("laser_enemy_warm_up_duration"))) .SetNext(new LaserShootProcess(engine, entity)) .SetNext(new LaserEnemyUnfreezeRotation(engine, entity)) .SetNext(loopProcess); return(chain); }
internal static CVar Register(CVarAttribute attribute, MemberInfo memberInfo, string value) { if (attribute.Name == null) { attribute.Name = memberInfo.Name; } NativeCVarMethods.RegisterCVarString(attribute.Name, value, (string)attribute.DefaultValue ?? string.Empty, attribute.Flags, attribute.Help); if (memberInfo.MemberType == MemberTypes.Field) { CVars.Add(new StaticCVarField(attribute, memberInfo as FieldInfo)); } else { CVars.Add(new StaticCVarProperty(attribute, memberInfo as PropertyInfo)); } return(CVars.Last()); }
/// <summary> /// Sets or Adds a CVar. /// </summary> /// <typeparam name="T">The datatype of the cvar.</typeparam> /// <param name="name">The cvar's name.</param> /// <param name="value">The cvar's value.</param> public static void SetCVar <T>(string name, T value) { if (name == null) { throw new ArgumentNullException("name"); } if (value == null) { throw new ArgumentNullException("value"); } if (CVars.ContainsKey(name)) { CVars[name] = new CVar(CVars[name].dtype, value); } else { CVars.Add(name, new CVar(typeof(T), value)); } }
static bool TryModVar(string cvar, object val) { if (CVars.ContainsKey(cvar)) { try { SetCVar(cvar, val); return(true); } catch (Exception) { //LogError(e); return(false); } } else { return(false); } }
/// <summary> /// Adds a CVar. /// </summary> /// <typeparam name="T">The datatype of the cvar.</typeparam> /// <param name="name">The cvar's name.</param> /// <param name="value">The cvar's value.</param> public static void AddCVar <T>(string name, T value) { if (name == null) { throw new ArgumentNullException("name"); } if (value == null) { throw new ArgumentNullException("value"); } if (CVars.ContainsKey(name)) { throw new Exception(String.Format("CVar \"{0}\" already exists!", name)); } else { CVars.Add(name, new CVar(typeof(T), value)); } }
internal static CVar Register(CVarAttribute attribute, MemberInfo memberInfo, ref float value) { if (attribute.Name == null) { attribute.Name = memberInfo.Name; } NativeCVarMethods.RegisterCVarFloat(attribute.Name, ref value, System.Convert.ToSingle(attribute.DefaultValue), attribute.Flags, attribute.Help); if (memberInfo.MemberType == MemberTypes.Field) { CVars.Add(new StaticCVarField(attribute, memberInfo as FieldInfo)); } else { CVars.Add(new StaticCVarProperty(attribute, memberInfo as PropertyInfo)); } return(CVars.Last()); }
public static Entity AddBehavior(Entity entity) { entity.AddComponent(new RotationComponent(CVars.Get <float>("chasing_enemy_rotational_speed"))); float angle = entity.GetComponent <TransformComponent>().Rotation; entity.AddComponent(new MovementComponent(new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)), CVars.Get <float>("chasing_enemy_speed"))); entity.AddComponent(new EnemyComponent()); entity.AddComponent(new ChasingEnemyComponent()); entity.AddComponent(new BounceComponent()); entity.AddComponent(new QuadTreeReferenceComponent(new QuadTreeNode(new BoundingRect()))); entity.AddComponent(new CollisionComponent(new PolygonCollisionShape(new Vector2[] { new Vector2(3, 0), new Vector2(-5, 3), new Vector2(-5, -3) }))); entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_ENEMIES; return(entity); }
public static Entity Create(Engine engine, Vector2 position, Color color) { Entity entity = engine.CreateEntity(); entity.AddComponent(new TransformComponent(position)); entity.AddComponent(new MovementComponent()); entity.AddComponent(new PlayerShipComponent(CVars.Get <int>("player_ship_max_health"), CVars.Get <float>("player_super_shield_max"))); entity.AddComponent(new BounceComponent()); entity.AddComponent(new CameraTrackingComponent()); entity.GetComponent <MovementComponent>().UpdateRotationWithDirection = false; entity.AddComponent(new VectorSpriteComponent(new RenderShape[] { new PolyRenderShape(new Vector2[] { new Vector2(3, 0), new Vector2(0, 3), new Vector2(-3, 0), new Vector2(0, -3) }, 0.2f, color, PolyRenderShape.PolyCapStyle.Filled, true), new PolyRenderShape(new Vector2[] { new Vector2(0, 3), new Vector2(-3, -2), new Vector2(-3, 2), new Vector2(0, -3) }, 0.13f, color, PolyRenderShape.PolyCapStyle.Filled) })); entity.GetComponent <VectorSpriteComponent>().RenderGroup = Constants.Render.RENDER_GROUP_GAME_ENTITIES; entity.GetComponent <TransformComponent>().SetScale(CVars.Get <float>("player_ship_size"), true); entity.AddComponent(new ColoredExplosionComponent(color)); entity.AddComponent(new QuadTreeReferenceComponent(new QuadTreeNode(new BoundingRect()))); entity.AddComponent(new CollisionComponent(new PolygonCollisionShape(new Vector2[] { new Vector2(3, 0), new Vector2(0, 3), new Vector2(-3, 2), new Vector2(-3, -2), new Vector2(0, -3) }))); entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_PLAYER; entity.GetComponent <CollisionComponent>().CollisionMask = (byte)(Constants.Collision.GROUP_MASK_ALL); return(entity); }
/// <summary> /// Sets a CVar (infers datatype, slower than SetCVar<T>). /// </summary> /// <param name="name">The cvar's name.</param> /// <param name="value">The cvar's value.</param> static void SetCVar(string name, object value) { if (name == null) { throw new ArgumentNullException("name"); } if (value == null) { throw new ArgumentNullException("value"); } if (CVars.ContainsKey(name)) { CVars[name] = new CVar(CVars[name].dtype, Convert.ChangeType(value, CVars[name].dtype)); } else { throw new Exception( String.Format("CVar \"{0}\" doesnt exist, and cannot be added! (To add, use AddCVar Or SetCVar<T>)", name)); } }
public static Entity Create(Engine engine, Entity shipEntity) { Entity entity = engine.CreateEntity(); entity.AddComponent(new TransformComponent(shipEntity.GetComponent <TransformComponent>().Position)); entity.AddComponent(new SuperShieldComponent(shipEntity)); entity.AddComponent(new VectorSpriteComponent( new RenderShape[] { new QuadRenderShape(new Vector2(3, 0), new Vector2(0, 3), new Vector2(-1.6f, 0), new Vector2(0, -3), shipEntity.GetComponent <ColoredExplosionComponent>().Color) })); entity.GetComponent <VectorSpriteComponent>().RenderGroup = Constants.Render.RENDER_GROUP_NO_GLOW; entity.GetComponent <TransformComponent>().SetScale(CVars.Get <float>("player_ship_size"), true); return(entity); }
private void Draw() { _particleEffect.CurrentTechnique = _particleEffect.Techniques["Draw"]; GraphicsDevice.SetVertexBuffer(_particleDrawVertices); GraphicsDevice.Indices = _particleDrawIndices; GraphicsDevice.BlendState = _particleDrawBlendState; _particleEffect.Parameters["PositionVelocity"].SetValue(_positionVelocityTargets[_currentPositionVelocityTarget]); _particleEffect.Parameters["StaticInfo"].SetValue(_staticInfoTarget); _particleEffect.Parameters["ScaleX"].SetValue(CVars.Get <float>("particle_explosion_scale_x")); _particleEffect.Parameters["ScaleY"].SetValue(CVars.Get <float>("particle_explosion_scale_y")); foreach (EffectPass pass in _particleEffect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, ParticleCount * 2); } }
private void UpdateKeyBindingTextures() { _root.FindWidgetsByClass("primary_keyboard_counter_clockwise_texture").ForEach((Widget widget) => { Image image = widget as Image; if (image != null) { image.Texture = Content.Load <TextureAtlas>("complete_texture_atlas") .GetRegion((_keyTextureMap[(Keys)CVars.Get <int>("input_keyboard_primary_rotate_counter_clockwise")])); } }); _root.FindWidgetsByClass("primary_keyboard_clockwise_texture").ForEach((Widget widget) => { Image image = widget as Image; if (image != null) { image.Texture = Content.Load <TextureAtlas>("complete_texture_atlas") .GetRegion((_keyTextureMap[(Keys)CVars.Get <int>("input_keyboard_primary_rotate_clockwise")])); } }); _root.FindWidgetsByClass("secondary_keyboard_counter_clockwise_texture").ForEach((Widget widget) => { Image image = widget as Image; if (image != null) { image.Texture = Content.Load <TextureAtlas>("complete_texture_atlas") .GetRegion((_keyTextureMap[(Keys)CVars.Get <int>("input_keyboard_secondary_rotate_counter_clockwise")])); } }); _root.FindWidgetsByClass("secondary_keyboard_clockwise_texture").ForEach((Widget widget) => { Image image = widget as Image; if (image != null) { image.Texture = Content.Load <TextureAtlas>("complete_texture_atlas") .GetRegion((_keyTextureMap[(Keys)CVars.Get <int>("input_keyboard_secondary_rotate_clockwise")])); } }); }
void Keyboard_KeyDown(object sender, KeyboardEventArgs e) { // Workaround; when the game is debug paused, the EventManager's // queue isn't dispatched. Because of this, opening/closing // of debug windows isn't possible when the game is debug paused. if (CVars.Get <bool>("debug_pause_game_updates") && (e.Key == Keys.OemTilde || e.Key == Keys.F1 || e.Key == Keys.F2 || e.Key == Keys.F3 || e.Key == Keys.F4 || e.Key == Keys.F5 || e.Key == Keys.F6 || e.Key == Keys.F7)) { EventManager.Instance.TriggerEvent(new KeyboardKeyDownEvent(e.Key)); } else { EventManager.Instance.QueueEvent(new KeyboardKeyDownEvent(e.Key)); } }
private string SetNextResolution() { Console.WriteLine("Set Next Resolution Called"); resolutionIndex = (resolutionIndex == supportedResolutions.Count - 1) ? 0 : resolutionIndex + 1; string returnString = supportedResolutions[resolutionIndex]; string[] splitterList = { "{Width:", " Height:", "Format:" }; string[] resolutionList = returnString.Split(splitterList, StringSplitOptions.RemoveEmptyEntries); foreach (string item in resolutionList) { Console.WriteLine(item); } Int32.TryParse(resolutionList[0], out int width); Int32.TryParse(resolutionList[1], out int height); CVars.Get <int>("display_fullscreen_width") = width; CVars.Get <int>("display_fullscreen_height") = height; return(width + " x " + height); }
private void PlaySound(string cvarName, float eventVolume, float pan, float pitch, SoundType type) { SoundEffect sound = content.Load <SoundEffect>(cvarName); SoundEffectInstance instance = sound.CreateInstance(); float volume = CVars.Get <float>("sound_master_volume") * eventVolume; if (type == SoundType.SoundEffect) { volume *= CVars.Get <float>("sound_effect_volume") / 10; } if (type == SoundType.Music) { volume *= CVars.Get <float>("sound_music_volume") / 10; } instance.Pan = pan; instance.Pitch = pitch; instance.Volume = volume; instance.Play(); _soundEffects.Add(instance); }