public bool GotPushed(Direction4D direction, PlayerAvatar sender)
        {
            Vector2 offset = direction.ToVector2();
            Point position = (gridPos + offset).ToPoint();

            if (isSilverBot)
            {
                if (!IsPositionFree(position))
                    return false;
                if (!IsPositionFree(position + new Point(1,0)))
                    return false;
                if (!IsPositionFree(position + new Point(0,1)))
                    return false;
                if (!IsPositionFree(position + new Point(1,1)))
                    return false;
            }
            else
            {
                if (!IsPositionFree(position))
                    return false;

                if( position.X == game.silverBot.gridPos.X || position.X == game.silverBot.gridPos.X+1 )
                {
                    if( position.Y == game.silverBot.gridPos.Y || position.Y == game.silverBot.gridPos.Y+1 )
                    {
                        //can't push things into silverbot
                        return false;
                    }
                }
            }

            gridPos += offset;
            animTarget = gridPos * 32.0f;
            isPushing = true;
            return true;
        }
 void PlayerAvatar_Arrive(List<Block> blocksOn, PlayerAvatar sender, Vector2 gridPos)
 {
     if (blocksOn.Contains(Block.Exit))
     {
         game.DrawWin(this);
     }
 }
 public void DrawWin (PlayerAvatar player)
 {
     if (outS != null)
     {
         byte[][] array = outS.GetBytes();
         BinaryWriter writer = new BinaryWriter(File.OpenWrite(outSolution));
         writer.WriteArray(array);
         writer.Flush();
         writer.Close();
     }
     if (File.Exists("Levels/" + (currentLevel + 1) +".sbalvl"))
         LoadNextLevel();
     else
     {
         won = true;
     }
 }
 internal void AddPushAnim(Block block, Point destination, PlayerAvatar pusher, Direction4D moveDirection)
 {
     switch(block)
     {
         case Block.Crate:
             pushAnims.Add( new PushAnim(textures.crate, pusher, moveDirection.ToVector2() * widthOfBlock, destination) );
             break;
     }
 }
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            for (int x = 0; x < blocks.GetLength(0); x++)
            {
                for (int y = 0; y < blocks.GetLength(1); y++)
                {
                    if (blocks[x, y] == Block.Ice)
                    {
                        UpdateIce(new Point(x, y));
                    }
                }
            }
            if (current != null)
                if (!current.Update(inputState))
                    inputState.Update();
                else
                    ;
            else
                inputState.Update();

            if (inputState.WasButtonJustPressed(Buttons.Back))
                Exit();
            if (outS != null)
                outS.Add(inputState);

            if (inputState.WasKeyJustPressed(Keys.F10) || inputState.WasButtonJustPressed(Buttons.X))
            {
                if (solutions.Length > 0)
                    current = solutions[0];
                else
                    System.Media.SystemSounds.Asterisk.Play();
                RestartLevel();
            }

            if (controlled == silverBot)
            {
                if (inputState.WasKeyJustPressed(Keys.Escape) || inputState.WasButtonJustPressed(Buttons.B))
                    controlled = dozerBot;
                else
                    dozerBot.Update(inputState.GetPseudoJoystick(inputState.gamePad.ThumbSticks.Left, Keys.Up, Keys.Down, Keys.Left, Keys.Right), false);
            }
            else if (controlled == dozerBot)
            {
                if (silverBot != null)
                    silverBot.Update(inputState.GetPseudoJoystick(inputState.gamePad.ThumbSticks.Left, Keys.Up, Keys.Down, Keys.Left, Keys.Right), false);
            }

            controlled.Update(inputState.GetPseudoJoystick(inputState.gamePad.ThumbSticks.Left, Keys.Up, Keys.Down, Keys.Left, Keys.Right));
            laserManager.Update();

            for (int Idx = 0; Idx < pushAnims.Count; )
            {
                if (pushAnims[Idx].Finished())
                {
                    pushAnims.RemoveAt(Idx);
                }
                else
                {
                    Idx++;
                }
            }
        }
 void dozerBot_Arrive(List<Block> blocks, PlayerAvatar sender, Vector2 gridPos)
 {
     if (blocks.Contains(Block.Panel))
     {
         controlled = silverBot;
     }
 }
 public void LoadLevel (string location)
 {
     pushAnims.Clear();
     uint StartdozerBotX;
     uint StartdozerBotY;
     bool silverBot;
     uint StartSilverBotX;
     uint StartSilverBotY;
     byte[][][] solutions;
     blocks = FileLoader.ReadFile(File.OpenRead(location), out solutions, out version, out StartdozerBotX, out StartdozerBotY, out silverBot, out StartSilverBotX, out StartSilverBotY);
     laserManager =
         new LaserbeamManager(Content);
     dozerBot = new PlayerAvatar(textures.dozerBot, new Vector2(StartdozerBotX, StartdozerBotY), blocks, laserManager.Internal.beams, this);
     if (silverBot)
         this.silverBot = new PlayerAvatar(textures.silverBot, new Vector2(StartSilverBotX, StartSilverBotY), blocks, laserManager.Internal.beams, this, true);
     else
         this.silverBot = null;
     this.solutions = new ReleaseSolution[solutions.Length];
     for (int n = 0; n < solutions.Length; n++)
     {
         this.solutions[n] = new ReleaseSolution(solutions[n]);
     }
     shadowMap = new ShadowMap(Content, blocks);
     ReloadLasers(); 
     controlled = dozerBot;
     dozerBot.Arrive += dozerBot_Arrive;
 }