示例#1
0
        /// <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;
        }
示例#2
0
        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 StaticBackground()
        {
            var texture = new Texture2D ("/Application/Assets/background/background.jpg", false);
            var textureInfo = new TextureInfo (texture);
            this.RegisterDisposeOnExit (textureInfo);
            var sprite = new SpriteUV (textureInfo);
            sprite.Quad.S = textureInfo.TextureSizef;

            AddChild (sprite);

            Camera = new Camera2D (Director.Instance.GL, Director.Instance.DrawHelpers);
            Camera.SetViewFromViewport ();
        }
示例#4
0
        public GameOverScene()
        {
            var texture = new Texture2D ("/Application/Assets/images/dead_scene.png", false);
            var textureInfo = new TextureInfo (texture);
            RegisterDisposeOnExit (textureInfo);
            var sprite = new SpriteUV (textureInfo);
            sprite.Quad.S = textureInfo.TextureSizef;

            AddChild (sprite);

            Camera = new Camera2D (Director.Instance.GL, Director.Instance.DrawHelpers);
            Camera.SetViewFromViewport ();

            ScheduleUpdate(2);
        }
示例#5
0
        public TitleScene()
        {
            var texture = new Texture2D("Application/Assets/images/title_image.png", false);
            var textureInfo = new TextureInfo(texture);
            this.RegisterDisposeOnExit (textureInfo);
            var sprite = new SpriteUV(){ TextureInfo = textureInfo};
            sprite.Quad.S = textureInfo.TextureSizef;

            Camera = new Camera2D (Director.Instance.GL, Director.Instance.DrawHelpers);
            Camera.SetViewFromViewport ();

            AddChild(sprite);
            ScheduleUpdate(2);

            // for test; fireWall and fireleaf_one become noise. other images are not.
            //generateFireleafSprite();
        }
示例#6
0
        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);
        }
示例#7
0
        public MapTestScene()
        {
            this.ScheduleUpdate ();

            animation = new Animation(0, 3, 0.1f, true);

            _random = new Random();
            //	bgm1 = new Bgm("/Application/assets/music1.mp3");
            //bgm2 = new Bgm("/Application/assets/root.mp3");
            //	player = bgm1.CreatePlayer();
            //player.Play ();
            SceneCamera = (Camera2D)Camera;
            var texInfo = new TextureInfo(AssetManager.GetTexture ("spritesheet"),new Vector2i(2,2), TRS.Quad0_1);
            _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();
            AddChild(_ground);
        }
示例#8
0
        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);
        }
示例#9
0
 /// <summary>
 /// Creates a 3D view that max the screen bounds in pixel size (in plane z=0)
 /// Exactly match the 3D frustum. Eye distance to z=0 plane is calculated based
 /// on current Frustum.FovY value.
 /// </summary>
 public void SetViewFromViewport()
 {
     Camera2D tmp = new Camera2D( GL, m_draw_helpers );
     tmp.SetViewFromViewport();
     SetFromCamera2D( tmp );
 }
示例#10
0
        /// <summary>
        /// Position the camera and set the persective so that it matches
        /// exactly the 2D ortho view (when all sprites are drawn
        /// on the Z=0 plane anyway, which is the default.
        /// </summary>
        public void SetFromCamera2D( Camera2D cam2d )
        {
            Vector2 y = cam2d.Y();
            float eye_distance = y.Length() / FMath.Tan( 0.5f * Frustum.FovY );	// distance to view plane
            Eye = cam2d.Center.Xy0 + eye_distance * Math._001;
            Center = cam2d.Center.Xy0;
            Up = y.Xy0.Normalize();

            m_last_2d_bounds = cam2d.CalcBounds();
        }
示例#11
0
        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);
        }
示例#12
0
 public CameraManager(Camera2D camera)
 {
     this.camera = camera;
 }