public GamePlayScene()
        {
            this.ScheduleUpdate ();
            _garnishTimer = new Timer();
            _groundTimer = new Timer();
            _waterLevel = 272;
            _groundLevel = 120;
            _random = new Random();
            _garnishDelay = _random.Next(0,5);

            Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f);
            SceneCamera = (Camera2D)Camera;

            SceneCamera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);

            _groundGarnish = new Layer(SceneCamera);
            _mainLayer = new Layer(SceneCamera);
            _playerCreature = new PlayerCreature ();
            _playerCreature.sprite.Position = Camera.CalcBounds ().Center;
            _mainLayer.AddChild (_playerCreature.sprite);

            _backgroundLayer = new Layer(SceneCamera, 0, 0);
            var background = new SpriteTile(new TextureInfo(AssetManager.GetTexture("background_paper")));
            _backgroundLayer.AddChild(background);
            background.Quad.S = background.TextureInfo.TextureSizef;
            background.CenterSprite();
            background.Position = SceneCamera.CalcBounds().Center;

            _water = new SpriteTile(new TextureInfo(AssetManager.GetTexture("water")));
            _water.Quad.S = _water.TextureInfo.TextureSizef;
            _water.CenterSprite();
            _water.Position = SceneCamera.CalcBounds().Center + new Vector2(0, -244);

             _waterTop = new WaterTile(new TextureInfo(AssetManager.GetTexture("waveline")));
            _waterTop.Quad.S = _waterTop.TextureInfo.TextureSizef;
            _waterTop.CenterSprite();
            _waterTop.Position = _water.Position + new Vector2(0 ,_water.TextureInfo.TextureSizef.Y /2 );
            _waterTop.Position = SceneCamera.CalcBounds().Center + new Vector2(0, -244 + _water.TextureInfo.TextureSizef.Y/2f);

            _groundLayer = new Layer(SceneCamera, 1, 1);
            _groundGarnish = new Layer(SceneCamera, 1, 1);

            var texInfo = new TextureInfo(AssetManager.GetTexture ("ground_tile"));
            _ground = new SpriteList(texInfo);
            _sprite = new SpriteTile(texInfo);
            _ground.AddChild(_sprite);
            _sprite.Quad.S = texInfo.TextureSizef;
            _sprite.CenterSprite();
            _sprite.TileIndex2D = new Vector2i(0,0);

            GenerateMap();

            _enemies = new List<Enemy>();
            _bullets = new List<Bullet>();
            /*
            // enemy sprite test code
            var fish0 = new FishEnemy (new Vector2 (30.0f, 30.0f), _playerCreature);
            var fish1 = new FishEnemy (new Vector2 (15.0f, 15.0f), _playerCreature);
            var fish2 = new FishEnemy (new Vector2 (100.0f, 70.0f), _playerCreature);

            _enemies.Add (fish0);
            _enemies.Add (fish1);
            _enemies.Add (fish2);
            */
            var dummyFish = new FishEnemy (new Vector2 (-25.0f, -25.0f), _playerCreature);
            dummyFish.sprite.UnscheduleAll();
            _mainLayer.AddChild (FishEnemy.spriteList);

            var dummyBullet = new Bullet(new Vector2(-25.0f,-25.0f));
            dummyBullet.sprite.UnscheduleAll();
            //dummyBullet.sprite.Visible = false;
            _mainLayer.AddChild(Bullet.spriteList);

            _waterLayer = new Layer(SceneCamera);
            _waterLayer.AddChild(_water);
            _waterLayer.AddChild(_waterTop);

            _musicPlayer = AssetManager.GetBGM("gameplaymusic").CreatePlayer();
            _musicPlayer.Loop = true;
            _musicPlayer.Play();

            AddChild (_backgroundLayer);

            AddChild (_mainLayer);
            AddChild(_groundLayer);
            AddChild(_groundGarnish);
            AddChild(_waterLayer);

            _eventManager = new EventManager(_mainLayer,_playerCreature);
        }
        public override void Update(float dt)
        {
            GamePadData gamePadData = GamePad.GetData (0);
            if (((gamePadData.Buttons & GamePadButtons.Up) != 0)
                && (_playerCreature.sprite.Position.Y < _screenSize.Y - (_playerCreature.spriteSize ().Y)))
            {
                if ((_playerCreature.sprite.Position.Y > _waterLevel)
                    && (_playerCreature.isJumping == false))
                {
                    _playerCreature.isJumping = true;
                }
                else
                {
                _playerCreature.sprite.Position = new Vector2 (_playerCreature.sprite.Position.X,
                                                              _playerCreature.sprite.Position.Y + 8);
                }
            }
            if (((gamePadData.Buttons & GamePadButtons.Down) != 0)
                && (_playerCreature.sprite.Position.Y > _playerCreature.spriteSize ().Y))
            {
                _playerCreature.sprite.Position = new Vector2 (_playerCreature.sprite.Position.X,
                                                              _playerCreature.sprite.Position.Y - 8);
            }
            if (((gamePadData.Buttons & GamePadButtons.Left) != 0)
                && (_playerCreature.sprite.Position.X > _playerCreature.spriteSize().X))
            {
                _playerCreature.sprite.Position = new Vector2 (_playerCreature.sprite.Position.X - 6,
                                                              _playerCreature.sprite.Position.Y);
            }
            if (((gamePadData.Buttons & GamePadButtons.Right) != 0)
                && (_playerCreature.sprite.Position.X < _screenSize.X - (_playerCreature.spriteSize ().X)))
            {
                _playerCreature.sprite.Position = new Vector2 (_playerCreature.sprite.Position.X + 6,
                                                              _playerCreature.sprite.Position.Y);
            }

            if (Bullet.cooldown > 0)
                Bullet.cooldown--;

            if (((gamePadData.Buttons & GamePadButtons.Circle) != 0) && (Bullet.cooldown <= 0))
            {
                System.Console.WriteLine("Pew!");
                Bullet bull = new Bullet(_playerCreature.sprite.Position);
                _bullets.Add(bull);
                Bullet.cooldown += 20;
            }
            /*
            foreach (Enemy enemy in _enemies) {
                enemy.UpdateEnemyState ();
            }
            */
            if(_groundTimer.Milliseconds() > 200)
            {
                _groundTimer.Reset();
                _groundLevel -= 1;
                _groundGarnish.Offset = new Vector2(0, _groundLevel);
            }
            if(_garnishTimer.Seconds() >=  _garnishDelay )
            {
                _garnishDelay = _random.Next (3, 10);
                var garnish = _random.Next(0, 3);
                if(garnish == 0)
                {
                    _sprite = new GarnishTile(new TextureInfo(AssetManager.GetTexture("seaball")));
                } else if(garnish == 1)
                {
                    _sprite = new GarnishTile(new TextureInfo(AssetManager.GetTexture("plant")));
                } else if(garnish == 2)
                {
                    _sprite = new GarnishTile(new TextureInfo(AssetManager.GetTexture("seasponge_red")));
                } else if(garnish == 3)
                {
                    _sprite = new GarnishTile(new TextureInfo(AssetManager.GetTexture("seasponge_yellow")));
                }
                _groundGarnish.AddChild(_sprite);
                _groundGarnish.Offset = new Vector2(0,_groundLevel);
                _sprite.Quad.S = _sprite.TextureInfo.TextureSizef;
                _sprite.Position = new Vector2(SceneCamera.CalcBounds().Point10.X +_sprite.TextureInfo.TextureSizei.X, _groundLayer.Position.Y + _groundLevel + 120);
                _garnishTimer.Reset();
            }

            if(_playerCreature.sprite.Position.Y < _groundLayer.Position.Y + 140 + 64)
            {
                _playerCreature.sprite.Position = new Vector2(_playerCreature.sprite.Position.X, _groundLayer.Position.Y + 140 + 64);
            }
            _waterLayer.Offset = new Vector2(0,_waterLevel);
            _groundLayer.Offset = new Vector2(0, _groundLevel );

            if(_groundLevel < -140 && !_end)
            {
                _end = true;
                _musicPlayer.Dispose();
                Director.Instance.ReplaceScene( new TransitionDirectionalFade( new EndScene() )
                    { Duration = 1.0f, Tween = (x) => Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.PowEaseOut( x, 3.0f )} );
            }

            _playerCreature.Update (dt);
            _backgroundLayer.Update (dt);
            _groundLayer.Update (dt);
            _groundGarnish.Update(dt);
            _waterTop.Update (dt);

            _eventManager.Update();

            base.Update (dt);
        }