public static void TanksBulletDraw(BulletEngine bulletEngine) { Console.ForegroundColor = ConsoleColor.Yellow; Console.SetCursorPosition(bulletEngine.X + 1, bulletEngine.Y + 1); Console.Write('*'); Console.ForegroundColor = ConsoleColor.White; }
public void TestBulletNearRightWall() { int[,] map = new int[10, 10]; var bullet = new BulletEngine(1, 1, MoveDirection.Right); map[bullet.Y, bullet.X + 1] = 1; Assert.IsTrue(bullet.BulletNearWall(bullet, map)); }
public void TestBulletNearDownWall() { int[,] map = new int[10, 10]; var bullet = new BulletEngine(1, 1, MoveDirection.Down); map[bullet.Y + 1, bullet.X] = 1; Assert.IsTrue(bullet.BulletNearWall(bullet, map)); }
public void TestOnBulletDraw() { var bullet = new BulletEngine(1, 1, MoveDirection.Up); bullet.BulletDraw += TestBulletMethod; int i = index; bullet.OnBulletDraw(bullet); Assert.IsTrue(i + 1 == index); }
private void Shoot() { GeneralTransform objGeneralTransform = BulletOrigin.TransformToVisual(Application.Current.RootVisual); Bullet bullet = new Bullet(Bullet(), 180 - ProjectoryAngle, objGeneralTransform.Transform(new Point(0, 0)), this.ImpactDamage, ttLive); bullet.Position += BulletProjectory(); if (CollisionTargets != null) { bullet.AddCollisionTargets(CollisionTargets); } BulletEngine.Add <Bullet>(bullet); _bulletLastFired = DateTime.Now; }
public static void InitAndStart() { var enemyTankInitX = Int32.Parse(ConfigurationManager.AppSettings["EnemyTankInitX"]); var enemyTankInitY = Int32.Parse(ConfigurationManager.AppSettings["EnemyTankInitY"]); var minX = Int32.Parse(ConfigurationManager.AppSettings["MinX"]); var maxX = Int32.Parse(ConfigurationManager.AppSettings["MaxX"]); var minY = Int32.Parse(ConfigurationManager.AppSettings["MinY"]); var maxY = Int32.Parse(ConfigurationManager.AppSettings["MaxY"]); var tankInitX = Int32.Parse(ConfigurationManager.AppSettings["TankInitX"]); var tankInitY = Int32.Parse(ConfigurationManager.AppSettings["TankInitY"]); var filePath = ConfigurationManager.AppSettings["FilePath"]; var projectPath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())); const MoveDirection enemyStartDirection = MoveDirection.Left; const MoveDirection startDirection = MoveDirection.Right; var myTank = new TankEngine(); myTank.TankDraw += EventMethods.MyTankDraw; myTank.TankErase += EventMethods.MyTankErase; var enemyTank = new EnemyTankEngine(); enemyTank.EnemyTankDraw += EventMethods.EnemyTankDraw; enemyTank.EnemyTankErase += EventMethods.EnemyTankErase; var bullet = new BulletEngine(); bullet.BulletDraw += EventMethods.TanksBulletDraw; bullet.BulletErase += EventMethods.TanksBulletErase; var map = new MapBase(); map.InitMap += EventMethods.InitGameMap; map.DrawMap += EventMethods.DrawGameMap; map.DrawBorders += EventMethods.DrawGameMapBorders; map.MapPointErase += EventMethods.GameMapPointErase; map.InitMap(out map.GameMap, GetMapArray(string.Concat(projectPath, filePath), maxX, maxY), maxY, maxX); var control = new ControlBase(); control.GetAction += EventMethods.GetAction; var gameEngine = new GameEngineControl(myTank, enemyTank, bullet, control, map, enemyStartDirection, startDirection); gameEngine.GameIsOver += EventMethods.WriteResult; gameEngine.GameProcess(tankInitX, tankInitY, enemyTankInitX, enemyTankInitY, minX, minY, maxY, maxX); }
public HelpScreen() : base(_menu) { Controls.Add(new HelpControlHolder { Name = "Q", Key = Key.Q, KeyName = "Shuffle Weapon Down", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/q.png", GridCol = 0, GridRow = 0 }); Controls.Add(new HelpControlHolder { Name = "W", Key = Key.W, KeyName = "Jump", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/w.png", GridCol = 1, GridRow = 0 }); Controls.Add(new HelpControlHolder { Name = "E", Key = Key.E, KeyName = "Shuffle Weapon Up", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/e.png", GridCol = 2, GridRow = 0 }); Controls.Add(new HelpControlHolder { Name = "A", Key = Key.A, KeyName = "Move to Left", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/a.png", GridCol = 0, GridRow = 1 }); Controls.Add(new HelpControlHolder { Name = "D", Key = Key.D, KeyName = "Move to Right", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/d.png", GridCol = 2, GridRow = 1 }); Controls.Add(new HelpControlHolder { Name = "Left", Key = Key.Left, KeyName = "Aim Weapon to Left", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/left.png", GridCol = 0, GridRow = 3 }); Controls.Add(new HelpControlHolder { Name = "Up", Key = Key.Up, KeyName = "Shuffle Weapon Up", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/up.png", GridCol = 1, GridRow = 2 }); Controls.Add(new HelpControlHolder { Name = "Right", Key = Key.Right, KeyName = "Aim Weapon to Right", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/right.png", GridCol = 2, GridRow = 3 }); Controls.Add(new HelpControlHolder { Name = "Down", Key = Key.Down, KeyName = "Shuffle Weapon Down", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/down.png", GridCol = 1, GridRow = 3 }); Controls.Add(new HelpControlHolder { Name = "Control", Key = Key.Ctrl, KeyName = "Jump", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/control.png", GridCol = 0, GridRow = 4 }); Controls.Add(new HelpControlHolder { Name = "Space", Key = Key.Space, KeyName = "Shoot Weapon", ImgString = @"/ResourceFramework;component/Images/Buttons/Control/space.png", GridCol = 1, GridRow = 4, Width = 350, Height = 100, GridColWidth = 3 }); _bulletEngine = new BulletEngine(new Canvas()); _meer = new ME { Name = "testMEer", Position = new Point(800, 650) }; _meer.WeaponEngine.SetBulletEngine(_bulletEngine); _btnResource = _menu.Resources.MergedDictionaries[0]; _cnvsMe = _menu.FindName("cnvsMe") as Canvas; if (_cnvsMe == null) { throw new NotImplementedException("ME not implemented"); } _cnvsMe.Children.Add(_bulletEngine.Container); _cnvsMe.Children.Add(_meer); _txtKeyName = _menu.FindName("txtKeyName") as TextBlock; if (_txtKeyName == null) { throw new NotImplementedException("txtKeyName not implemented"); } _btnGrid = _menu.FindName("btnGrid") as Grid; if (_btnGrid == null) { throw new NotImplementedException("btnGrid not implemented"); } CreateButtons(); _signPost = _menu.FindName("SignPost") as SignPost; if (_signPost == null) { throw new NotImplementedException("SignPost not implemented"); } _signPost.SignText = "Naar Home"; (_signPost.FindName("canvasSignpost") as Canvas).MouseLeftButtonDown += SignPostMouseLeftButtonDown; Updated += HelpScreenUpdated; Shown += HelpScreenShown; }
public void TestBulletMethod(BulletEngine bullet) { index++; }
public static void TanksBulletErase(BulletEngine bulletEngine) { Console.SetCursorPosition(bulletEngine.X + 1, bulletEngine.Y + 1); Console.Write(' '); }
public override void BulletErase(BulletEngine bulletEngine) { Console.SetCursorPosition(bulletEngine.X + 1, bulletEngine.Y + 1); Console.Write(' '); }