public void OnHit(TileMap collisionMap) { this.textureTile = collisionMap.GetTileFromPoint(TileLayer.Fore, new Point(((int) this.location.X) + 8, ((int) this.location.Y) + 8)); if ((this.state == PrizeBlockState.Hidden) && GameEngine.Game.CanSpawnBlocks()) { if (!GameEngine.Game.GetPlayer().GetCollisionRectangle().IntersectsWith(this.GetCollisionRectangle())) { collisionMap.SetTile(TileLayer.Fore, this.textureTile.X, this.textureTile.Y, GameEngine.Game.CurrentMap.PrizeBlock); this.state = PrizeBlockState.Visible; GameEngine.Framework.PlaySound(SoundEffects.OpenChest); } } else if ((this.state == PrizeBlockState.Visible) && GameEngine.Game.CanBreakBlocks()) { collisionMap.SetTile(TileLayer.Fore, this.textureTile.X, this.textureTile.Y, new Point(0, 0)); this.state = PrizeBlockState.Broken; GameEngine.Framework.PlaySound(SoundEffects.BreakBlock); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.UpLeft); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.UpRight); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.DownLeft); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.DownRight); if (GameEngine.Game.CheckGlobal(this)) { this.empty = true; } if (!this.empty) { this.prize.CreateObject((PointF) new Point(((int) this.location.X) + 8, ((int) this.location.Y) + 8)); if (this.prize.Item != ObjectType.MysteryBlock) { GameEngine.Game.SetGlobal(this, true); } } } }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { this.tilePoint = collisionMap.GetTileFromPointUnchecked(TileLayer.Fore, new Point((int) base.X, (int) base.Y)); if (this.startingTilePoint.X < 0) { this.startingTilePoint.X = this.tilePoint.X; this.startingTilePoint.Y = this.tilePoint.Y; } switch (this.state) { case FallingBlockState.Resting: { GameObject player = GameEngine.Game.GetPlayer(); if ((this.trigger == FallingBlockTrigger.PlayerNear) || collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y + 1).Equals(new Point(0, 0))) { switch (this.trigger) { case FallingBlockTrigger.PlayerNear: if (Math.Abs((float) (player.X - base.X)) < 100f) { this.state = FallingBlockState.Triggered; } break; case FallingBlockTrigger.PlayerOn: if (((player.X >= base.X) && (player.X <= (base.X + 16f))) && (player.GetCollisionRectangle().Bottom == this.GetCollisionRectangle().Top)) { this.state = FallingBlockState.Triggered; } if (player.GetCollisionRectangle().IntersectsWith(this.GetCollisionRectangle())) { this.state = FallingBlockState.Triggered; } break; case FallingBlockTrigger.PlayerHit: if ((player.CurAnimHitType == AnimHitType.Sword) && this.GetCollisionRectangle().IntersectsWith(player.GetShieldSwordRectangle())) { this.state = FallingBlockState.Triggered; } break; } break; } return true; } case FallingBlockState.Triggered: if (this.delay.Update()) { if (this.trigger != FallingBlockTrigger.PlayerNear) { collisionMap.SetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y, new Point(0, 0)); } this.state = FallingBlockState.Falling; this.fallBegin = base.Y; } break; case FallingBlockState.Falling: base.Y += 4f; if (GameEngine.Game.GetPlayer().GetCollisionRectangle().IntersectsWith(this.GetCollisionRectangle())) { GameObject colObject = new GameObject(null, ObjectType.FallingBlock) { AttackDamage = 8 }; GameEngine.Game.GetPlayer().ObjectBehavior.HandleHit(colObject); } if (((base.Y - this.fallBegin) >= 64f) && !collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y).Equals(new Point(0, 0))) { collisionMap.SetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y - 1, new Point(3, 0)); this.state = FallingBlockState.Fallen; return true; } break; } return true; }
private void DropBlock(TileMap collisionMap) { for (Point point = collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y); point.Equals(new Point(0, 0)); point = collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y)) { this.tilePoint.Y++; } collisionMap.SetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y - 1, new Point(3, 0)); }