コード例 #1
0
ファイル: MainScene.cs プロジェクト: edibletoaster/PSM-Game
        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);
        }
コード例 #2
0
        public override void triggerEvent()
        {
            Random rand = new Random();

            int x = rand.Next(maxX);
            int y = rand.Next(maxY);

            if (this.enemyType == Enemy.EnemyType.ENEMY_TYPE_FISH)
            {
                int coinFlip = rand.Next(2);

                FishEnemy enemy;
                if (coinFlip == 0)
                {
                   	enemy = new FishEnemy(new Vector2(0,y),player);
                }
                else
                {
                    enemy = new FishEnemy(new Vector2(maxX,y),player);
                }
                //this.parent.AddChild(enemy.sprite);
            }
        }
コード例 #3
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);
        }