Exemplo n.º 1
0
        private void LoadSheet(AnimationSheet sheet)
        {
            if (sheet == null)
            {
                return;
            }

            ResetAnimationTimers();
            currentSheet = sheet;

            //Construct others list

            List <string> items = new List <string>()
            {
                "Idle",
                "Walking",
                "Running",
                "Casting",
                "Attacking"
            };

            items.Remove(sheet.name);

            others.Items.Clear();
            for (int i = 0; i < items.Count; i++)
            {
                if (!GrabSheet(current, items[i]).IsEmpty())
                {
                    others.Items.Add(items[i]);
                }
            }

            //Set UI

            useOther.Checked = sheet.useOther;

            leftGroupBox.Enabled  = !useOther.Checked;
            rightGroupBox.Enabled = !useOther.Checked;
            upGroupBox.Enabled    = !useOther.Checked;
            downGroupBox.Enabled  = !useOther.Checked;
            speed.Enabled         = !useOther.Checked;

            others.SelectedItem = sheet.other;
            others.Enabled      = useOther.Checked;

            //Load frames

            speed.Value = sheet.speed;

            //Invalidate

            InvalidateCanvasses();
        }
Exemplo n.º 2
0
        private void frameTimer_Tick(object sender, ElapsedEventArgs e)
        {
            if (currentSheet == null)
            {
                return;
            }

            AnimationSheet sheet =
                (currentSheet.useOther
                    ? GrabSheet(current, currentSheet.other)
                    : currentSheet);

            if (sheet == null)
            {
                return;
            }

            elapsed  += (int)(stopwatch.ElapsedTicks / TimeSpan.TicksPerMillisecond);
            stopwatch = Stopwatch.StartNew();

            if (elapsed >= sheet.speed)
            {
                upFrame++;
                downFrame++;
                leftFrame++;
                rightFrame++;

                if (upFrame >= sheet.frames[(int)Direction.Up].Length)
                {
                    upFrame = 0;
                }
                if (downFrame >= sheet.frames[(int)Direction.Down].Length)
                {
                    downFrame = 0;
                }
                if (leftFrame >= sheet.frames[(int)Direction.Left].Length)
                {
                    leftFrame = 0;
                }
                if (rightFrame >= sheet.frames[(int)Direction.Right].Length)
                {
                    rightFrame = 0;
                }

                elapsed = 0;

                InvalidateCanvasses();
            }
        }
Exemplo n.º 3
0
        private bool CheckPresentAnimation(AnimationSheet sheet)
        {
            if (sheet.useOther)
            {
                AnimationSheet other = CharacterAnimations.GrabSheet(current, sheet.other);

                if (other == null)
                {
                    return(false);
                }

                return(CheckPresentAnimation(other));
            }

            return(!sheet.IsEmpty());
        }
Exemplo n.º 4
0
        public SheetSelection(Character character, AnimationSheet sheet, Image image, string animation, Direction direction)
        {
            InitializeComponent();

            Text = "WebClash - Edit " + animation.ToLower() + " " + direction.ToString().ToLower() + " frames";

            current          = character;
            currentSheet     = sheet;
            currentImage     = image;
            currentDirection = direction;

            camera = new Point(
                canvas.Width / 2 - image.Width / 2,
                canvas.Height / 2 - image.Height / 2
                );

            LoadFrameList();

            canvas.Paint += Canvas_Paint;
            canvas.Invalidate();
        }
Exemplo n.º 5
0
        private void DrawFrame(Graphics g, Direction direction, int frame)
        {
            try
            {
                g.Clear(SystemColors.ControlLight);
                g.SmoothingMode = SmoothingMode.HighQuality;

                //Grab correct sheet

                AnimationSheet sheet =
                    (currentSheet.useOther
                        ? GrabSheet(current, currentSheet.other)
                        : currentSheet);

                if (sheet == null)
                {
                    return;
                }

                Point2D[] frames = sheet.frames[(int)direction];
                if (frames.Length == 0 || frame >= frames.Length)
                {
                    return;
                }

                //Get clip data

                Size    s = new Size(current.width, current.height);
                Point2D p = frames[frame];

                //Calculate centered drawing point
                //and destination rectangle

                Point center = new Point(
                    canvasSize / 2 - current.width / 2,
                    canvasSize / 2 - current.height / 2
                    );

                Rectangle destination = new Rectangle(center, s);

                //Draw frame

                g.DrawImage(
                    currentImage,
                    destination,
                    p.x, p.y,
                    s.Width, s.Height,
                    GraphicsUnit.Pixel
                    );

                //Draw frame indicator

                g.DrawString(
                    (frame + 1) + "/" + frames.Length,
                    DefaultFont,
                    Brushes.Black,
                    new Point(3, 3)
                    );
            }
            catch
            {
                //...
            }
        }