Exemple #1
0
 public Wall(int x, int y, IColor color, IMap map, IMapItems wrappee) : base(wrappee)
 {
     this.x     = x;
     this.y     = y;
     this.color = color;
     this.map   = map;
 }
Exemple #2
0
 public Crate(int x, int y, IColor color, IMap map, IMapItems wrappee, IPowerUp powerUp) : base(wrappee)
 {
     this.x       = x;
     this.y       = y;
     this.color   = color;
     this.map     = map;
     this.powerUp = powerUp;
 }
 public void ConstructCrate(int x, int y, IMap map, IMapItems wrappee)
 {
     CreateCrate();
     SetPosition(x, y);
     AddPowerUp();
     SetColor();
     SetMap(map);
     SetWrappee(wrappee);
 }
 public MapItemDecorator(IMapItems wrappee)
 {
     this.wrappee = wrappee;
 }
Exemple #5
0
 public Wall(IMapItems wrappee) : base(wrappee)
 {
 }
Exemple #6
0
 public Crate(IMapItems wrappee) : base(wrappee)
 {
 }
Exemple #7
0
        //mapItems = new Wall(120, 210, new Blue(), mapAdapter, mapItems);

        //for (int i = 1; i <= 10; i++)
        //{
        //    mapItems = new Wall(i*10, 30, new Blue(), mapAdapter, mapItems);
        //}

        //PowerUpCrateBuildDirector director = new PowerUpCrateBuildDirector();
        //IPowerUpCrateBuilder builder = new QuantityCrateBuilder();
        //director.Construct(builder, 300, 300, mapAdapter, mapItems);
        //mapItems = builder.GetCrate();

        private async Task TryToCreateMap(Form form)
        {
            // MAP
            IMap      mapAdapter = new MapAdapter();
            IMapItems mapItems   = mapAdapter;

            // WALLS LOGIC
            mapItems = new Wall(0, 40, new Blue(), mapAdapter, mapItems);
            mapItems = new Wall(0, 542, new Blue(), mapAdapter, mapItems);
            mapItems = new Wall(0, 0, new Blue(), mapAdapter, mapItems);
            mapItems = new Wall(565, 0, new Blue(), mapAdapter, mapItems);


            PowerUpCrateBuildDirector director = new PowerUpCrateBuildDirector();
            PowerUpCrateBuilder       builder  = new QuantityCrateBuilder();
            PowerUpCrateBuilder       builders = new SpeedCrateBuilder();

            director.Construct(builder, 60, 60, mapAdapter, mapItems);
            mapItems = builder.GetCrate();

            director.Construct(builder, 60, 450, mapAdapter, mapItems);
            mapItems = builder.GetCrate();

            director.Construct(builders, 450, 450, mapAdapter, mapItems);
            mapItems = builders.GetCrate();
            mapItems.AddMapItem();

            Iterator mapIterator = mapAdapter.GetMap().GetIterator();
            int      wallIndex   = 0;

            //mapItems.AddMapItem();
            for (IGameObject gameObject = (IGameObject)mapIterator.First(); !mapIterator.IsDone(); gameObject = (IGameObject)mapIterator.Next())
            {
                if (gameObject is Crate)
                {
                    //IColor c = (Crate)VARIABLE.
                    form.Controls.Add(new PictureBox {
                        Name = "Crate", Location = new Point(gameObject.x, gameObject.y), Size = new Size(25, 25), BackColor = (gameObject as Crate).GetColor().GetColor()
                    });
                    Crate c = (Crate)gameObject;
                    c.Type = c.powerUp.getPowerUpType();
                    HttpResponseMessage response = await client.PostAsJsonAsync(cratesData, c);
                }
                else if (gameObject is Wall)
                {
                    if (wallIndex < 2)
                    {
                        form.Controls.Add(new PictureBox {
                            Name = "Wall", Location = new Point(gameObject.x, gameObject.y), Size = new Size(600, 20), BackColor = Color.DarkSlateBlue
                        });
                    }
                    else
                    {
                        form.Controls.Add(new PictureBox {
                            Name = "Wall", Location = new Point(gameObject.x, gameObject.y), Size = new Size(20, 600), BackColor = Color.DarkSlateBlue
                        });
                    }
                    roomWalls.Add((Wall)gameObject);
                    HttpResponseMessage response = await client.PostAsJsonAsync(wallsData, gameObject);

                    wallIndex++;
                }
            }
        }
 public void Construct(PowerUpCrateBuilder builder, int x, int y, IMap map, IMapItems wrappee)
 {
     builder.ConstructCrate(x, y, map, wrappee);
 }
 public virtual void SetWrappee(IMapItems item)
 {
     crate.wrappee = item;
 }