Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        // CONSTRUCTOR -----------------------------------------------------------------------
        public Slider(int trackLength=320)
        {
            active = false;

            Title = new Label() {
                FontMap = FontManager.Instance.GetMap( FontManager.Instance.GetInGame("Bariol", 32, "Bold") ),
                Position = new Vector2(-TICK_WIDTH/2.0f, 29.0f),
                Color = Colors.Black
            };
            this.AddChild(Title);

            min = 0.0f;
            max = 100.0f;
            val = min;
            Track = Support.UnicolorSprite("white", 255, 255, 255, 255);
            Track.Scale = new Vector2((float)trackLength/16.0f, 0.625f);
            this.AddChild(Track);
            length = (float)trackLength;

            //			Knob = Support.UnicolorSprite("white", 255, 255, 255, 255);
            //			Knob = Support.SpriteFromFile("/Application/assets/images/UI/sliderLozenge.png");
            Knob = Support.SpriteFromAtlas("crystallonUI", "sliderLozenge.png");
            Knob.CenterSprite(new Vector2(0.5f, 0.36f));
            //			Knob.Position = new Vector2((pValue/(max-min+min))*length, 0.0f);
            this.AddChild(Knob,100);

            bounds = new Bounds2( new Vector2(-20.0f, -20.0f), new Vector2(length+20.0f, 36.0f) );
            #if DEBUG
            Console.WriteLine(GetType().ToString() + " created" );
            #endif
        }
        private SpriteTile spritePlayer = null; //最初に表示されるpngイラスト

        #endregion Fields

        #region Constructors

        /**
         *@param float positionX 描画する位置(画面の分割率)
         *@param float positionY 描画する位置(画面の分割率)
         *@param Scene scene 描画するscene
         *ファイル名等は今クラス内に埋め込み。読み込むSpriteSheetごとにCallクラスが一つ必要
         */
        public DrawPlayerSheetSample(float positionX,float positionY,float sizeX,float sizeY, string img, string xml, Scene scene)
        {
            playerSheet = new PlayerSheetSample(img,xml);//このSpriteSheetを呼ぶ
            spritePlayer = playerSheet.Get("Walk_left00"); //最初に表示されるpngイラスト
            //positionX = Director.Instance.GL.Context.GetViewport().Width/positionX;
            //positionY = Director.Instance.GL.Context.GetViewport().Height/positionY;
            positionX = Const.DISPLAY_WIDTH - Const.DISPLAY_WIDTH*(Const.GRID_NUM_X-positionX)/Const.GRID_NUM_X;
            positionY = Const.DISPLAY_HEIGHT - Const.DISPLAY_HEIGHT*positionY/Const.GRID_NUM_Y;

            spriteOffset = 0;
            spriteName = "Walk_left" + spriteOffset.ToString("00");

            //var
            //scene.Camera.SetViewFromViewport();
            //var spriteWalker = walker.Get("Walk_left00");

            //spriteWalker.Position = scene.Camera.CalcBounds().Center;
            //spriteWalker.Position = new Vector2(positionX,positionY); //オブジェクトの位置
            spritePlayer.CenterSprite();
            spritePlayer.Scale = new Vector2(sizeX,sizeY); //サイズの変更
            //spriteWalker.Position = new Vector2(positionX+spriteWalker.Quad.S.X/2,positionY-spriteWalker.Quad.S.Y/2);
            spritePlayer.Position = new Vector2(0,0);
            spritePlayer.Quad.T.X = positionX;
            spritePlayer.Quad.T.Y = positionY - spritePlayer.Quad.S.Y;

            //sceneに追加
            scene.AddChild(spritePlayer);
        }
Ejemplo n.º 4
0
 public AnimationFall()
 {
     b = AnimationFallSpriteSingleton.getInstance().Get("1");
      		b.Position = new Vector2(100,100);
     b.CenterSprite();
     this.AddChild(b);
     Scheduler.Instance.ScheduleUpdateForTarget(this,  0,false);
 }
        public void testAnimation()
        {
            a = Support.TiledSpriteFromFile( "Application/assets/animation/leftGlitch/leftOneLine.png", 15, 1 );
            //			a = AnimationGlitchSpriteSingleton.getInstance().Get("1");
             		a.Position = new Vector2(100,100);
            a.CenterSprite();
            this.AddChild(a);

            a.RunAction( new Support.AnimationAction(a,0,4,3.0f,true) );

            Scheduler.Instance.ScheduleUpdateForTarget(this,  0,false);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public virtual SpriteTile createSprite(TextureInfo texture_info, float world_scale=1.5f)
        {
            SpriteTile sprite;

            //スプライト生成
            sprite = new SpriteTile(){TextureInfo = texture_info};
            //表示するテクスチャID
            sprite.TileIndex1D=0;
            //拡大率
            sprite.Quad.S = sprite.CalcSizeInPixels() * world_scale;
            //スプライトの中心と座標の中心を一致させる
            sprite.CenterSprite();
            //輝度設定
            sprite.Color=new Vector4(1.0f,1.0f,1.0f,1.00f);
            //表示の混合設定
            sprite.BlendMode = BlendMode.Normal;

            return sprite;
        }
Ejemplo n.º 8
0
        public WinSection(Vector2 pos)
            : base(pos)
        {
            sprite = Support.TiledSpriteFromFile("/Application/assets/Goal_Object.png", 1, 1);
              spriteoverlay = Support.TiledSpriteFromFile("/Application/assets/Goal_Object_Overlay_1.png", 1, 1);
              sprite.Position = pos;
              spriteoverlay.Position = pos;
              sprite.CenterSprite();
              spriteoverlay.CenterSprite();

              GameScene.Instance.AddChild(sprite);

              var goaloverlay = Support.TiledSpriteFromFile("/Application/assets/Screen_Object.png", 10, 4);
              goaloverlay.CenterSprite();
              goaloverlay.Position = new Vector2(sprite.Position.X, sprite.Position.Y+35);
              goaloverlay.VertexZ = 1;
              this.AddChild(goaloverlay);
              var ScreenAnimation = new Support.AnimationAction(goaloverlay, 1, 40, 1.0f, looping: true);
              goaloverlay.RunAction(ScreenAnimation);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        private SpriteTile CreateSpriteTile(String path, Int32 u, Int32 v, Boolean centerToSprite, Vector2 center)
        {
            if (String.IsNullOrWhiteSpace(path))
                throw new ArgumentException();

            if (!TextureAssetsByUsers.ContainsKey(path))
                throw new ArgumentException("Unknown texture asset: " + path);

            TextureInfo ti = GetTextureInfo(path);//TextureAssets[path];

            SpriteTile s = new SpriteTile(ti, new Vector2i(u, v));
            s.Quad.S = new Vector2(ti.Texture.Width / ti.NumTiles.X, ti.Texture.Height / ti.NumTiles.Y);

            if (centerToSprite)
                s.CenterSprite();
            else
                s.CenterSprite(center);

            return s;
        }
Ejemplo n.º 13
0
        public void SpriteInitialize()
        {
            //オープニングタイトルのSpriteTileスプライトを構成する
            Texture2D texture_title = new Texture2D ("/Application/assets/PressStart.png", false);
            var textureInfo_title= new TextureInfo (texture_title,new Vector2i(1, 1));
            //ロードしたテクスチャでSpriteUVを初期化する
            Title = new SpriteTile () { TextureInfo = textureInfo_title};
            //テクスチャのサイズをスプライトのサイズとして設定
            Title.Quad.S = textureInfo_title.TextureSizef;
            // スプライト上のPositon座標の位置を設定
            Title.CenterSprite();

            //背景のSpriteTileスプライトを構成する
            Texture2D texture_background = new Texture2D ("/Application/assets/ag0.png", false);
            var textureInfo_background = new TextureInfo (texture_background,new Vector2i(1, 1));
            //ロードしたテクスチャでSpriteUVを初期化する
            Background = new SpriteTile () { TextureInfo = textureInfo_background};
            //テクスチャのサイズをスプライトのサイズとして設定
            Background.Quad.S = textureInfo_background.TextureSizef;
            // スプライト上のPositon座標の位置を設定
            Background.CenterSprite();

            //プレイヤーのSpriteTileスプライトを構成する
            Texture2D texture_player = new Texture2D ("/Application/assets/r23.png", false);
            var textureInfo_player = new TextureInfo (texture_player,new Vector2i(2, 1));
            //ロードしたテクスチャでSpriteUVを初期化する
            Player = new SpriteTile () { TextureInfo = textureInfo_player};
            //テクスチャのサイズをスプライトのサイズとして設定
            Player.Quad.S = textureInfo_player.TextureSizef;
            // スプライト上のPositon座標の位置を設定
            Player.CenterSprite ();//

            //TileIndex2D はこのスプライトに使われる UV を定義する
            Player.TileIndex2D = new Vector2i(0, 0);
            Player.Schedule( ( dt ) =>
            {
                        if ( TickCounter % 8 == 0 ) {
                             Player_animation_counter = Player_animation_counter==1 ? 0 : 1;
                            Player.TileIndex2D = new Vector2i(Player_animation_counter, 0);
                            //Console.WriteLine(Common.FrameCount);
                            }
            } );

            //蝙蝠のSpriteTileスプライトを構成する
            Texture2D texture_bat = new Texture2D ("/Application/assets/bat_frames.png", false);
            var textureInfo_bat = new TextureInfo (texture_bat,new Vector2i(2, 2));
            //ロードしたテクスチャでSpriteTileを初期化する
            Bat = new SpriteTile () { TextureInfo = textureInfo_bat};
            //テクスチャのサイズをスプライトのサイズとして設定
            Bat.Quad.S = textureInfo_bat.TextureSizef;
            //Batの大きさを半分にする
            Bat.Scale = new Vector2( 0.5f );
            // スプライト上のPositon座標の位置を設定
            Bat.CenterSprite ();//

            //TileIndex2D はこのスプライトに使われる UV を定義する
            Bat.TileIndex2D = new Vector2i(0, 0);
            Bat.Schedule( ( dt ) =>
            {
                        if ( TickCounter % 4 == 0 ) {
                            // Bat_animation_counter = (Bat_animation_counter++)%4;
                            Bat.TileIndex2D = new Vector2i((Bat_animation_counter++)%4, 0);
                            //Console.WriteLine(Common.FrameCount);
                            }
            } );
        }
Ejemplo n.º 14
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);
        }