/// <summary> /// Luo uuden numeroblockin /// </summary> /// <param name="grid">Pelin grid</param> /// <param name="width">Leveys</param> /// <param name="height">Korkeus</param> /// <param name="num">Numeroarvo</param> public OrangeNumberBlock(Grid grid, double width, double height, int num) : base(grid, width, height) { this.Image = Game.LoadImage("o" + num); this.Value = num; this.IsEdible = true; }
/// <summary> /// Luo uuden numeroblockin /// </summary> /// <param name="grid">Pelin grid</param> /// <param name="width">Leveys</param> /// <param name="height">Korkeus</param> /// <param name="num">Numeroarvo</param> public NumberBlock( Grid grid, double width, double height, int num ) : base(grid, width, height, Shape.Rectangle) { this.Image = Game.LoadImage("g" + num); this.Value = num; this.IsEdible = true; // apparently labels can not be put as child objects for GameObjs :( }
/// <summary> /// Luo uuden fysiikkaolion. /// </summary> /// <param name="width">Leveys.</param> /// <param name="height">Korkeus.</param> /// <param name="shape">Muoto.</param> public MovingBlock( Grid grid, double width, double height, Shape shape ) : base(grid, width, height, shape) { this.Acceleration = Grid.CellSize.Y; this.MaxVelocity = Grid.CellSize.Y; this.IsUpdated = true; this.CollisionIgnoreGroup = 2; this.Arrived += MovingBlockArrived; }
/// <summary> /// Luodaan uusi räjähtävä block /// </summary> /// <param name="grid">Pelin grid</param> /// <param name="width">Leveys</param> /// <param name="height">Korkeus</param> public ExplodingBlock(Grid grid, double width, double height) : base(grid, width, height) { this.MaxVelocity = Grid.Size * 0.2; this.Collided -= DroppingBlockCollided; this.Collided += ExplodingDroppingBlockCollided; // stopataan vasta kun törmätään this.StopOnlyWhenColliding = true; }
/// <summary> /// Luo uuden blockin /// </summary> /// <param name="grid">Pelin grid</param> /// <param name="width">Leveys</param> /// <param name="height">Korkeus</param> /// <param name="shape">Muoto</param> public Block( Grid grid, double width, double height, Shape shape ) : base(width, height, shape) { this.Grid = grid; this.CanRotate = false; this.IgnoresExplosions = true; this.IgnoresCollisionResponse = true; this.IgnoresGravity = true; this.CollisionIgnoreGroup = 1; this.MaxVelocity = Grid.Size; this.Arrived += BlockArrived; }
/// <summary> /// Luo uuden pelaajablockin /// </summary> /// <param name="grid">Pelin grid</param> /// <param name="width">Leveys</param> /// <param name="height">Korkeus</param> /// <param name="shape">Muoto<param> public PlayerBlock( Grid grid, double width, double height, Shape shape ) : base(grid, width, height, shape) { this.MaxVelocity = Grid.Size * 1.2; this.CollisionIgnoreGroup = 100; this.Collided += PlayerBlockCollision; this.IsHard = true; this.Color = Color.White; Predicate<Block> isHardAndNotEdible = delegate(Block x) { return x.IsHard && !x.IsEdible; }; limitFactors.Add(isHardAndNotEdible); }
/// <summary> /// Luodaan uusi tippuva block /// </summary> /// <param name="grid">Pelin grid</param> /// <param name="width">Leveys</param> /// <param name="height">Korkeus</param> public DroppingBlock( Grid grid, double width, double height) : base(grid, width, height, Shape.Rectangle) { this.MaxVelocity = Grid.Size * 0.2; this.IsHard = true; this.CollisionIgnoreGroup = 0; this.Collided += DroppingBlockCollided; this.Arrived += DroppingBlockArrived; Predicate<Block> isHardCheck = delegate(Block x) { return x.IsHard; }; Predicate<Block> isNotPlayerCheck = delegate(Block x) { return !(x is PlayerBlock); }; Predicate<Block> isNotExplodingCheck = delegate(Block x) { return !(x is ExplodingBlock); }; Predicate<Block> isNotForceMoveCheck = delegate(Block x) { return !forceMove; }; limitFactors.Add(isHardCheck); limitFactors.Add(isNotPlayerCheck); limitFactors.Add(isNotExplodingCheck); limitFactors.Add(isNotForceMoveCheck); }
/// <summary> /// Olio joka edustaa kenttää /// </summary> /// <param name="grid">Grid</param> /// <param name="defaultSize">Olioiden oletuskoko</param> public MathLevel(Grid grid, double defaultSize) { this.grid = grid; this.defaultSize = defaultSize; }
/// <summary> /// Luo uuden Eval/Exit blockin /// </summary> /// <param name="grid">Pelin grid</param> /// <param name="width">Leveys</param> /// <param name="height">Korkeus</param> public EvalBlock(Grid grid, double width, double height) : base(grid, width, height, Shape.Rectangle) { this.IsSolid = true; this.Color = Color.Orange; }
/// <summary> /// Käy kentän kaikki merkit läpi ja kutsuu <c>SetTileMethod</c>-metodilla annettuja /// aliohjelmia kunkin merkin kohdalla. Palauttaa täytetyn GridLogic-olion. /// </summary> /// <remarks> /// Aliohjelmassa voi esimerkiksi luoda olion ruudun kohdalle. /// </remarks> /// <param name="tileWidth">Yhden ruudun leveys.</param> /// <param name="tileHeight">Yhden ruudun korkeus.</param> /// <returns>Olioilla täytetty GridLogic-olio</returns> public GridLogic Execute(Grid grid) { Game game = Peli.Instance; int width = tiles.GetLength(1); int height = tiles.GetLength(0); GridLogic gridLogic = new GridLogic(grid, width, height); double tileWidth = grid.CellSize.X; double tileHeight = grid.CellSize.Y; // Tehdään kenttä sen kokoiseksi että luodut oliot ladotaan gridiin nätisti // ... ja Grid.SnapToCenter toimii fiksusti // Aina parillinen määrä kertoimena. if (width % 2 == 0) game.Level.Width = width * tileWidth + (2 * tileWidth); else game.Level.Width = (width * tileWidth) + (3 * tileWidth); if (height % 2 == 0) game.Level.Height = height * tileHeight + (2 * tileHeight); else game.Level.Height = (height * tileHeight) + (3 * tileHeight); for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { char symbol = tiles[y, x]; if (legend.ContainsKey(symbol)) { TileMethod f = legend[symbol]; double realX = game.Level.Left + (x * tileWidth) + (tileWidth / 2); double realY = game.Level.Top - (y * tileHeight) - (tileHeight / 2); GameObject o = f(new Vector(realX, realY), tileWidth, tileHeight, args[symbol]); (o as Block).GridLocation = new Vector(x, y); gridLogic.Add(y, x, o); } } } return gridLogic; }
/// <summary> /// Uusi GridLogic olio /// </summary> /// <param name="grid">Grid</param> /// <param name="width">Gridin leveys</param> /// <param name="height">Gridin korkeus</param> public GridLogic(Grid grid, int width, int height) { this.grid = grid; level = new GameObject[height, width]; }