/// <summary> /// Scene constructor. /// </summary> public Scene() { Camera2D default_camera = new Camera2D( Director.Instance.GL, Director.Instance.DrawHelpers ); default_camera.SetViewFromHeightAndCenter( 16.0f, GameEngine2D.Base.Math._00 ); Camera = (ICamera)default_camera; }
public MainScene() { this.ScheduleUpdate (); SceneCamera = (Camera2D)Camera; SceneCamera.SetViewFromHeightAndCenter (_screenSize.Y, _screenSize / 2.0f); //_background = new Layer (SceneCamera, 0.1f, 0.1f); //_main = new Layer (SceneCamera); _main = new Node (); /* _physics = new PhysicsScene(); _physics.InitScene(); */ _playerCreature = new PlayerCreature (); _playerCreature.sprite.Position = Camera.CalcBounds ().Center; // _player.PositionAll = SceneCamera.CalcBounds().Center; /* _block = new PhysicalSpriteUV(new TextureInfo("/Application/assets/floor.png"), _physics); _block.PositionAll = new Vector2(SceneCamera.CalcBounds().Center.X + 10, SceneCamera.CalcBounds().Center.Y - 100); _physics.sceneBodies[_block.BodyIndex].SetBodyStatic(); _physics.restitutionCoeff = 0.9f; _physics.sceneMax = new Vector2(10000, 10000); _physics.sceneMin = new Vector2(-10000, -10000); */ //AddChild (new SpriteUV(new TextureInfo("/Application/king_water_drop.png"))); //_main.AddChild (_player); var background = new SpriteUV (new TextureInfo ("/Application/assets/background.png")); background.Quad.S = background.TextureInfo.TextureSizef; background.CenterSprite (); //_physics.Gravity = new Vector2(0.0f, -98f); background.Position = SceneCamera.CalcBounds ().Center; //_background.AddChild(background); //AddChild(_background); //AddChild(_block); AddChild (_main); _main.AddChild (background); _main.AddChild (_playerCreature.sprite); _enemies = new ArrayList (); // 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); // _main.AddChild (FishEnemy.spriteList); }
public EndScene() { _waitTimer = new Timer(); ScheduleUpdate(); _sceneCamera = (Camera2D)Camera; Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f); _sceneCamera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f); _groundLayer = new Layer(_sceneCamera); Animations = new Dictionary<string, Animation>(); var texInfo = new TextureInfo(AssetManager.GetTexture("catanimation"), new Vector2i(5,1),TRS.Quad0_1); _currentAnimation = new Animation(0, 5, 0.1f, false); _currentAnimation.Play(); _cat = new SpriteTile(texInfo); _cat.TileIndex1D = _currentAnimation.CurrentFrame; _cat.Quad.S = new Vector2(258, 214); _cat.CenterSprite(); _cat.Position = new Vector2(_sceneCamera.CalcBounds().Point00.X, _sceneCamera.CalcBounds().Point00.Y + _cat.TextureInfo.TextureSizef.Y/2 +64 ); var background = new SpriteTile(new TextureInfo(AssetManager.GetTexture("background_paper"))); background.Quad.S = background.TextureInfo.TextureSizef; background.CenterSprite(); background.Position = _sceneCamera.CalcBounds().Center; for(var i = 0; i < 5; i++) { var _sprite = new GroundTile(new TextureInfo(AssetManager.GetTexture("ground_tile"))); _groundLayer.AddChild(_sprite); _sprite.Quad.S = _sprite.TextureInfo.TextureSizef; _sprite.Position = new Vector2(_sceneCamera.CalcBounds().Point00.X + i * _sprite.TextureInfo.TextureSizef.X, _sceneCamera.CalcBounds().Point00.Y - _sprite.TextureInfo.TextureSizef.Y / 2); } _musicPlayer = AssetManager.GetBGM("endscreen").CreatePlayer(); _musicPlayer.Play(); AddChild(background); AddChild (_cat); AddChild (_groundLayer); }
public TitleScene() { ScheduleUpdate(); _nextSequence = false; _sleepTimer = new Timer(); _sceneCamera = (Camera2D)Camera; Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f); _titleBackground = new SpriteTile(new TextureInfo(AssetManager.GetTexture("titlescreen"))); _titleBackground.Quad.S = _titleBackground.TextureInfo.TextureSizef; _titleBackground.CenterSprite(); _sceneCamera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f); var kid = new SpriteTile(new TextureInfo(AssetManager.GetTexture("kid"))); kid.Quad.S = kid.TextureInfo.TextureSizef; kid.CenterSprite(); kid.Position = _sceneCamera.CalcBounds().Center; _musicPlayer = AssetManager.GetBGM("title").CreatePlayer(); _musicPlayer.Play(); _titleBackground.Position = _sceneCamera.CalcBounds().Center; AddChild(kid); AddChild(_titleBackground); }
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); }