示例#1
0
        public FishEnemy(Vector2 pos, PlayerCreature player)
        {
            enemyHabitat = Enemy.EnemyHabitat.ENEMY_HABITAT_SEA;
            enemyType = Enemy.EnemyType.ENEMY_TYPE_FISH;
            sprite = new SpriteTile();
            this.player = player;

            if (texInfo == null)
            {
                //texInfo = new TextureInfo ("/Application/assets/stingray_float.png");
                texInfo = new TextureInfo(AssetManager.GetTexture("stingray_float"), new Vector2i(4,1),TRS.Quad0_1);
            }

            if (spriteList == null)
            {
                spriteList = new SpriteList(texInfo);
            }

            spriteList.Position = new Vector2(0.0f,0.0f);
            spriteList.AddChild(sprite);

            Animations = new Dictionary<string, Animation>();
            //texInfo = new TextureInfo(AssetManager.GetTexture("stingray_float"), new Vector2i(4,1),TRS.Quad0_1);
            Animations.Add("idle" , new Animation(0, 3, 0.3f, false));
            CurrentAnimation = Animations["idle"];
            CurrentAnimation.Play();

            sprite.GetContentWorldBounds(ref boundingBox);
            sprite.Quad.S = new Vector2(321, 270);// map 1:1 on screen -- necessary? !!!\
            sprite.CenterSprite();
            sprite.Position = pos;
            sprite.Schedule((dt) => UpdateEnemyState(dt));
        }
示例#2
0
 public EnemySpawnEvent(double triggerTime, Enemy.EnemyType enemyType, Node parentLayer, PlayerCreature player)
 {
     this.triggerTime = triggerTime;
     this.enemyType = enemyType;
     this.parent = parentLayer;
     this.player = player;
 }
示例#3
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);
        }
示例#4
0
        public EventManager(Node parent, PlayerCreature player)
        {
            _eventList = new List<Event>();

            EnemySpawnEvent enemySpawn0 = new EnemySpawnEvent(1.0f, Enemy.EnemyType.ENEMY_TYPE_FISH, parent, player);
            EnemySpawnEvent enemySpawn1 = new EnemySpawnEvent(5.0f, Enemy.EnemyType.ENEMY_TYPE_FISH, parent, player);
            EnemySpawnEvent enemySpawn2 = new EnemySpawnEvent(15.0f, Enemy.EnemyType.ENEMY_TYPE_FISH, parent, player);

            _eventList.Add(enemySpawn0);
            _eventList.Add(enemySpawn1);
            _eventList.Add(enemySpawn2);

            _currentIndex = 0;
            _startTime = Director.Instance.DirectorTime;
        }
示例#5
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);
        }