public Session(Ballz _game, World.World world, MatchSettings settings) { World = world; Terrain = World.StaticGeometry; GameSettings = settings; Physics = new Physics.PhysicsControl(_game); Physics.Enabled = false; _game.Components.Add(Physics); GameRenderer = new Renderer.GameRenderer(_game); GameRenderer.Enabled = false; GameRenderer.Visible = false; _game.Components.Add(GameRenderer); DebugRenderer = new Renderer.DebugRenderer(_game); DebugRenderer.Enabled = false; DebugRenderer.Visible = false; _game.Components.Add(DebugRenderer); SessionLogic = new Logic.GameLogic(_game, this); SessionLogic.Enabled = false; _game.Components.Add(SessionLogic); Logic = _game.Services.GetService <LogicControl>(); Logic.Message += Physics.HandleMessage; Logic.Message += GameRenderer.HandleMessage; Logic.Message += SessionLogic.HandleMessage; Logic.Message += DebugRenderer.HandleMessage; Input = _game.Services.GetService <Input.InputTranslator>(); Game = _game; }
public void Initialize(World world, PhysicsControl physics) { _physics = physics; var particles = new List<Vector2>(); var velocities = new List<Vector2>(); Particles = new Vector2[ParticleCount]; Velocities = new Vector2[ParticleCount]; _velocityBuffer = new Vector2[ParticleCount]; const float initGridSize = 0.4f; for (var x = 0.0f; x < _width; x += initGridSize) for (var y = 0.0f; y < _height; y += initGridSize) { if (!world.StaticGeometry.IsWaterSpawn(x, y)) continue; particles.Add(new Vector2(x, y)); velocities.Add(new Vector2(0,0)); _grid[(int)(particles.Last().X * GridMultiplier), (int)(particles.Last().Y * GridMultiplier)].Add(particles.Count-1); } Particles = particles.ToArray(); Velocities = velocities.ToArray(); _velocityBuffer = Velocities.ToArray(); ParticleCount = particles.Count; _w = new float[ParticleCount, ParticleCount]; }