public SpriteBatch() { var accessor = Properties.Access(); var bufferCapacity = accessor.GetInt("sprite.batch.buffer.capacity"); var indexCapacity = accessor.GetInt("sprite.batch.index.capacity"); buffer = new PrimitiveBuffer(bufferCapacity, indexCapacity); GLUtilities.AllocateBuffers(bufferCapacity, indexCapacity, out bufferId, out indexId, GL_DYNAMIC_DRAW); // These two shaders (owned by the sprite batch) can be completed here (in terms of binding a buffer). // External shaders are bound when first applied. spriteShader = new Shader(bufferId, indexId); spriteShader.Attach(ShaderTypes.Vertex, "Sprite.vert"); spriteShader.Attach(ShaderTypes.Fragment, "Sprite.frag"); spriteShader.AddAttribute <float>(2, GL_FLOAT); spriteShader.AddAttribute <float>(2, GL_FLOAT); spriteShader.AddAttribute <byte>(4, GL_UNSIGNED_BYTE, ShaderAttributeFlags.IsNormalized); spriteShader.Initialize(); primitiveShader = new Shader(bufferId, indexId); primitiveShader.Attach(ShaderTypes.Vertex, "Primitives2D.vert"); primitiveShader.Attach(ShaderTypes.Fragment, "Primitives.frag"); primitiveShader.AddAttribute <float>(2, GL_FLOAT); primitiveShader.AddAttribute <byte>(4, GL_UNSIGNED_BYTE, ShaderAttributeFlags.IsNormalized); primitiveShader.Initialize(); }
public MasterRenderer3D() { // Note that shader attributes aren't set here since custom VAOs are created per renderer. shadowMapShader = new Shader(); shadowMapShader.Attach(ShaderTypes.Vertex, "ShadowMap.vert"); shadowMapShader.Attach(ShaderTypes.Fragment, "ShadowMap.frag"); shadowMapShader.Initialize(); shadowMapShader.Use(); shadowMapShader.SetUniform("image", 0); // These default values are arbitrary, just to make sure something shows up. Light = new GlobalLight(); Light.Direction = vec3.UnitX; Light.Color = Color.White; Light.AmbientIntensity = 0.1f; // TODO: Consider making shadow map size reloadable. var accessor = Properties.Access(); var size = accessor.GetInt("shadow.map.size"); shadowMapTarget = new RenderTarget(size, size, RenderTargetFlags.Depth); modelRenderer = new ModelRenderer(Light); spriteBatch3D = new SpriteBatch3D(Light); skeletonRenderer = new SkeletonRenderer(Light); IsEnabled = true; }
public PlayerController(PlayerCharacter player, PlayerData playerData, PlayerControls controls, ControlSettings settings, AbstractController[] controllers) { this.player = player; this.playerData = playerData; this.controls = controls; this.settings = settings; aerialController = (AerialController)controllers[PlayerCharacter.ControllerIndexes.Air]; groundController = (GroundController)controllers[PlayerCharacter.ControllerIndexes.Ground]; platformController = (PlatformController)controllers[PlayerCharacter.ControllerIndexes.Platform]; wallController = (WallController)controllers[PlayerCharacter.ControllerIndexes.Wall]; ladderController = (LadderController)controllers[PlayerCharacter.ControllerIndexes.Ladder]; // TODO: Make this class reloadable. // Create buffers. var accessor = Properties.Access(); var grab = accessor.GetFloat("player.grab.buffer"); var ascend = accessor.GetFloat("player.ascend.buffer"); // Actual values for requiresHold on each buffer are set when control settings are applied. attackBuffer = new InputBuffer(false, controls.Attack); grabBuffer = new InputBuffer(grab, false, controls.Grab); ascendBuffer = new InputBuffer(ascend, false, controls.Jump); ascendBuffer.RequiredChords = controls.Ascend; settings.ApplyEvent += OnApply; MessageSystem.Subscribe(this, CoreMessageTypes.Input, (messageType, data, dt) => { ProcessInput((FullInputData)data, dt); }); }
public Terminal() { colors = new Color[4]; commands = new Dictionary <string, CommandProcessor>(); font = ContentCache.GetFont("Terminal"); currentLine = new SpriteText(font); lines = new List <SpriteText>(); oldCommands = new List <string>(); charWidth = font.Measure("A").x; storedIndex = -1; var accessor = Properties.Access(this); padding = accessor.GetInt("terminal.padding", this, false); textProcessor = new TextProcessor(); textProcessor.Submit = Submit; AddDefaultCommands(); MessageSystem.Subscribe(this, CoreMessageTypes.ResizeWindow, (messageType, data, dt) => { // The terminal is always resized to fit the window width. Width = ((ivec2)data).x; }); MessageSystem.Subscribe(this, CoreMessageTypes.Keyboard, (messageType, data, dt) => { ProcessKeyboard((KeyboardData)data); }); }
public AerialSwordSwipe(AttackData data, PlayerCharacter parent) : base(data, parent) { // TODO: Make this reloadable. var accessor = Properties.Access(); boost = accessor.GetFloat("player.aerial.swipe.boost"); limit = accessor.GetFloat("player.aerial.swipe.limit"); }
protected MeshRenderer(GlobalLight light, string property) : base(light) { var accessor = Properties.Access(); var bufferCapacity = accessor.GetInt(property + ".buffer.capacity"); var indexCapacity = accessor.GetInt(property + ".index.capacity"); GLUtilities.AllocateBuffers(bufferCapacity, indexCapacity, out bufferId, out indexId, GL_STATIC_DRAW); }
public GameplayLoop(TitleLoop titleLoop = null) : base(LoopTypes.Gameplay) { // TODO: Pull relevant objects from the title loop (likely camera and maybe scene). camera = new Camera3D(); var accessor = Properties.Access(); physicsMaxIterations = accessor.GetInt("physics.max.iterations"); }
static PhysicsConstants() { var accessor = Properties.Access(); // TODO: These should be reloadable (I think). EdgeForgiveness = accessor.GetFloat("edge.forgiveness"); Gravity = accessor.GetFloat("gravity"); StepThreshold = accessor.GetFloat("step.threshold"); WallThreshold = accessor.GetFloat("wall.threshold"); }
public FollowView(Camera3D camera, PlayerCharacter player, ControlSettings settings) : base(camera) { this.player = player; this.settings = settings; player.FollowView = this; Properties.Access(this); MessageSystem.Subscribe(this, CoreMessageTypes.Input, (messageType, data, dt) => { ProcessInput((FullInputData)data); }); }
// For the time being, only the player is capable of traversing walls. public WallController(PlayerCharacter player, SingleTimer wallStickTimer) : base(player) { this.wallStickTimer = wallStickTimer; // TODO: Make this reloadable. var accessor = Properties.Access(); // Simpler (for the time being, anyway) to just load properties here. acceleration = accessor.GetFloat("player.wall.acceleration"); deceleration = accessor.GetFloat("player.wall.deceleration"); maxSpeed = accessor.GetFloat("player.wall.max.speed"); wallGravity = accessor.GetFloat("player.wall.gravity"); wallTerminalSpeed = accessor.GetFloat("player.wall.terminal.speed"); stickForgiveness = accessor.GetFloat("player.wall.stick.forgiveness"); }
public Terminal(Primitive <bool> isPauseToggled) { this.isPauseToggled = isPauseToggled; commands = new SortedDictionary <string, Command>(); autocomplete = new Autocomplete(); font = ContentCache.GetFont("Debug"); currentLine = new SpriteText(font); suggestionText = new SpriteText(font); lines = new List <SpriteText>(); history = new List <string>(); charWidth = font.Measure("A").x; storedIndex = -1; insertBounds = new Bounds2D(charWidth, font.Size); var accessor = Properties.Access(); padding = accessor.GetInt("terminal.padding"); historyLimit = accessor.GetInt("terminal.history.limit"); Height = accessor.GetInt("terminal.default.height"); Anchor = Anchors.Left | Anchors.Top; IsDrawEnabled = false; colors = new Color[5]; textProcessor = new TextProcessor(); textProcessor.RepeatDelay = accessor.GetFloat("terminal.repeat.delay"); textProcessor.RepeatRate = accessor.GetFloat("terminal.repeat.rate"); textProcessor.Submit = Submit; AddDefaultCommands(); MessageSystem.Subscribe(this, (int)CoreMessageTypes.ResizeWindow, data => { // The terminal is always resized to fit the window width. Width = ((ivec2)data).x; }); InputProcessor.Add(this, 10); }
public PlayerCharacter(ControlSettings settings) : base(EntityGroups.Player) { // TODO: Find a better way to retrieve settings. this.settings = settings; controls = new PlayerControls(); playerData = new PlayerData(); state = PlayerStates.Airborne; // TODO: Make this class reloadable. var accessor = Properties.Access(); var coyoteTime = accessor.GetFloat("player.coyote.time"); var coyoteWallTime = accessor.GetFloat("player.coyote.wall.time"); var platformTime = accessor.GetFloat("player.platform.ignore.time"); var wallStickTime = accessor.GetFloat("player.wall.stick.time"); // Flags coyoteFlag = Components.Add(new TimedFlag(coyoteTime)); coyoteFlag.OnExpiration = () => { jumpsRemaining--; }; coyoteWallFlag = Components.Add(new TimedFlag(coyoteWallTime)); coyoteWallFlag.OnExpiration = () => { wallController.Reset(); }; platformFlag = new TimedFlag(platformTime); platformFlag.OnExpiration = () => { platformFlag.Tag = null; }; wallStickTimer = new SingleTimer(time => { UnstickFromWall(); }, wallStickTime); int skillCount = Utilities.EnumCount <PlayerSkills>(); int upgradeCount = Utilities.EnumCount <PlayerUpgrades>(); skillsUnlocked = new bool[skillCount]; upgradesUnlocked = new bool[upgradeCount]; }
public AerialSwordLift(AttackData data, PlayerCharacter parent) : base(data, parent) { // TODO: Make this reloadable. boost = Properties.Access().GetFloat("player.aerial.sword.boost"); }
public PlayerData() { Properties.Access(this); }
static GroundController() { // TODO: Should be removed (and use the constant version instead). EdgeForgiveness = Properties.Access().GetFloat("edge.forgiveness"); }
protected CameraView() { Properties.Access(this); }