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;
                }
            }
        }
Esempio n. 2
0
 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();
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 public Machinegun(CreatorOfPictureBox _creator) : base(_creator)
 {
 }
Esempio n. 7
0
 public Sniper(CreatorOfPictureBox _creator) : base(_creator)
 {
 }
Esempio n. 8
0
 public Pistol(CreatorOfPictureBox _creator) : base(_creator)
 {
 }
Esempio n. 9
0
 public Enemy(CreatorOfPictureBox creator, long id) : base()
 {
     this.creator = creator;
     createPictureBox();
     SetId(id);
 }
Esempio n. 10
0
 public ShootAlgorithm(CreatorOfPictureBox _creator)
 {
     creator = _creator;
 }
Esempio n. 11
0
 public Player(CreatorOfPictureBox creator) : base()
 {
     facing       = "down";
     this.creator = creator;
     createPictureBox();
 }