internal void LoadLasers(uint x, uint y, uint width, uint height, Block current, ContentManager Content, Block[,] grid, LaserbeamManager laserManager, ref int laserIndex ) { switch (current) { case Block.LaserGunRight: { FireLaser(x, y, width, height, Direction4D.Right, grid, Content, laserManager, ref laserIndex); return; } case Block.LaserGunDown: { FireLaser(x, y, width, height, Direction4D.Down, grid, Content, laserManager, ref laserIndex); return; } case Block.LaserGunLeft: { FireLaser(x, y, width, height, Direction4D.Left, grid, Content, laserManager, ref laserIndex); return; } case Block.LaserGunUp: { FireLaser(x, y, width, height, Direction4D.Up, grid, Content, laserManager, ref laserIndex); return; } } }
internal void FireLaser (uint x, uint y, uint width, uint height, Direction4D direction, Block[,] grid, ContentManager Content, LaserbeamManager laserManager, ref int laserIndex) { SilverBotMirrorPosition[] mirrorPositions = new SilverBotMirrorPosition[0]; if (silverBot != null) mirrorPositions = GetSilverBotPositions(new Vector2(silverBot.gridPos.X, silverBot.gridPos.Y)); Laserbeam current = laserManager.GetBeam(laserIndex); current.SetStartDirection(direction); Vector2 currentPosition = new Vector2(x, y) + direction.ToVector2(); while(true) { if (currentPosition.X == -1 || currentPosition.Y == -1) break; if (currentPosition.X == width) break; if (currentPosition.Y == height) break; foreach (var mirror in mirrorPositions) { if (mirror == currentPosition) { direction = mirror.Mirror(direction.Reverse()); break; } } if(grid[(int)currentPosition.X, (int)currentPosition.Y].LaserPassesThrough()) { current.Add(currentPosition); currentPosition += direction.ToVector2(); } else { break; } } current.SetEndDirection(direction); laserIndex++; }
internal LaserbeamManagerInternal(LaserbeamManager laserBeamManager) { this.laserBeamManager = laserBeamManager; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); laserManager = new LaserbeamManager(Content); textures = new GameTextures(Content); if (Environment.GetCommandLineArgs().Length == 3) { LoadLevel(Environment.GetCommandLineArgs()[1]); outSolution = Environment.GetCommandLineArgs()[2]; outS = new CreateSolution(); } else if (Environment.GetCommandLineArgs().Length == 2) LoadLevel(Environment.GetCommandLineArgs()[1]); else LoadNextLevel(); Font = Content.Load<SpriteFont>("Font"); base.LoadContent(); }
public void LoadLevel (string location) { pushAnims.Clear(); uint StartdozerBotX; uint StartdozerBotY; bool silverBot; uint StartSilverBotX; uint StartSilverBotY; byte[][][] solutions; blocks = FileLoader.ReadFile(File.OpenRead(location), out solutions, out version, out StartdozerBotX, out StartdozerBotY, out silverBot, out StartSilverBotX, out StartSilverBotY); laserManager = new LaserbeamManager(Content); dozerBot = new PlayerAvatar(textures.dozerBot, new Vector2(StartdozerBotX, StartdozerBotY), blocks, laserManager.Internal.beams, this); if (silverBot) this.silverBot = new PlayerAvatar(textures.silverBot, new Vector2(StartSilverBotX, StartSilverBotY), blocks, laserManager.Internal.beams, this, true); else this.silverBot = null; this.solutions = new ReleaseSolution[solutions.Length]; for (int n = 0; n < solutions.Length; n++) { this.solutions[n] = new ReleaseSolution(solutions[n]); } shadowMap = new ShadowMap(Content, blocks); ReloadLasers(); controlled = dozerBot; dozerBot.Arrive += dozerBot_Arrive; }