Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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));
 }