protected override void Draw(AppTime time) { // update instance data // NOTE: this is called here instead of in `Update` because buffers can only be updated once per frame _instanceBuffer.Update(_positions.AsMemory().Slice(0, _currentParticleCount)); // begin a frame buffer render pass var pass = BeginDefaultPass(Rgba32F.Black); // describe the binding of the buffers var resourceBindings = default(ResourceBindings); resourceBindings.VertexBuffer() = _vertexBuffer; resourceBindings.VertexBuffer(1) = _instanceBuffer; resourceBindings.IndexBuffer = _indexBuffer; // apply the render pipeline and bindings for the render pass pass.ApplyPipeline(_pipeline); pass.ApplyBindings(ref resourceBindings); // apply the mvp matrix to the vertex shader pass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _modelViewProjectionMatrix); // draw the particles into the target of the render pass pass.DrawElements(24, instanceCount: _currentParticleCount); // end frame buffer render pass pass.End(); }
public static void SeedLogs() { GrowlHelper.SimpleGrowl("Seeding Legacy Logs"); var lines = File.ReadAllLines(Path.Combine(AppPaths.Instance.GetMigrationDataFolder(), "legacy_logs.csv")).Select(a => a.Split(';')); var repo = new LogRepository(); foreach (var l in lines) { var x = new Log(); x.DateCreated = DateTime.Parse(l.First().Split(',')[0].Trimmed()); x.DateModified = AppTime.Now(); x.LogId = l.First().Split(',')[2].Trimmed(); x.Name = l.First().Split(',')[3].Trimmed(); x.UserId = l.First().Split(',')[4].Trimmed(); x.ShortName = l.First().Split(',')[5].Trimmed(); x.WidgetColor = l.First().Split(',')[6].Trimmed(); var existing = repo.FindByLogId(x.LogId); if (!existing.Any()) { repo.Add(x); } } }
public static void Update(AppTime appTime) { lock (mutex) { windows.Where(x => x.IsEnabled).ToList().ForEach(x => x.Update(appTime)); } }
protected override void Draw(AppTime time) { // upload the texture data to the GPU, can only done once per frame per image _texture.Update(_textureData.AsMemory()); // begin a frame buffer render pass var pass = BeginDefaultPass(Rgba32F.Black); // describe the binding of the vertex and index buffer var resourceBindings = default(ResourceBindings); resourceBindings.VertexBuffer() = _vertexBuffer; resourceBindings.IndexBuffer = _indexBuffer; resourceBindings.FragmentStageImage() = _texture; // apply the render pipeline and bindings for the render pass pass.ApplyPipeline(_pipeline); pass.ApplyBindings(ref resourceBindings); // apply the params to the vertex shader pass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _worldProjectionMatrix); // draw the cube into the target of the render pass pass.DrawElements(36); // end the frame buffer render pass pass.End(); }
public CallForSpeech(CallForSpeechNumber number, Speech speech, Speaker speaker, Category cat) : this(number, CallForSpeechStatus.New, speaker, speech, cat, null, new Registration(AppTime.Now()), null, null, new CallForSpeechId(0)) { }
public static string GenerateZipName(int count) { return(count + "-inbox-files-" + AppTime.Now().ToString("MM_dd_yyyy", CultureInfo.InvariantCulture) + "_" + ShortGuid.NewGuid() + ".zip"); }
protected override void Draw(AppTime time) { // begin a frame buffer render pass Rgba32F clearColor = 0x8080FFFF; var pass = BeginDefaultPass(clearColor); // apply the render pipeline for the render pass pass.ApplyPipeline(_pipeline); // apply the bindings necessary to render the triangle for the render pass _resourceBindings.VertexBuffer() = _vertexBuffer; _resourceBindings.VertexBufferOffset() = 0; _resourceBindings.IndexBuffer = _indexBuffer; _resourceBindings.IndexBufferOffset = 0; pass.ApplyBindings(ref _resourceBindings); // draw the triangle (3 triangle indices) into the target of the render pass pass.DrawElements(3); // set and apply the bindings necessary to render the quad for the render pass _resourceBindings.VertexBuffer() = _vertexBuffer; _resourceBindings.VertexBufferOffset() = 3 * Marshal.SizeOf <Vertex>(); _resourceBindings.IndexBuffer = _indexBuffer; _resourceBindings.IndexBufferOffset = 3 * Marshal.SizeOf <ushort>(); pass.ApplyBindings(ref _resourceBindings); // draw the quad (6 triangle indices) into the target of the render pass pass.DrawElements(6); // end the frame buffer render pass pass.End(); }
static void Main(string[] args) { Startup.ConfigureServices(); var appTime = new AppTime { Active = true, Duration = 0, TurnOver = 0 }; var appTimeService = Startup.ServiceProvider.GetService <IAppTimeService>(); appTimeService.AddAppTime(appTime); var appService = Startup.ServiceProvider.GetService <IAppService>(); var action = String.Empty; do { appService.StartApp(action); appTime.TurnOver += 1; appTimeService.UpdateAppTime(appTime); } while (action != "exit"); Startup.DisposeServices(); }
public ErrorModel MapEntity(Error entity) { Guid = entity.Guid; ApplicationName = entity.ApplicationName; Host = entity.Host; Type = entity.Type; Source = entity.Source; Message = entity.Message; User = entity.User; Time = entity.Time; DateCreated = entity.Time.ToFriendly(); RelativeTime = entity.Time.ToRelativeString(AppTime.Now()); StatusCode = entity.StatusCode; Browser = entity.Browser; Detail = entity.Detail; ServerVariables = entity.ServerVariables ?? new Dictionary <string, string>(); QueryString = entity.QueryString ?? new Dictionary <string, string>(); Form = entity.Form ?? new Dictionary <string, string>(); Cookies = entity.Cookies ?? new Dictionary <string, string>(); CustomData = entity.CustomData ?? new Dictionary <string, string>(); Severity = entity.Severity; IsCustom = entity.IsCustom; Url = entity.Url; Method = entity.Method; Log = new LogModel { LogId = entity.LogId }; return(this); }
protected override void Draw(AppTime time) { // begin a frame buffer render pass var pass = BeginDefaultPass(Rgba32F.Black); // describe the binding of the vertex and index buffer var resourceBindings = default(ResourceBindings); resourceBindings.VertexBuffer() = _vertexBuffer; resourceBindings.IndexBuffer = _indexBuffer; resourceBindings.FragmentStageImage() = _texture; // apply the render pipeline and bindings for the render pass pass.ApplyPipeline(_pipeline); pass.ApplyBindings(ref resourceBindings); // apply the params to the vertex shader pass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _vertexStageParams); // draw the cube into the target of the render pass pass.DrawElements(36); // end the frame buffer render pass pass.End(); _frameIndex++; }
protected override void Draw(AppTime time) { // begin a frame buffer render pass var pass = BeginDefaultPass(Rgba32F.Gray); var resourceBindings = default(ResourceBindings); resourceBindings.VertexBuffer() = _vertexBuffer; resourceBindings.VertexBuffer(1) = _vertexBuffer; resourceBindings.VertexBufferOffset(1) = 12 * 6 * sizeof(float); resourceBindings.IndexBuffer = _indexBuffer; // apply the render pipeline and bindings for the render pass pass.ApplyPipeline(_pipeline); pass.ApplyBindings(ref resourceBindings); // apply the mvp matrix to the vertex shader pass.ApplyShaderUniforms(ShaderStageType.VertexStage, ref _modelViewProjectionMatrix); // draw the cube into the target of the render pass pass.DrawElements(36); // end the frame buffer render pass pass.End(); }
public ExecutionStatus TryPreliminaryAccept(Judge decisionBy) { if (Status == CallForSpeechStatus.PreliminaryAcceptedByJudge) { return(ExecutionStatus. LogicError("You already PreliminaryAcceptedByJudge this CallForSpeech")); } if (Status != CallForSpeechStatus.EvaluatedByMachine) { return(ExecutionStatus.LogicError("Cannot accept application that WASNT'T in EvaluatedByMachine")); } if (ScoreResult == null) { return(ExecutionStatus.LogicError("Cannot accept application before scoring")); } if (!decisionBy.CanAccept(this.Category.Id)) { return(ExecutionStatus. LogicError("Judge is from diffrent category. Can't Accept")); } Status = CallForSpeechStatus.PreliminaryAcceptedByJudge; PreliminaryDecision = new Decision(AppTime.Now(), decisionBy); return(ExecutionStatus.LogicOk()); }
protected override void Update(AppTime time) { if (_paused) { return; } var deltaSeconds = time.ElapsedSeconds; // rotate cube and create vertex shader mvp matrix _rotationX += 0.25f * deltaSeconds; _rotationY += 0.5f * deltaSeconds; var rotationMatrixX = Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, _rotationX); var rotationMatrixY = Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, _rotationY); var modelMatrix = rotationMatrixX * rotationMatrixY; _vertexStageParams.MVP = modelMatrix * _viewProjectionMatrix; // calculate texture coordinate offsets (xy = uv, z = texture layer) var offset = _frameIndex * 0.0001f; _vertexStageParams.Offset0 = new Vector3(-offset, offset, 0); _vertexStageParams.Offset1 = new Vector3(offset, -offset, 1); _vertexStageParams.Offset2 = new Vector3(0, 0, 2); // calculate color interpolation weight _vertexStageParams.Weights = new Vector3(1f, 1f, 1f); }
public void Accept(Judge decisionBy) { if (Status == CallForSpeechStatus.AcceptedByJudge) { throw new ApplicationException("You already Accepted this CallForSpeech"); } if (Status == CallForSpeechStatus.Rejected) { throw new ApplicationException("Cannot accept application that is already rejected"); } if (Status != CallForSpeechStatus.PreliminaryAcceptedByJudge) { throw new ApplicationException("Cannot accept application that wasn't PreliminaryAccepted FIRST"); } if (ScoreResult == null) { throw new ApplicationException("Cannot accept application before scoring"); } if (!decisionBy.CanAccept(this.Category.Id)) { throw new ApplicationException("Judge is from diffrent category. Can't Accept"); } Status = CallForSpeechStatus.AcceptedByJudge; FinalDecision = new Decision(AppTime.Now(), decisionBy); }
public async Task HandleGraphQLHttpRequestAsync(HttpContext httpContext) { if (httpContext.Request.Path.Value.EndsWith("/schema")) { await HandleSchemaDocRequestAsync(httpContext); return; } var start = AppTime.GetTimestamp(); var gqlHttpReq = await BuildGraphQLHttpRequestAsync(httpContext); var reqCtx = gqlHttpReq.RequestContext; //internal request context try { await Server.ExecuteRequestAsync(gqlHttpReq.RequestContext); } catch (Exception exc) { gqlHttpReq.RequestContext.AddError(exc); } // success, serialize response try { var httpResp = httpContext.Response; httpResp.ContentType = ContentTypeJson; var respJson = SerializeResponse(reqCtx.Response); await httpResp.WriteAsync(respJson, httpContext.RequestAborted); reqCtx.Metrics.HttpRequestDuration = AppTime.GetDuration(start); } catch (Exception ex) { // this ex is at attempt to write response as json; we try to write it as plain text and return something await WriteExceptionsAsTextAsync(httpContext, new[] { ex }); } }
internal void Update(AppTime appTime, Input.InputFrame inputFrame) { for (Int32 i = 0; i < Components.Count; ++i) { Components [i].Poll (appTime, inputFrame); } }
public async Task ExecuteRequestAsync(RequestContext context) { try { // validate if (string.IsNullOrWhiteSpace(context.RawRequest.Query)) { throw new GraphQLException("Query may not be empty."); } Events.OnRequestStarting(context); var handler = new RequestHandler(this, context); await handler.ExecuteAsync(); } catch (AbortRequestException) { return; // error already added to response } catch (InvalidInputException inpEx) { context.AddInputError(inpEx); } catch (Exception ex) { context.AddError(ex); } finally { context.Metrics.Duration = AppTime.GetDuration(context.StartTimestamp); if (context.Failed) { Events.OnRequestError(context); } Events.OnRequestCompleted(context); } }
public async Task <ExecutionStatus> Run(CallForSpeechId id, JudgeId judge, CallForSpeechStatus status) { using var connection = new SqliteConnection(_geekLemonContext.ConnectionString); var q = @"UPDATE CallForSpeakes SET FinalDecision_DecisionBy = @JudgeId, FinalDecision_Date = @Date, Status = @Status WHERE Id = @Id;"; try { var result = await connection.ExecuteAsync(q, new { @JudgeId = judge.Value, @Date = AppTime.Now().ToLongDateString(), @Id = id.Value, @Status = (int)status }); return(ExecutionStatus.DbOk()); } catch (Exception ex) { if (ExecutionFlow.Options.ThrowExceptions) { throw; } return(ExecutionStatus.DbError(ex)); } }
public static DateTime AdjustUploadDate(this DateTime uploadDate) { if (uploadDate > AppTime.Now()) { uploadDate = AppTime.Now(); } return(uploadDate); }
protected override void Draw(AppTime time) { // begin a frame buffer render pass var pass = BeginDefaultPass(_clearColor); // end the frame buffer render pass pass.End(); }
void log(Guid?conversationId, object message, Exception ex = null) { this.LogInfo($"${conversationId} - {AppTime.Now()} - {message.GetType().FullName} - {JsonConvert.SerializeObject(message)}"); if (ex != null) { this.LogException(ex); } }
internal override void Poll(AppTime time, Input.InputFrame inputFrame) { touches.ClearBuffer (); foreach (var rawTouch in inputFrame.ActiveTouches) { touches.RegisterTouch ( rawTouch.Id, rawTouch.Position, rawTouch.Phase, time.FrameNumber, time.Elapsed); } }
protected override void Init() { EnumeratorManager.Init(); DownloadManager.Init(); UIManager.Init(); InputManager.Init(); TouchManager.Init(); AppTime.Init(); }
public override void OnUpdate(AppTime time) { _timer += time.Delta; Single displacement = _speed * _timer; Quaternion rot; Quaternion.CreateFromAxisAngle(ref _vec, ref displacement, out rot); this.Parent.Transform.LocalRotation = rot; }
public static void Start(AppTime appTime) { // Part 1: set up the timer for 2 seconds. var timer = new Timer(2000); // To add the elapsed event handler: // ... Type "_timer.Elapsed += " and press tab twice. timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); timer.Enabled = true; _timer = timer; }
public override Scene Update(AppTime time) { if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Escape) || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Backspace)) { return new Scene_MainMenu(); } return this; }
public override void Update(AppTime appTime) { if (CursorAnimation) { cursorAnimationTimer -= appTime.Elapsed; if (cursorAnimationTimer <= 0) { cursorAnimationState = !cursorAnimationState; cursorAnimationTimer = cursorAnimationState ? cursorVisibleTimer : cursorHiddenTimer; } } }
protected override void Update(AppTime time) { if (_paused) { return; } // emit new particles for (var i = 0; i < _particlesCountEmittedPerFrame; i++) { if (_currentParticleCount < _maxParticlesCount) { _positions[_currentParticleCount] = Vector3.Zero; _velocities[_currentParticleCount] = new Vector3( ((float)(_random.Next() & 0x7FFF) / 0x7FFF) - 0.5f, ((float)(_random.Next() & 0x7FFF) / 0x7FFF * 0.5f) + 2.0f, ((float)(_random.Next() & 0x7FFF) / 0x7FFF) - 0.5f); _currentParticleCount++; } else { break; } } // update particle positions var elapsedSeconds = (float)time.ElapsedTime.TotalSeconds; for (var i = 0; i < _currentParticleCount; i++) { _velocities[i].Y -= 1.0f * elapsedSeconds; _positions[i].X += _velocities[i].X * elapsedSeconds; _positions[i].Y += _velocities[i].Y * elapsedSeconds; _positions[i].Z += _velocities[i].Z * elapsedSeconds; // ReSharper disable once InvertIf if (_positions[i].Y < -2.0f) { _positions[i].Y = -1.8f; _velocities[i].Y = -_velocities[i].Y; _velocities[i].X *= 0.8f; _velocities[i].Y *= 0.8f; _velocities[i].Z *= 0.8f; } } // rotate each particle at the same time and create vertex shader mvp matrix _rotationY += 1.0f * 0.020f; var rotationMatrixY = Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, _rotationY); var modelMatrix = rotationMatrixY; _modelViewProjectionMatrix = modelMatrix * _viewProjectionMatrix; }
public override void Draw(IGraphics graphics, AppTime appTime) { var size = new Size(Math.Max(this.RenderText.Length, this.Size.Width), this.Size.Height); if (DropShadow) { graphics.DrawShadowRect(this.Position.X, this.Position.Y, size.Width + 1, size.Height + 1, this.HasFocus ? Application.ThemeColor : this.BackgroundColor); } else { graphics.DrawRect(this.Position.X, this.Position.Y, size.Width, size.Height, this.HasFocus ? Application.ThemeColor : this.BackgroundColor); } var totWidth = 0; foreach (var op in this.TextRenderOperations) { graphics.DrawString(op.Text, Position.X + (size.Width / 2 - RenderText.Length / 2) + totWidth, Position.Y, this.HasFocus ? ConsoleColor.White : op.ForegroundColor, this.HasFocus ? Application.ThemeColor : this.BackgroundColor); totWidth += op.Text.Length; } //graphics.DrawString( // Text, // Position.X + (size.Width / 2 - RenderText.Length / 2), // Position.Y, // this.HasFocus ? ConsoleColor.White : this.ForegroundColor, // this.HasFocus ? Application.ThemeColor : this.BackgroundColor); if (this.HasFocus) { graphics.SetPixel( AsciiCodes.TriangleRight, Position.X, Position.Y, ConsoleColor.White, Application.ThemeColor); graphics.SetPixel( AsciiCodes.TriangleLeft, Position.X + size.Width - 1, Position.Y, ConsoleColor.White, Application.ThemeColor); } }
public override void Update(AppTime appTime) { if (!Indeterminate) { return; } animationPositionX += (float)(appTime.Elapsed * AnimationSpeed); if (animationPositionX >= this.Size.Width) { animationPositionX = 0; } }
public static Log ToNewEntity(this LogModel m) { var x = new Log { DateCreated = AppTime.Now(), Name = m.Name, LogId = Guid.NewGuid().ToString(), WidgetColor = m.WidgetColor, ShortName = m.Name.GetRandomLetters(2) }; return(x); }
public User ToEntity(UserModel m) { var x = new User(); x.FirstName = m.FirstName; x.LastName = m.LastName; x.Email = m.Email; x.DateCreated = IsNullOrEmpty(m.DateCreated) ? DateTime.UtcNow : DateTime.Parse(m.DateCreated); x.DateModified = AppTime.Now(); x.IsActive = m.IsActive; x.PictureUrl = m.PictureUrl; return(x); }
public override void Draw(IGraphics graphics, AppTime appTime) { if (string.IsNullOrEmpty(this.Text)) { return; } var rows = this.Text.Split('\n'); for (var i = 0; i < rows.Length; i++) { graphics.DrawString(rows[i], this.Position.X, this.Position.Y + i, this.ForegroundColor, this.BackgroundColor); } }
public override void Update(AppTime appTime) { base.Update(appTime); var len = MessageLabel.Text.Length; var newWidth = len + 7; if (this.Size.Width < newWidth) { this.Size = new Size(newWidth, this.Size.Height); } MessageLabel.Position = new Point(this.Size.Width / 2 - len / 2 - 2, MessageLabel.Position.Y); }
public override void OnUpdate(AppTime time) { _timer -= time.Delta; if( _timer < 0f ) { _timer = _colourChangeTime - _timer; _current = _target; _target = RandomGenerator.Default.GetRandomColour(); } Single lerpVal = 1f - _timer; if(lerpVal < 0f) lerpVal = 0f; Rgba32 colToSet = Rgba32.Lerp(_current, _target, lerpVal); _renderer.Material.SetColour("MaterialColour", colToSet); }
internal override void Poll(AppTime appTime, Input.InputFrame inputFrame) { switch (playerIndex) { case PlayerIndex.Two: { A = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_A); B = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_B); Back = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_Back); LeftShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_LeftSholder); LeftStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_LeftThumbstick); RightShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_RightSholder); RightStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_RightThumbstick); Start = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_Start); X = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_X); Y = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_Y); } break; case PlayerIndex.Three: { A = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_A); B = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_B); Back = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_Back); LeftShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_LeftSholder); LeftStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_LeftThumbstick); RightShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_RightSholder); RightStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_RightThumbstick); Start = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_Start); X = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_X); Y = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_Y); } break; case PlayerIndex.Four: { A = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_A); B = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_B); Back = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_Back); LeftShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_LeftSholder); LeftStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_LeftThumbstick); RightShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_RightSholder); RightStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_RightThumbstick); Start = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_Start); X = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_X); Y = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_Y); } break; case PlayerIndex.One: { A = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_A); B = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_B); Back = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_Back); LeftShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_LeftSholder); LeftStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_LeftThumbstick); RightShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_RightSholder); RightStick = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_RightThumbstick); Start = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_Start); X = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_X); Y = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_Y); } break; default: throw new NotSupportedException (); } }
internal void Update(AppTime appTime) { UpdateCurrentInputFrame (); foreach (var hid in this.humanInputDevices) { hid.Update (appTime, inputFrame); } }
public Boolean Update(Platform platform, AppTime time) { if (platform.Input.Keyboard.IsFunctionalKeyDown (FunctionalKey.Escape)) return true; colourChangeProgress += time.Delta / colourChangeTime; if (colourChangeProgress >= 1f) { colourChangeProgress = 0f; currentColour = nextColour; nextColour = RandomColours.GetNext(); } foreach (var element in elements) element.Update (platform, time); return false; }
internal override void Poll(AppTime appTime, Input.InputFrame inputFrame) { switch (gamepad) { case Gamepad.Xbox360: { switch (playerIndex.Value) { case PlayerIndex.One: { Down = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_DPad_Down); Left = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_DPad_Left); Right = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_DPad_Right); Up = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_0_DPad_Up); } break; case PlayerIndex.Two: { Down = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_DPad_Down); Left = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_DPad_Left); Right = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_DPad_Right); Up = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_1_DPad_Up); } break; case PlayerIndex.Three: { Down = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_DPad_Down); Left = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_DPad_Left); Right = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_DPad_Right); Up = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_2_DPad_Up); } break; case PlayerIndex.Four: { Down = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_DPad_Down); Left = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_DPad_Left); Right = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_DPad_Right); Up = GetButtonState (inputFrame, BinaryControlIdentifier.Xbox360_3_DPad_Up); } break; } } break; case Gamepad.PSM: { Down = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_DPad_Down); Left = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_DPad_Left); Right = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_DPad_Right); Up = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_DPad_Up); } break; default: throw new NotSupportedException (); } }
void Update() { if (firstUpdate) { firstUpdate = false; this.timer.Start (); this.userApp.Start (this); } var dt = (Single)(timer.Elapsed.TotalSeconds - previousTimeSpan.TotalSeconds); previousTimeSpan = timer.Elapsed; if (dt > 0.5f) { dt = 0.0f; } elapsedTime += dt; var appTime = new AppTime (dt, elapsedTime, ++frameCounter); this.input.Update (appTime); Boolean userAppToDie = this.userApp.Update (this, appTime); if (userAppToDie) { timer.Stop (); userApp.Stop (this); api.app_Stop (); } VertexBuffer.CollectGpuGarbage (api); IndexBuffer.CollectGpuGarbage (api); Texture.CollectGpuGarbage (api); Shader.CollectGpuGarbage (api); }
internal override void Poll(AppTime time, Input.InputFrame inputFrame) { PressedCharacterKeys.Clear (); PressedFunctionalKeys.Clear (); inputFrame.PressedCharacters.ToList ().ForEach (x => PressedCharacterKeys.Add (x)); foreach (var key in mapping.Keys) { if (inputFrame.BinaryControlStates.Contains (key)) PressedFunctionalKeys.Add (mapping [key]); } }
internal virtual void Poll(AppTime appTime, Input.InputFrame inputFrame) { }
internal override void Poll(AppTime time, Input.InputFrame inputFrame) { Left = GetButtonState (inputFrame, BinaryControlIdentifier.Mouse_Left); Middle = GetButtonState (inputFrame, BinaryControlIdentifier.Mouse_Middle); Right = GetButtonState (inputFrame, BinaryControlIdentifier.Mouse_Right); ScrollWheelValue = GetDigitalState (inputFrame, DigitalControlIdentifier.Mouse_Wheel); X = GetDigitalState (inputFrame, DigitalControlIdentifier.Mouse_X); Y = GetDigitalState (inputFrame, DigitalControlIdentifier.Mouse_Y); }
internal override void Poll(AppTime appTime, Input.InputFrame inputFrame) { Triangle = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_Triangle); Square = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_Square); Circle = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_Circle); Cross = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_Cross); Start = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_Start); Select = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_Select); LeftShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_LeftSholder); RightShoulder = GetButtonState (inputFrame, BinaryControlIdentifier.PlayStationMobile_RightSholder); }
internal override void Poll(AppTime appTime, Input.InputFrame inputFrame) { switch (gamepad) { case Gamepad.Xbox360: { switch (playerIndex.Value) { case PlayerIndex.One: { Left = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_0_Leftstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_0_Leftstick_Y) }; Right = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_0_Rightstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_0_Rightstick_Y) }; } break; case PlayerIndex.Two: { Left = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_1_Leftstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_1_Leftstick_Y) }; Right = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_1_Rightstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_1_Rightstick_Y) }; } break; case PlayerIndex.Three: { Left = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_2_Leftstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_2_Leftstick_Y) }; Right = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_2_Rightstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_2_Rightstick_Y) }; } break; case PlayerIndex.Four: { Left = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_3_Leftstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_3_Leftstick_Y) }; Right = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_3_Rightstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_3_Rightstick_Y) }; } break; } } break; case Gamepad.PSM: { Left = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.PlayStationMobile_Leftstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.PlayStationMobile_Leftstick_Y) }; Right = new Vector2 { X = GetAnalogState (inputFrame, AnalogControlIdentifier.PlayStationMobile_Rightstick_X), Y = GetAnalogState (inputFrame, AnalogControlIdentifier.PlayStationMobile_Rightstick_Y) }; } break; default: throw new NotSupportedException (); } }
public override Scene Update(AppTime time) { this.Engine.DebugRenderer.AddGrid ("Debug"); var menuResult = this.CheckForMenuInput(); this.Engine.PrimitiveRenderer.AddTriple ("Gui", q); if (menuResult != this) return menuResult; for (int i = 0; i < _menuSceneObjects.Count; ++i) { if( i == _selectedIndex ) { _menuSceneObjects[i].Transform.LocalScale = new Vector3(scaleBig, scaleBig, scaleBig); } else { _menuSceneObjects[i].Transform.LocalScale = new Vector3(scaleSmall, scaleSmall, scaleSmall); } } _timer -= time.Delta; if (_timer <= 0f) _timer = 0f; _inputTimer -= time.Delta; if (_inputTimer <= 0f) _inputTimer = 0f; Rgba32 c = Rgba32.Lerp(_startCol, _endCol, (Maths.Sin(time.Elapsed) / 2f) + 0.5f); this.RuntimeConfiguration.ChangeBackgroundColour (c); return this; }
public override void OnUpdate(AppTime time) { Single width = (Single) Scene_Sprites.AppWidth / 2f; Single height = (Single) Scene_Sprites.AppHeight / 2f; this.sprite.Position += this.velocity * time.Delta; if (this.sprite.Position.X > width) { this.velocity.X = -this.velocity.X; this.sprite.Position = new Vector2 (width, this.sprite.Position.Y); } if (this.sprite.Position.X < -width) { this.velocity.X = -this.velocity.X; this.sprite.Position = new Vector2 (-width, this.sprite.Position.Y); } if (this.sprite.Position.Y > height) { this.velocity.Y = -this.velocity.Y; this.sprite.Position = new Vector2 (this.sprite.Position.X, height); } if (this.sprite.Position.Y < -height) { this.velocity.Y = -this.velocity.Y; this.sprite.Position = new Vector2 (this.sprite.Position.X, -height); } this.sprite.Scale += this.deltaScale * time.Delta; if (this.sprite.Scale > 1.2f) { this.deltaScale = -this.deltaScale; this.sprite.Scale = 1.2f; } if (this.sprite.Scale < 0.8f) { this.deltaScale = -this.deltaScale; this.sprite.Scale = 0.8f; } this.sprite.Rotation += this.deltaRotation * time.Delta; }
public override Scene Update(AppTime time) { AppWidth = this.Platform.Status.Width; AppHeight = this.Platform.Status.Height; bgSprite.DrawEx ("Debug", 0f, 0f, 0.0f, 1f / 100f, 1f / 100f); if (timer > 0f) { timer -= time.Delta; } if (timer <= 0f) { if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown (FunctionalKey.Escape) || Platform.Input.Keyboard.IsFunctionalKeyDown (FunctionalKey.Backspace)) { returnScene = new Scene_MainMenu (); } if (Platform.Input.GenericGamepad.Buttons.North == ButtonState.Pressed || Platform.Input.Keyboard.IsCharacterKeyDown ('d')) { debugLinesOn = !debugLinesOn; hares.ForEach (x => x.EnabledDebugRenderer (debugLinesOn)); } if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsCharacterKeyDown ('b')) { hares.ForEach (x => x.NextBlendMode ()); } if (Platform.Input.GenericGamepad.Buttons.South == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown (FunctionalKey.Spacebar)) { ChangeNumHares (); } timer = 0.2f; } if (debugLinesOn) this.Engine.DebugRenderer.AddGrid ("Debug"); if (debugLinesOn) { Single left = -(Single)(AppWidth / 2) * Settings.PixelToWorldSpace; Single right = (Single)(AppWidth / 2) * Settings.PixelToWorldSpace; Single top = (Single)(AppHeight / 2) * Settings.PixelToWorldSpace; Single bottom = -(Single)(AppHeight / 2) * Settings.PixelToWorldSpace; this.Engine.DebugRenderer.AddQuad ( "Default", new Vector3 (left, bottom, 0), new Vector3 (right, bottom, 0), new Vector3 (right, top, 0), new Vector3 (left, top, 0), Rgba32.Yellow); } return returnScene; }
public override Scene Update(AppTime time) { if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Escape) || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Backspace)) { _returnScene = new Scene_MainMenu(); } this.Engine.DebugRenderer.AddGrid ("Debug"); _timer -= time.Delta; if( _timer < 0f ) { _timer = _cameraChangeTime; if( _defaultCamIsCurrent ) { this.RuntimeConfiguration.SetRenderPassCameraTo("Default", _alternateCamera); } else { this.RuntimeConfiguration.SetRenderPassCameraToDefault("Default"); } _defaultCamIsCurrent = !_defaultCamIsCurrent; } return _returnScene; }
public override Scene Update(AppTime time) { this.Engine.DebugRenderer.AddGrid ("Debug", 1f, 10); timer -= time.Delta; if (timer < 0f) { timer = timeWindow; goOut = !goOut; if (goOut) x = !x; } float f = timer / timeWindow; if (goOut) f = 1f - f; f = f * 2f; target.Position = new Vector3 ( x ? f : 0f, 0, x ? 0f : f); this.Engine.DebugRenderer.AddLine ( "Default", target.Position, target.Position + new Vector3 (0f, 10f, 0f), Rgba32.Orange); this.Engine.DebugRenderer.AddLine ( "Default", las.Subject.Position, new Vector3(cam.Transform.Position.X, 0f, cam.Transform.Position.Z), Rgba32.Lime); markerGo.Transform.Position = target.Position + new Vector3 (0f, 0.2f, 0f); if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Escape) || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Backspace)) { returnScene = new Scene_Shapes3(); } return returnScene; }
internal override void Poll(AppTime appTime, Input.InputFrame inputFrame) { switch (gamepad) { case Gamepad.Xbox360: { switch (playerIndex.Value) { case PlayerIndex.One: { Left = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_0_LeftTrigger); Right = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_0_RightTrigger); } break; case PlayerIndex.Two: { Left = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_1_LeftTrigger); Right = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_1_RightTrigger); } break; case PlayerIndex.Three: { Left = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_2_LeftTrigger); Right = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_2_RightTrigger); } break; case PlayerIndex.Four: { Left = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_3_LeftTrigger); Right = GetAnalogState (inputFrame, AnalogControlIdentifier.Xbox360_3_RightTrigger); } break; } } break; default: throw new NotSupportedException (); } }
public override Scene Update(AppTime time) { if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Escape) || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Backspace)) { _returnScene = new Scene_MainMenu(); } this.Engine.DebugRenderer.AddGrid ("Debug"); this.Engine.DebugRenderer.AddLine( "Gui", new Vector3(-0.5f, -0.5f, 0), new Vector3(0.5f, 0.5f, 0), Rgba32.Yellow); return _returnScene; }
public override Scene Update(AppTime time) { this.Engine.DebugRenderer.AddGrid ("Debug", 1f, 10); if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown (FunctionalKey.Escape) || Platform.Input.Keyboard.IsFunctionalKeyDown (FunctionalKey.Backspace)) { returnScene = new Scene_MainMenu (); } return returnScene; }
public override Scene Update(AppTime time) { //this.Engine.PrimitiveRenderer.AddTriple ("Debug", q); //this.Engine.PrimitiveRenderer.AddTriple ("Gui", q); //s.Draw4V ("Gui", // 0.0f, 0.0f, // 0.5f, 0.0f, // 0.0f, 0.5f, // 0.5f, 0.5f); s.DrawEx ("Gui", 0f, 0f, 0.5f, 1f / 256f / 4f, 1f / 256f / 4f); //s.Draw ("Gui", 0f, 0f); ps.Fire (); ps.Draw ("Default"); this.Engine.DebugRenderer.AddGrid ("Debug"); if (Platform.Input.GenericGamepad.Buttons.East == ButtonState.Pressed || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Escape) || Platform.Input.Keyboard.IsFunctionalKeyDown(FunctionalKey.Backspace)) { returnScene = new Scene_MainMenu(); } return returnScene; }