Esempio n. 1
0
        internal override IList <DrawingInstruction> CreateInstructions(ProjectInstructions projectInstructions, IList <ScriptedInstruction> script, IList <DrawingInstruction> currentInstructions)
        {
            var results = new List <DrawingInstruction>();

            var previousFrame = PreviousFrame(currentInstructions);

            var text     = string.Concat(previousFrame.Text, '\n');
            var newFrame = new DrawingInstruction
            {
                Cursor = projectInstructions.DrawCursor,
                Delay  = 1,
                Text   = text
            };

            results.Add(newFrame);

            var lastFrame = new DrawingInstruction
            {
                Cursor = false,
                Delay  = 1,
                Text   = text
            };

            results.Add(lastFrame);

            return(results);
        }
        internal override IList <DrawingInstruction> CreateInstructions(ProjectInstructions projectInstructions, IList <ScriptedInstruction> script, IList <DrawingInstruction> currentInstructions)
        {
            var frameCount = Length / Delay;

            frameCount = frameCount % 2 == 0 ? frameCount + 1 : frameCount;

            var previousFrame = PreviousFrame(currentInstructions).Copy();

            var newFrameTemplate = new DrawingInstruction
            {
                Cursor = false,
                Delay  = Delay,
                Text   = string.Concat(previousFrame.Text, Text)
            };

            var results = new List <DrawingInstruction>();

            for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
            {
                var on = frameIndex % 2 == 0;

                var newFrame = on ? newFrameTemplate.Copy() : previousFrame;
                results.Add(newFrame);
            }

            return(results);
        }
        internal override IList <DrawingInstruction> CreateInstructions(ProjectInstructions projectInstructions, IList <ScriptedInstruction> script, IList <DrawingInstruction> currentInstructions)
        {
            var results = new List <DrawingInstruction>();

            if (Change == 0 || Start == End)
            {
                return(results);
            }

            var realChange = GetRealChange();

            var previousFrame = PreviousFrame(currentInstructions);

            for (var current = Start; End > Start && current <= End || Start > End && current >= End; current += realChange)
            {
                var newFrame = new DrawingInstruction
                {
                    Cursor = false,
                    Delay  = Delay,
                    Text   = string.Concat(previousFrame.Text, current.ToString())
                };

                results.Add(newFrame);
            }

            if (!LeaveTextWhenFinished)
            {
                results.Add(previousFrame.Copy());
            }

            return(results);
        }
Esempio n. 4
0
        internal override IList <DrawingInstruction> CreateInstructions(ProjectInstructions projectInstructions, IList <ScriptedInstruction> script, IList <DrawingInstruction> currentInstructions)
        {
            var results       = new List <DrawingInstruction>();
            var previousFrame = PreviousFrame(currentInstructions);

            if (!FlashCursor)
            {
                var newFrame = new DrawingInstruction
                {
                    Cursor = DrawCursor,
                    Delay  = Length,
                    Text   = previousFrame.Text
                };

                results.Add(newFrame);

                if (DrawCursor)
                {
                    var newFrame2 = new DrawingInstruction
                    {
                        Cursor = false,
                        Delay  = Length,
                        Text   = previousFrame.Text
                    };

                    results.Add(newFrame2);
                }
            }
            else
            {
                var frameCount = Length / Delay;
                frameCount = frameCount % 2 == 0 ? frameCount : frameCount + 1;

                var newFrameTemplate = new DrawingInstruction
                {
                    Cursor = true,
                    Delay  = Delay,
                    Text   = previousFrame.Text
                };

                for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
                {
                    var on = frameIndex % 2 == 0;

                    var newFrame = on ? newFrameTemplate.Copy() : previousFrame.Copy();
                    results.Add(newFrame);
                }

                var lastFrame = new DrawingInstruction
                {
                    Cursor = false,
                    Delay  = Delay,
                    Text   = previousFrame.Text
                };

                results.Add(lastFrame);
            }

            return(results);
        }
Esempio n. 5
0
 public DrawingInstruction(Sprite sprite, int imageVariant, Vector2F position, Vector2F depthOrigin)
 {
     this.sprite       = sprite;
     this.position     = position;
     this.imageVariant = imageVariant;
     this.next         = null;
     this.depthOrigin  = depthOrigin;
 }
Esempio n. 6
0
        internal override IList <DrawingInstruction> CreateInstructions(ProjectInstructions projectInstructions, IList <ScriptedInstruction> script, IList <DrawingInstruction> currentInstructions)
        {
            var results  = new List <DrawingInstruction>();
            var newFrame = new DrawingInstruction
            {
                Cursor = false,
                Delay  = 1,
                Text   = string.Empty
            };

            results.Add(newFrame);

            return(results);
        }
Esempio n. 7
0
        // Draw all the queued drawing instructions to a graphics object.
        public void DrawAll(Graphics2D g)
        {
            // Draw all instructions from the lowest layer to the highest layer.
            for (int i = 0; i < layerHeads.Length; i++)
            {
                DrawingInstruction instruction = layerHeads[i];

                while (instruction != null)
                {
                    g.DrawSprite(instruction.sprite,
                                 instruction.imageVariant,
                                 instruction.position.X,
                                 instruction.position.Y);
                    instruction = instruction.next;
                }
            }
        }
Esempio n. 8
0
        // Sort a depth layer. Sprites with smaller y coordinates
        // will be drawn before ones with larger y coordinates.
        public void SortDepthLayer(DepthLayer layer)
        {
            // Check if the layer is empty.
            int layerIndex = (int)layer;

            if (layerHeads[layerIndex] == null)
            {
                return;
            }

            // Create a list of the drawing instructions.
            List <DrawingInstruction> instructions = new List <DrawingInstruction>(layerCounts[layerIndex]);
            DrawingInstruction        instruction  = layerHeads[layerIndex];

            while (instruction != null)
            {
                instructions.Add(instruction);
                instruction = instruction.next;
            }

            // Sort the list by depth origin Y.
            instructions.Sort(delegate(DrawingInstruction a, DrawingInstruction b) {
                if (Math.Round(a.depthOrigin.Y) < Math.Round(b.depthOrigin.Y))
                {
                    return(-1);
                }
                return(1);
            });

            // Update the drawing instruction linked list.
            layerHeads[layerIndex] = instructions[0];
            layerTails[layerIndex] = instructions[instructions.Count - 1];
            for (int i = 0; i < instructions.Count; i++)
            {
                if (i + 1 < instructions.Count)
                {
                    instructions[i].next = instructions[i + 1];
                }
                else
                {
                    instructions[i].next = null;
                }
            }
        }
Esempio n. 9
0
        internal override IList <DrawingInstruction> CreateInstructions(ProjectInstructions projectInstructions, IList <ScriptedInstruction> script, IList <DrawingInstruction> currentInstructions)
        {
            var results = new List <DrawingInstruction>();

            for (var textIndex = 0; textIndex < Text.Length; textIndex++)
            {
                var previousFrame = results.Count == 0
                                        ? PreviousFrame(currentInstructions)
                                        : results[results.Count - 1];

                var current = string.Concat(previousFrame.Text, Text[textIndex]);

                var newFrame = new DrawingInstruction
                {
                    Cursor = projectInstructions.DrawCursor,
                    Delay  = Delay,
                    Text   = current
                };

                results.Add(newFrame);
            }

            if (projectInstructions.DrawCursor)
            {
                var previousFrame = results[results.Count - 1];
                var lastFrame     = new DrawingInstruction
                {
                    Cursor = false,
                    Delay  = Delay,
                    Text   = previousFrame.Text
                };

                results.Add(lastFrame);
            }

            return(results);
        }
Esempio n. 10
0
        // Draw a sprite.
        public void DrawSprite(Sprite sprite, int imageVariant, Vector2F position, DepthLayer depth, Vector2F depthOrigin)
        {
            // There's a bias of 0.001f to account for rounding inconsistancies with the value 0.5f.
            position.X = GMath.Round(position.X + 0.001f);
            position.Y = GMath.Round(position.Y + 0.001f);

            DrawingInstruction instruction = new DrawingInstruction(
                sprite, imageVariant, position, depthOrigin);

            // Add the instruction to the end of the linked list for its layer.
            int layerIndex = (int)depth;

            if (layerHeads[layerIndex] == null)
            {
                layerHeads[layerIndex] = instruction;
                layerTails[layerIndex] = instruction;
            }
            else
            {
                layerTails[layerIndex].next = instruction;
                layerTails[layerIndex]      = instruction;
            }
            layerCounts[layerIndex]++;
        }
Esempio n. 11
0
 public DrawingInstruction(Sprite sprite, int imageVariant, Vector2F position, Vector2F depthOrigin)
 {
     this.sprite			= sprite;
     this.position		= position;
     this.imageVariant	= imageVariant;
     this.next			= null;
     this.depthOrigin	= depthOrigin;
 }
Esempio n. 12
0
        // Draw a sprite.
        public void DrawSprite(Sprite sprite, int imageVariant, Vector2F position, DepthLayer depth, Vector2F depthOrigin)
        {
            // There's a bias of 0.001f to account for rounding inconsistancies with the value 0.5f.
            position.X = GMath.Round(position.X + 0.001f);
            position.Y = GMath.Round(position.Y + 0.001f);

            DrawingInstruction instruction = new DrawingInstruction(
                    sprite, imageVariant, position, depthOrigin);

            // Add the instruction to the end of the linked list for its layer.
            int layerIndex = (int) depth;
            if (layerHeads[layerIndex] == null) {
                layerHeads[layerIndex] = instruction;
                layerTails[layerIndex] = instruction;
            }
            else {
                layerTails[layerIndex].next = instruction;
                layerTails[layerIndex] = instruction;
            }
            layerCounts[layerIndex]++;
        }