Exemple #1
0
 public LMessage(LTexture formImage, int x, int y, int width, int height)
     : base(x, y, width, height)
 {
     this.animation = new Animation();
     if (formImage == null)
     {
         this.SetBackground(new LTexture(width, height, true));
         this.SetAlpha(0.3F);
     }
     else
     {
         this.SetBackground(formImage);
         if (width == -1)
         {
             width = formImage.GetWidth();
         }
         if (height == -1)
         {
             height = formImage.GetHeight();
         }
     }
     this.print = new Print(GetLocation(), messageFont, width, height);
     if (XNAConfig.IsActive())
     {
         this.SetTipIcon(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "creese.png"));
     }
     this.totalDuration = 80;
     this.customRendering = true;
     this.SetWait(false);
     this.SetElastic(true);
     this.SetLocked(true);
     this.SetLayer(100);
 }
Exemple #2
0
 public MoveObject(float x, float y, float dw, float dh,
         Animation animation, TileMap map): base(x, y, dw, dh, animation, map)
 {
    
     this.timer = new LTimer(0);
     this.isComplete = false;
     this.allDirection = false;
     this.speed = 4;
 }
Exemple #3
0
	public Actor(Animation animation, int x, int y) {
		if (animation == null) {
			throw new RuntimeException("Animation is null !");
		}
		this.noSequenceNumber = sequenceNumber++;
		this.animation = animation;
		this.isAnimation = true;
		this.location.Set(x, y);
		this.SetImage(animation.GetSpriteImage());
	}
 public void AddAnimation(Animation anm)
 {
     if (anm != null)
     {
         anm.Listener = asl;
         playAnimations.Add(anm);
         isRunning = true;
         size++;
     }
 }
Exemple #5
0
 public Animation(Animation a)
 {
     this.isRunning = a.isRunning;
     this.frames = new List<Animation.AnimationFrame>(a.frames);
     this.loopCount = a.loopCount;
     this.loopPlay = a.loopPlay;
     this.currentFrameIndex = a.currentFrameIndex;
     this.animTime = a.animTime;
     this.totalDuration = a.totalDuration;
     this.size = frames.Count;
 }
Exemple #6
0
 public JumpObject(float x, float y, Animation animation, TileMap map):  base(x, y, 0, 0, animation, map)
 {
     this.GRAVITY = 0.6f;
     vx = 0;
     vy = 0;
     speed = 6f;
     jumpSpeed = 12f;
     onGround = false;
     forceJump = false;
     jumperTwo = false;
     canJumperTwo = true;
 }
        public SpriteBatchObject(float x, float y, float dw, float dh,
				Animation animation, TileMap map)
        {
            this.SetLocation(x, y);
            this.tiles = map;
            this.animation = animation;
            this.dstWidth = dw;
            this.dstHeight = dh;
            if (dw < 1 && dh < 1) {
                this.rectBox = new RectBox(x, y, animation.GetSpriteImage()
                        .GetWidth(), animation.GetSpriteImage().GetHeight());
            } else {
                this.rectBox = new RectBox(x, y, dw, dh);
            }
        }
		public SpriteBatchObject(float x, float y, float dw, float dh,
				Animation animation, TileMap map) {
			this.SetLocation(x, y);
			this.tiles = map;
			this.animation = animation;
			this.dstWidth = dw;
			this.dstHeight = dh;
            Loon.Core.Graphics.Opengl.LTexture texture = animation.GetSpriteImage();
			if (dw < 1 && dh < 1) {
                this.rectBox = new RectBox(x, y, texture
                        .GetWidth(), texture.GetHeight());
			} else {
				this.rectBox = new RectBox(x, y, dw, dh);
			}
		}
Exemple #9
0
 public void OnComplete(Animation animation)
 {
     if (store.animationIndexLocked != -1)
     {
         store.currentFrameIndex = store.animationIndexLocked;
     }
     else
     {
         if (store.loopOverToRemove)
         {
             if (store.Listener != null)
             {
                 store.Listener.OnComplete(store);
             }
             store.playAnimations.Remove(animation);
             store.size = store.playAnimations.Count;
             store.loopPlay++;
         }
         else
         {
             if (store.currentFrameIndex < store.size - 1)
             {
                 if (store.Listener != null)
                 {
                     store.Listener.OnComplete(store);
                 }
                 store.currentFrameIndex++;
                 store.loopPlay++;
             }
             else
             {
                 if (store.loopOverToPlay)
                 {
                     store.currentFrameIndex = 0;
                 }
                 else
                 {
                     store.currentFrameIndex = 0;
                     store.isRunning = false;
                 }
             }
         }
     }
 }
Exemple #10
0
 public override void CreateUI(GLEx g)
 {
     base.CreateUI(g);
     switch (type)
     {
         case 0:
             if (a1 == null)
             {
                 a1 = Animation.GetDefaultAnimation("assets/s.png", 3, 48, 48,
                         100);
             }
             animation = a1;
             break;
         case 2:
             if (a2 == null)
             {
                 a2 = Animation
                         .GetDefaultAnimation("assets/s1.png", 48, 48, 100);
             }
             animation = a2;
             break;
         default:
             break;
     }
     if (animation == null)
     {
         return;
     }
     if (type == 0 || type == 2)
     {
         LTexture img = animation.GetSpriteImage();
         if (img != null)
         {
             g.DrawTexture(img, X() + (GetWidth() - img.GetWidth()) / 2, Y()
                     + (GetHeight() - img.GetHeight()) / 2);
         }
     }
 }
Exemple #11
0
 public void Dispose()
 {
     this.visible = false;
     if (image != null)
     {
         image.Dispose();
         image = null;
     }
     if (animation != null)
     {
         animation.Dispose();
         animation = null;
     }
 }
Exemple #12
0
 public void SetAnimation(Animation animation)
 {
     this.animation = animation;
 }
Exemple #13
0
 private void SetAnimation(Animation myAnimation, LTexture[] images,
         int maxFrame, long timer)
 {
     if (maxFrame != -1)
     {
         for (int i = 0; i < maxFrame; i++)
         {
             myAnimation.AddFrame(images[i], timer);
         }
     }
     else
     {
         for (int i = 0; i < images.Length; i++)
         {
             myAnimation.AddFrame(images[i], timer);
         }
     }
 }
Exemple #14
0
 public virtual void Dispose()
 {
     if (image != null)
     {
         image.Destroy();
         image = null;
     }
     if (animation != null)
     {
         animation.Dispose();
         animation = null;
     }
 }
Exemple #15
0
 public Enemy(float x, float y, Animation animation, TileMap tiles)
     : base(x, y, 32, 32, animation, tiles)
 {
     vx = -SPEED;
     vy = 0;
 }
Exemple #16
0
 public MoveObject(float x, float y, Animation animation, TileMap map):this(x, y, 0, 0, animation, map)
 {
     
 }
Exemple #17
0
            public Accelerator(float x, float y, Animation animation, TileMap tiles)
                : base(x, y, 32, 32, animation, tiles)
            {

            }
Exemple #18
0
        public override void Dispose()
        {
			base.Dispose();
			if (animation != null) {
				animation.Dispose();
				animation = null;
			}
		}
Exemple #19
0
 public override void Dispose()
 {
     base.Dispose();
     if (print != null)
     {
         print.Dispose();
         print = null;
     }
     if (animation != null)
     {
         animation.Dispose();
         animation = null;
     }
 }
Exemple #20
0
 /**
  * ת��һ��ImageΪ����ͼ��
  *
  * @param images
  * @param maxFrame
  * @param width
  * @param height
  * @param timer
  * @return
  */
 public static Animation GetDefaultAnimation(LTexture[] images,
         int maxFrame, int timer)
 {
     if (images == null)
     {
         return new Animation();
     }
     Animation animation = new Animation();
     if (maxFrame != -1)
     {
         for (int i = 0; i < maxFrame; i++)
         {
             animation.AddFrame(images[i], timer);
         }
     }
     else
     {
         int size = images.Length;
         for (int i = 0; i < size; i++)
         {
             animation.AddFrame(images[i], timer);
         }
     }
     return animation;
 }
 public virtual JumpObject AddJumpObject(float x, float y, float w, float h,
         Animation a)
 {
     JumpObject o = null;
     if (indexTile != null)
     {
         o = new JumpObject(x, y, w, h, a, indexTile);
     }
     else if (tiles.Count > 0)
     {
         o = new JumpObject(x, y, w, h, a, tiles[0]);
     }
     else
     {
         return null;
     }
     Add(o);
     return o;
 }
Exemple #22
0
            public JumperTwo(float x, float y, Animation animation, TileMap tiles)
                : base(x, y, 32, 32, animation, tiles)
            {

            }
Exemple #23
0
 public JumpI(TileMap indexMap, Animation enemyAnimation)
 {
     this.indexMap = indexMap;
     this.enemyAnimation = enemyAnimation;
 }
Exemple #24
0
            public Coin(float x, float y, Animation animation, TileMap tiles)
                : base(x, y, 32, 32, animation, tiles)
            {

            }
 public SimpleObject(float x, float y, float w, float h,
         Animation animation, TileMap tiles)
     : base(x, y, w, h, animation, tiles)
 {
 }
Exemple #26
0
 public void SetPauseIconAnimation(Animation a)
 {
     this.animation = a;
     if (a != null)
     {
         LTexture image = a.GetSpriteImage(0);
         if (image != null)
         {
             this.dw = image.GetWidth();
             this.dh = image.GetHeight();
             this.UpdateIcon();
         }
     }
 }
 public void SetAnimation(Animation a)
 {
     this.animation = a;
 }
Exemple #28
0
 public virtual void SetAnimation(Animation anm)
 {
     if (anm == null)
     {
         throw new Exception("Animation is null !");
     }
     this.animation = anm;
     this.isAnimation = true;
     this.SetImage(anm.GetSpriteImage());
 }
Exemple #29
0
	public Actor(Animation animation):this(animation, 0, 0) {
		
	}
Exemple #30
0
        public override void Create()
        {

            // 以指定图片创建动画
            this.coinAnimation = Animation.GetDefaultAnimation("assets/coin.png",
                    32, 32, 200);
            this.enemyAnimation = Animation.GetDefaultAnimation("assets/enemy.gif",
                    32, 32, 200, LColor.black);
            this.accelAnimation = Animation.GetDefaultAnimation(
                    "assets/accelerator.gif", 32, 32, 200);
            this.jumpertwoAnimation = Animation.GetDefaultAnimation(
                    "assets/jumper_two.gif", 32, 32, 200);

            // 注销Screen时释放下列资源
            PutReleases(coinAnimation, enemyAnimation, accelAnimation,
                    jumpertwoAnimation, hero);

            // 加载一张由字符串形成的地图(如果不使用此方式加载,则默认使用标准的数组地图)
            TileMap indexMap = TileMap.LoadCharsMap("assets/map.chr", 32, 32);
            // 如果有配置好的LTexturePack文件,可于此注入
            // indexMap.setImagePack(file);
            // 设定无法穿越的区域(如果不设置此项,所有索引不等于"-1"的区域都可以穿越)
            indexMap.SetLimit(new int[] { 'B', 'C', 'i', 'c' });
            indexMap.PutTile('B', "assets/block.png");
            int imgId = indexMap.PutTile('C', "assets/coin_block.gif");
            // 因为两块瓦片对应同一地图字符,所以此处使用了已载入的图片索引
            indexMap.PutTile('i', imgId);
            indexMap.PutTile('c', "assets/coin_block2.gif");

            // 加载此地图到窗体中
            putTileMap(indexMap);

            // 获得地图对应的二维数组
            int[][] maps = indexMap.GetMap();

            int w = indexMap.GetRow();
            int h = indexMap.GetCol();

            // 遍历二维数组地图,并以此为基础添加角色到窗体之上
            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    switch (maps[j][i])
                    {
                        case 'o':
                            Coin coin = new Coin(indexMap.TilesToPixelsX(i),
                                    indexMap.TilesToPixelsY(j), new Animation(
                                            coinAnimation), indexMap);
                            AddTileObject(coin);
                            break;
                        case 'k':
                            Enemy enemy = new Enemy(indexMap.TilesToPixelsX(i),
                                    indexMap.TilesToPixelsY(j), new Animation(
                                            enemyAnimation), indexMap);
                            AddTileObject(enemy);
                            break;
                        case 'a':
                            Accelerator accelerator = new Accelerator(
                                    indexMap.TilesToPixelsX(i),
                                    indexMap.TilesToPixelsY(j), new Animation(
                                            accelAnimation), indexMap);
                            AddTileObject(accelerator);
                            break;
                        case 'j':
                            JumperTwo jump = new JumperTwo(indexMap.TilesToPixelsX(i),
                                    indexMap.TilesToPixelsY(j), new Animation(
                                            jumpertwoAnimation), indexMap);
                            AddTileObject(jump);
                            break;
                    }
                }
            }

            // 获得主角动作图
            Animation animation = Animation.GetDefaultAnimation("assets/hero.png",
                    20, 20, 150, LColor.black);

            // 在像素坐标位置(192,32)放置角色,大小为32x32,动画为针对hero.png的分解图
            hero = AddJumpObject(192, 32, 32, 32, animation);

            // 让地图跟随指定对象产生移动(无论插入有多少张数组地图,此跟随默认对所有地图生效)
            // 另外请注意,此处能产生跟随的对像是任意LObject,并不局限于游戏角色。
            Follow(hero);

            // 监听跳跃事件
            hero.listener = new JumpI(indexMap, enemyAnimation);
            AddActionKey(Key.LEFT, new GoLeftKey());
            AddActionKey(Key.RIGHT, new GoRightKey());
            AddActionKey(Key.UP, new GoJumpKey());
            if (LSystem.type != LSystem.ApplicationType.JavaSE)
            {

                LPad pad = new LPad(10, 180);
                pad.SetListener(new PadClick(this));
                Add(pad);
            }
            this.updateListener =new GameUpdateListener(this);
        }