public async void ConvertUnitsToEnemies(List <Enemy> enemyList, Form1 form, CreatorOfPictureBox creator, Player thePlayer) { ICollection <Unit> playerCollection = await connection.GetAllPlayersData(); if (playerCollection == null) { return; } if (playerCollection.Count == 0) { return; } Unit tempUnit = playerCollection.Where(player => player.id == thePlayer.id).ToList()[0]; foreach (var item in playerCollection) { if (item.id == thePlayer.id) { thePlayer.message = item.message; break; } } playerCollection = playerCollection.Where(player => player.id != thePlayer.id).ToList(); if (tempUnit.isShooting == 1) { thePlayer.isShooting = 0; } // Surandam dar nesancius zaidejus ir pridedam foreach (Unit p in playerCollection) { if (enemyList.Find(x => x.id == p.id) == null) { Enemy temp = new Enemy(creator, p.id); temp.addToForm(form); enemyList.Add(temp); } else { enemyList.Find(x => x.id == p.id).getMovableObject().Location = new Point((int)p.PosX, (int)p.PosY); enemyList.Find(x => x.id == p.id).shootingType = p.shootingType; enemyList.Find(x => x.id == p.id).isShooting = p.isShooting; enemyList.Find(x => x.id == p.id).facing = p.facing; enemyList.Find(x => x.id == p.id).whoWon = p.whoWon; } } }
public Facade(Form1 playerBoard, Player boardPlayer, CreatorOfPictureBox creator, Timer a, Timer b, Timer c) { state = new StartGame(); gameTimer = a; moveTimer = b; requestTimer = c; coinsController = new CoinsController(); creatorOfPictureBox = creator; this.playerBoard = playerBoard; this.player = boardPlayer; connectionHandler = new ConnectionHandler(boardPlayer); enemyList = new List <Enemy>(); h1 = new YouWon(); h2 = new YouLost(); h1.SetSuccessor(h2); gameAction(); }
public Bullet GetWeaponEnemy(CreatorOfPictureBox creator, int strategy) { if (strategy == 1) { bullet = new Bullet(new Pistol(creator)); return(bullet.ContextInterface()); } if (strategy == 2) { bullet = new Bullet(new Machinegun(creator)); return(bullet.ContextInterface()); } if (strategy == 3) { bullet = new Bullet(new Sniper(creator)); return(bullet.ContextInterface()); } return(null); }
private void SetValues() { creatorOfPictureBox = new CreatorOfPictureBox(); thisPlayer = new Player(creatorOfPictureBox); this.MinimumSize = new Size(Constants.VIEW_SIZE_X, Constants.VIEW_SIZE_Y); this.AutoScrollPosition = thisPlayer.getMovableObject().Location; gameTimer = new Timer { Interval = coinSpawnInterval }; moveTimer = new Timer { Interval = moveInterval }; requestTimer = new Timer { Interval = requestInterval }; formControls = new Facade(this, thisPlayer, creatorOfPictureBox, gameTimer, moveTimer, requestTimer); InitializePlayer(); }
public Bullet GetWeapon(CreatorOfPictureBox creator, Player mainPlayer) { if (Keyboard.IsKeyDown(Key.NumPad1)) { bullet = new Bullet(new Pistol(creator)); mainPlayer.shootingType = 1; return(bullet.ContextInterface()); } if (Keyboard.IsKeyDown(Key.NumPad2)) { bullet = new Bullet(new Machinegun(creator)); mainPlayer.shootingType = 2; return(bullet.ContextInterface()); } if (Keyboard.IsKeyDown(Key.NumPad3)) { bullet = new Bullet(new Sniper(creator)); mainPlayer.shootingType = 3; return(bullet.ContextInterface()); } return(null); }
public Machinegun(CreatorOfPictureBox _creator) : base(_creator) { }
public Sniper(CreatorOfPictureBox _creator) : base(_creator) { }
public Pistol(CreatorOfPictureBox _creator) : base(_creator) { }
public Enemy(CreatorOfPictureBox creator, long id) : base() { this.creator = creator; createPictureBox(); SetId(id); }
public ShootAlgorithm(CreatorOfPictureBox _creator) { creator = _creator; }
public Player(CreatorOfPictureBox creator) : base() { facing = "down"; this.creator = creator; createPictureBox(); }