コード例 #1
0
ファイル: PrizeBlock.cs プロジェクト: maestun/wonderboy
 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);
             }
         }
     }
 }
コード例 #2
0
ファイル: PrizeBlock.cs プロジェクト: maestun/wonderboy
 public override bool Update(TileMap collisionMap, PointF screenPos, bool force)
 {
     if (this.state != PrizeBlockState.Broken)
     {
         if (this.state == PrizeBlockState.None)
         {
             this.textureTile = collisionMap.GetTileFromPoint(TileLayer.Fore, new Point(((int) this.location.X) + 8, ((int) this.location.Y) + 8));
             if (collisionMap.GetTile(TileLayer.Fore, this.textureTile.X, this.textureTile.Y).Equals(GameEngine.Game.CurrentMap.MagicBlock))
             {
                 this.state = PrizeBlockState.Hidden;
             }
             else
             {
                 this.state = PrizeBlockState.Visible;
             }
         }
         GameObject player = GameEngine.Game.GetPlayer();
         if (player.CurAnimHitType == AnimHitType.Sword)
         {
             if (this.GetCollisionRectangle().IntersectsWith(player.GetShieldSwordRectangle()))
             {
                 this.OnHit(collisionMap);
             }
         }
         else if ((player.Type == ObjectType.Lizard) && (player.YSpeed.CurrentSpeed < 0f))
         {
             float num = player.Y - player.GetCollisionRectangle().Height;
             if (((player.X >= this.location.X) && (player.X <= (this.location.X + 16f))) && ((num < (this.location.Y + 20f)) && (num > (this.location.Y + 8f))))
             {
                 this.OnHit(collisionMap);
             }
         }
     }
     return true;
 }