コード例 #1
0
ファイル: FishEnemy.cs プロジェクト: edibletoaster/PSM-Game
        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 PlayerCreature()
        {
            Animations = new Dictionary<string, Animation>();
            texInfo = new TextureInfo(AssetManager.GetTexture("spritesheet"), new Vector2i(2,2), TRS.Quad0_1);
            Animations.Add("idle" , new Animation(0, 2, 0.4f, false));
            CurrentAnimation = Animations["idle"];
            CurrentAnimation.Play();
            sprite = new SpriteTile(texInfo);
            sprite.TileIndex1D = CurrentAnimation.CurrentFrame;
            sprite.Quad.S = texInfo.TextureSizef;

            isJumping = false;
        }
コード例 #3
0
        public PlayerCreature()
        {
            Dead = false;
            Animations = new Dictionary<string, Animation>();
            texInfo = new TextureInfo(AssetManager.GetTexture("catanimation"), new Vector2i(5,1),TRS.Quad0_1);
            Animations.Add("idle" , new Animation(0, 3, 0.1f, false));
            CurrentAnimation = Animations["idle"];
            CurrentAnimation.Play();
            sprite = new SpriteTile(texInfo);
            sprite.TileIndex1D = CurrentAnimation.CurrentFrame;
            sprite.Quad.S = new Vector2(258, 214);
            sprite.CenterSprite();
            isJumping = false;

            BoundingBox = new Bounds2(new Vector2(0, 258), new Vector2(0, 214));
        }
コード例 #4
0
ファイル: EndScene.cs プロジェクト: edibletoaster/PSM-Game
        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);
        }