public void LoadContent(Game1 game) { State = Constants.Scene.SCENE_STATE.LOADING; gameObjectManager.LoadContent(game); ParticlesProcessor.LoadContent(game); AudioProcessor.LoadContentAndPlay(game); UIProcessor.LoadContent(game); }
public void Update(float delta) { State = Constants.Scene.SCENE_STATE.RUNNING; gameObjectManager.Update(delta); Camera.Update(gameObjectManager.unit); ParticlesProcessor.Update(); UIProcessor.Update(delta); }
public void Draw(Game1 game) { var spriteBatch = game.spriteBatch; game.GraphicsDevice.SetRenderTarget(game.nativeRenderTarget); game.GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(SpriteSortMode.FrontToBack, samplerState: SamplerState.PointClamp); gameObjectManager.Draw(spriteBatch); ParticlesProcessor.Draw(spriteBatch); spriteBatch.End(); game.GraphicsDevice.SetRenderTarget(null); spriteBatch.Begin(samplerState: SamplerState.PointClamp); spriteBatch.Draw(game.nativeRenderTarget, new Rectangle(0, 0, Constants.DEFAULT_ZOOMING_MODIFIER * Constants.RESOLUTION_WIDTH, Constants.DEFAULT_ZOOMING_MODIFIER * Constants.RESOLUTION_HEIGHT), Color.White); UIProcessor.Draw(spriteBatch, gameObjectManager.unit); spriteBatch.End(); }
private bool Attack(GameObject unit, GameObject objective) { if (unit.StatsComponent.Clock > unit.StatsComponent.HitIntervalLastTicks + Constants.Unit.DEFAULT_UNIT_HIT_INTERVAL - unit.StatsComponent.IntervalModifier) { var targetPosition = unit.PhysicsComponent.position; switch (unit.PhysicsComponent.FacingDirection) { case FacingDirections.UP: targetPosition -= new Vector2(0, Constants.TILESIZE); break; case FacingDirections.DOWN: targetPosition += new Vector2(0, Constants.TILESIZE); break; case FacingDirections.LEFT: targetPosition -= new Vector2(Constants.TILESIZE, 0); break; case FacingDirections.RIGHT: targetPosition += new Vector2(Constants.TILESIZE, 0); break; } if (objective != null && StatsProcessor.CheckIfAlive(objective.StatsComponent) && PhysicsProcessor.GetDistanceFromUnit(unit.PhysicsComponent, objective.PhysicsComponent) <= 1) { AudioProcessor.PlaySoundEffect(Constants.SoundEffects.FXSounds.HIT); unit.StatsComponent.HitIntervalLastTicks = unit.StatsComponent.Clock; StatsProcessor.TakeDamage(objective.StatsComponent, unit.StatsComponent.Damage); ParticlesProcessor.NewParticleStreamAt(Constants.Particles.DEFAULT_ATTACK_PARTICLES_AMMOUNT, objective.PhysicsComponent.position, Constants.Particles.ParticlesStyle.ATTACK); UIProcessor.SetFloatingText(Constants.UI.DEFAULT_FLOATING_TEXT_DURATION, "-" + unit.StatsComponent.Damage, objective.PhysicsComponent.position, Color.Red); if (!StatsProcessor.CheckIfAlive(objective.StatsComponent)) { StatsProcessor.GainExperience(unit, objective.StatsComponent.ExperienceReward); } } } return(false); }