示例#1
0
        /// <summary>
        /// Set Animation Sprites
        /// </summary>
        /// <param Name="sprites"></param>
        /// <param Name="cell_data"></param>
        /// <param Name="position"></param>
        void AnimationSetSprites(List <Geex.Run.Sprite> sprites, int[,] cell_data, int position)
        {
            if (sprites == null)
            {
                return;
            }
            for (int i = 0; i < sprites.Count; i++)
            {
                Geex.Run.Sprite sprite  = sprites[i];
                int             pattern = cell_data[i, 0];

                if (sprite == null || pattern == -1)
                {
                    if (sprite != null)
                    {
                        sprite.IsVisible = false;
                    }
                    continue;
                }
                sprite.IsVisible  = true;
                sprite.SourceRect = new Rectangle(pattern % 5 * 192, pattern / 5 * 192, 192, 192);
                if (position == 3)
                {
                    if (this.Viewport != null)
                    {
                        sprite.X = TileManager.Rect.Width / 2;
                        sprite.Y = TileManager.Rect.Height - 160;
                    }
                    else
                    {
                        sprite.X = 320;
                        sprite.Y = 240;
                    }
                }
                else
                {
                    sprite.X = this.X - this.Ox + this.SourceRect.Width / 2;
                    sprite.Y = this.Y - this.Oy + this.SourceRect.Height / 2;
                    if (position == 0)
                    {
                        sprite.Y -= this.SourceRect.Height / 4;
                    }
                    if (position == 2)
                    {
                        sprite.Y += this.SourceRect.Height / 4;
                    }
                }
                sprite.X        += cell_data[i, 1];
                sprite.Y        += cell_data[i, 2];
                sprite.Z         = sprite.Y + animationPriority;
                sprite.Ox        = 96;
                sprite.Oy        = 96;
                sprite.ZoomX     = (cell_data[i, 3] / 100f) + animationZoom;
                sprite.ZoomY     = (cell_data[i, 3] / 100f) + animationZoom;
                sprite.Angle     = cell_data[i, 4];
                sprite.Mirror    = (cell_data[i, 5] == 1);
                sprite.Opacity   = (byte)(cell_data[i, 6] * this.Opacity / 255);
                sprite.BlendType = cell_data[i, 7];
            }
        }
 /// <summary>
 /// Setup particle sprites and position
 /// </summary>
 /// <param Name="fromEvent">Event managing the particle</param>
 /// <param Name="fromViewport">Viewport displaying particle</param>
 /// <param Name="folder">Folder of the particle graphic</param>
 /// <param Name="filename">filename of particle texture</param>
 protected new void Setup(GameEvent fromEvent, Viewport fromViewport, string folder, string filename)
 {
     particleFolder = folder;
     Ev             = fromEvent;
     particles      = new LocalSprite[maxParticles];
     opacity        = new int[maxParticles];
     startingX      = Ev.ScreenX + xOffset;
     startingY      = Ev.ScreenY + yOffset;
     screenX        = Ev.ScreenX;
     screenY        = Ev.ScreenY;
     // Create particle Sprites
     for (int i = 0; i < maxParticles; i++)
     {
         particles[i]        = new LocalSprite(fromViewport);
         particles[i].Bitmap = Cache.LoadBitmap(folder, filename, hue);
         int cw = particles[i].Bitmap.Width / GameOptions.CharacterPatterns;
         int ch = particles[i].Bitmap.Height / GameOptions.CharacterDirections;
         particles[i].Oy         = GameOptions.IsArpgCharacterOn && particles[i].Bitmap.Height == particles[i].Bitmap.Width ? 2 * ch / 3 : ch;
         particles[i].Ox         = cw / 2;
         particles[i].SourceRect = new Rectangle(Ev.Pattern * cw, (Ev.Dir - 2) / 2 * ch, cw, ch);
         particles[i].BlendType  = blendValue;
         particles[i].Y          = startingY;
         particles[i].X          = startingX;
         particles[i].Z          = Ev.ScreenZ() - 1;
         opacity[i] = Ev.Opacity;
     }
 }
示例#3
0
        /// <summary>
        /// Set Loop Animation
        /// </summary>
        /// <param Name="Animation">Animation</param>
        protected void LoopAnimation(Animation animation)
        {
            // If Id is 0, animation is to be disposed
            if (animation != null && animation.Id == 0)
            {
                DisposeLoopAnimation();
                return;
            }
            if (animation == mLoopAnimation || animation.Frames == null)
            {
                return;
            }
            DisposeLoopAnimation();
            mLoopAnimation = animation;
            if (mLoopAnimation == null || mLoopAnimation.Frames == null)
            {
                return;
            }
            loopAnimationIndex = 0;
            string animation_name = mLoopAnimation.AnimationName;
            int    animation_hue  = mLoopAnimation.AnimationHue;
            Bitmap bitmap         = Cache.Animation(animation_name, animation_hue);

            if (referenceCount.ContainsKey(bitmap))
            {
                referenceCount[bitmap] += 1;
            }
            else
            {
                referenceCount[bitmap] = 1;
            }
            if (loopAnimationSprites != null)
            {
                loopAnimationSprites.Clear();
            }
            else
            {
                loopAnimationSprites = new List <Sprite>();
            }
            for (int i = 0; i < animation.Frames[0].CellMax; i++)
            {
                Geex.Run.Sprite sprite = new Geex.Run.Sprite(this.Viewport);
                sprite.Bitmap    = bitmap;
                sprite.IsVisible = false;
                loopAnimationSprites.Add(sprite);
            }
        }
示例#4
0
        /// <summary>
        /// Frame Update
        /// </summary>
        public void Update()
        {
            if (Type == 0)
            {
                return;
            }

            for (int i = 0; i < Max; i++)
            {
                Geex.Run.Sprite _sprite = sprites[i];

                if (_sprite == null)
                {
                    break;
                }

                if (Type == 1)
                {
                    _sprite.X       -= 2;
                    _sprite.Y       += 16;
                    _sprite.Opacity -= 8;
                }

                if (Type == 2)
                {
                    _sprite.X       -= 8;
                    _sprite.Y       += 16;
                    _sprite.Opacity -= 12;
                }

                if (Type == 3)
                {
                    _sprite.X       -= 2;
                    _sprite.Y       += 8;
                    _sprite.Opacity -= 8;
                }

                int x = _sprite.X;
                int y = _sprite.Y;
                if (_sprite.Opacity < 64 || x < 0 || x > GeexEdit.GameWindowWidth || y < 0 || y > GeexEdit.GameWindowHeight)
                {
                    _sprite.X       = InGame.Rnd.Next(GeexEdit.GameWindowWidth);
                    _sprite.Y       = InGame.Rnd.Next(GeexEdit.GameWindowHeight) - 200;
                    _sprite.Opacity = 255;
                }
            }
        }
示例#5
0
        /// <summary>
        /// Set Animation
        /// </summary>
        /// <param Name="Animation">Animation</param>
        /// <param Name="Hit">true if Hit</param>
        protected void animation(Animation animation, bool hit)
        {
            DisposeAnimation();
            this.mAnimation = animation;
            if (animation == null)
            {
                return;
            }
            animationHit      = hit;
            animationDuration = animation.FrameMax + 1;
            string animation_name = animation.AnimationName;
            int    animation_hue  = animation.AnimationHue;

            animationBitmap = Cache.Animation(animation_name, animation_hue);
            if (referenceCount != null && referenceCount.ContainsKey(animationBitmap))
            {
                referenceCount[animationBitmap] += 1;
            }
            else
            {
                referenceCount[animationBitmap] = 1;
            }
            if (animationSprites != null)
            {
                animationSprites.Clear();
            }
            if (animation.Position != 3 || !animations.Contains(animation))
            {
                for (int i = 0; i < animation.Frames[0].CellMax; i++)
                {
                    Geex.Run.Sprite sprite = new Geex.Run.Sprite(this.Viewport);
                    sprite.Bitmap    = animationBitmap;
                    sprite.IsVisible = false;
                    if (animationSprites == null)
                    {
                        animationSprites = new List <Run.Sprite>();
                    }
                    animationSprites.Add(sprite);
                }
                if (animations == null || !animations.Contains(animation))
                {
                    animations.Add(animation);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param Name="viewport">weather sprites' viewport</param>
        public Weather(Viewport viewport)
        {
            Type = 0;
            Max  = 0;
            Ox   = 0;
            Oy   = 0;
            Color _color1 = new Color(255, 255, 255, 255);
            Color _color2 = new Color(255, 255, 255, 128);

            rainBitmap = new Bitmap(7, 56);

            for (int i = 0; i < 6; i++)
            {
                rainBitmap.FillRect(6 - i, i * 8, 1, 8, _color1);
            }

            stormBitmap = new Bitmap(34, 64);

            for (int i = 0; i < 31; i++)
            {
                stormBitmap.FillRect(33 - i, i * 2, 1, 2, _color2);
                stormBitmap.FillRect(32 - i, i * 2, 1, 2, _color1);
                stormBitmap.FillRect(31 - i, i * 2, 1, 2, _color2);
            }

            snowBitmap = new Bitmap(6, 6);
            snowBitmap.FillRect(0, 1, 6, 4, _color2);
            snowBitmap.FillRect(1, 0, 4, 6, _color2);
            snowBitmap.FillRect(1, 2, 4, 2, _color1);
            snowBitmap.FillRect(2, 1, 2, 4, _color1);
            sprites = new Geex.Run.Sprite[40];

            for (int i = 0; i < 40; i++)
            {
                sprites[i]           = new Geex.Run.Sprite(viewport);
                sprites[i].Z         = 1000;
                sprites[i].IsVisible = false;
                sprites[i].Opacity   = 0;
            }
        }
 /// <summary>
 /// Setup particle sprites and position
 /// </summary>
 /// <param Name="fromEvent">Event managing the particle</param>
 /// <param Name="fromViewport">Viewport displaying particle</param>
 /// <param Name="folder">Folder of the particle graphic</param>
 /// <param Name="filename">filename of particle texture</param>
 protected void Setup(GameEvent fromEvent, Viewport fromViewport, string folder, string filename)
 {
     Ev           = fromEvent;
     particleName = filename;
     particles    = new LocalSprite[maxParticles];
     opacity      = new int[maxParticles];
     startingX    = Ev.ScreenX + xOffset;
     startingY    = Ev.ScreenY + yOffset;
     screenX      = Ev.ScreenX;
     screenY      = Ev.ScreenY;
     // Create particle Sprites
     for (int i = 0; i < maxParticles; i++)
     {
         particles[i]           = new LocalSprite(fromViewport);
         particles[i].Bitmap    = Cache.LoadBitmap(folder, particleName, hue);
         particles[i].BlendType = blendValue;
         particles[i].Y         = startingY;
         particles[i].X         = startingX;
         particles[i].Z         = Ev.ScreenZ();
         opacity[i]             = 250;
     }
 }
示例#8
0
        /// <summary>
        /// Dispose Loop Animation
        /// </summary>
        void DisposeLoopAnimation()
        {
            if (loopAnimationSprites != null && loopAnimationSprites.Count != 0)
            {
                Geex.Run.Sprite sprite = loopAnimationSprites[0];
                if (sprite != null)
                {
                    referenceCount[sprite.Bitmap] -= 1;

                    if (referenceCount[sprite.Bitmap] == 0)
                    {
                        sprite.Bitmap.Dispose();
                    }
                }
                foreach (Geex.Run.Sprite _disposedSprite in loopAnimationSprites)
                {
                    _disposedSprite.Dispose();
                }
                loopAnimationSprites.Clear();
                loopAnimationSprites = null;
            }
            mLoopAnimation = null;
        }
示例#9
0
 /// <summary>
 /// Set Loop Animation
 /// </summary>
 /// <param Name="Animation">Animation</param>
 protected void LoopAnimation(Animation animation)
 {
     // If Id is 0, animation is to be disposed
     if (animation != null && animation.Id == 0)
     {
         DisposeLoopAnimation();
         return;
     }
     if (animation == mLoopAnimation || animation.Frames == null)
     {
         return;
     }
     DisposeLoopAnimation();
     mLoopAnimation = animation;
     if (mLoopAnimation == null || mLoopAnimation.Frames == null)
     {
         return;
     }
     loopAnimationIndex = 0;
     string animation_name = mLoopAnimation.AnimationName;
     int animation_hue = mLoopAnimation.AnimationHue;
     Bitmap bitmap = Cache.Animation(animation_name, animation_hue);
     if (referenceCount.ContainsKey(bitmap))
     {
         referenceCount[bitmap] += 1;
     }
     else
     {
         referenceCount[bitmap] = 1;
     }
     if (loopAnimationSprites != null)
     {
         loopAnimationSprites.Clear();
     }
     else
     {
         loopAnimationSprites = new List<Sprite>();
     }
     for (int i = 0; i < animation.Frames[0].CellMax; i++)
     {
         Geex.Run.Sprite sprite = new Geex.Run.Sprite(this.Viewport);
         sprite.Bitmap = bitmap;
         sprite.IsVisible = false;
         loopAnimationSprites.Add(sprite);
     }
 }
示例#10
0
 /// <summary>
 /// Set Animation
 /// </summary>
 /// <param Name="Animation">Animation</param>
 /// <param Name="Hit">true if Hit</param>
 protected void animation(Animation animation, bool hit)
 {
     DisposeAnimation();
     this.mAnimation = animation;
     if (animation == null)
     {
         return;
     }
     animationHit = hit;
     animationDuration = animation.FrameMax + 1;
     string animation_name = animation.AnimationName;
     int animation_hue = animation.AnimationHue;
     animationBitmap = Cache.Animation(animation_name, animation_hue);
     if (referenceCount != null && referenceCount.ContainsKey(animationBitmap))
     {
         referenceCount[animationBitmap] += 1;
     }
     else
     {
         referenceCount[animationBitmap] = 1;
     }
     if (animationSprites != null) animationSprites.Clear();
     if (animation.Position != 3 || !animations.Contains(animation))
     {
         for (int i = 0; i < animation.Frames[0].CellMax; i++)
         {
             Geex.Run.Sprite sprite = new Geex.Run.Sprite(this.Viewport);
             sprite.Bitmap = animationBitmap;
             sprite.IsVisible = false;
             if (animationSprites == null) animationSprites = new List<Run.Sprite>();
             animationSprites.Add(sprite);
         }
         if (animations == null || !animations.Contains(animation))
         {
             animations.Add(animation);
         }
     }
 }
 /// <summary>
 /// Object Initialization : Battleback Sprite
 /// </summary>
 public void InitializeBattleback()
 {
     // Make Battleback sprite
     battlebackSprite = new Geex.Run.Sprite(Graphics.Background);
 }
示例#12
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param Name="viewport">weather sprites' viewport</param>
        public Weather(Viewport viewport)
        {
            Type = 0;
            Max = 0;
            Ox = 0;
            Oy = 0;
            Color _color1 = new Color(255, 255, 255, 255);
            Color _color2 = new Color(255, 255, 255, 128);
            rainBitmap = new Bitmap(7, 56);

            for (int i = 0; i < 6; i++)
            {
                rainBitmap.FillRect(6 - i, i * 8, 1, 8, _color1);
            }

            stormBitmap = new Bitmap(34, 64);

            for (int i = 0; i < 31; i++)
            {
                stormBitmap.FillRect(33 - i, i * 2, 1, 2, _color2);
                stormBitmap.FillRect(32 - i, i * 2, 1, 2, _color1);
                stormBitmap.FillRect(31 - i, i * 2, 1, 2, _color2);
            }

            snowBitmap = new Bitmap(6, 6);
            snowBitmap.FillRect(0, 1, 6, 4, _color2);
            snowBitmap.FillRect(1, 0, 4, 6, _color2);
            snowBitmap.FillRect(1, 2, 4, 2, _color1);
            snowBitmap.FillRect(2, 1, 2, 4, _color1);
            sprites = new Geex.Run.Sprite[40];

            for (int i = 0; i < 40; i++)
            {
                sprites[i] = new Geex.Run.Sprite(viewport);
                sprites[i].Z = 1000;
                sprites[i].IsVisible = false;
                sprites[i].Opacity = 0;
            }
        }