Esempio n. 1
0
        public IEnumerable <PointRadius> GetPathBetweenIndex(int i0, int i1)
        {
            var points = new List <PointRadius>();

            points.Add(new PointRadius()
            {
                Point = new Vector3(Center.X, Center.Y, 0),
                Color = StartColor
            });

            for (int i = i0 + 1; i < i1; i++)
            {
                var prev = (SLOTS + i - 1) % SLOTS;

                Vector3 p0;
                Vector3 p1;

                {
                    var ray  = s_rays[i];
                    var slot = m_slots[prev];
                    var x    = ray.X * slot.Radius + Center.X;
                    var y    = ray.Y * slot.Radius + Center.Y;

                    p0 = new Vector3(x, y, 0);
                }

                {
                    var ray  = s_rays[i];
                    var slot = m_slots[i];
                    var x    = ray.X * slot.Radius + Center.X;
                    var y    = ray.Y * slot.Radius + Center.Y;

                    p1 = new Vector3(x, y, 0);
                }

                if (p0 != p1)
                {
                    points.Add(new PointRadius()
                    {
                        Point = p0,
                        Color = Color4ub.Mix(StartColor, EndColor, (m_slots[prev].Radius / Radius))
                    });
                    points.Add(new PointRadius()
                    {
                        Point = p1,
                        Color = Color4ub.Mix(StartColor, EndColor, (m_slots[i].Radius / Radius))
                    });
                }
                else
                {
                    points.Add(new PointRadius()
                    {
                        Point = p0,
                        Color = Color4ub.Mix(StartColor, EndColor, (m_slots[prev].Radius / Radius))
                    });
                }
            }

            return(points);
        }
Esempio n. 2
0
        public void AddBlood(BloodType type, Vector2 position, Vector2 direction, Color4ub? color = null)
        {
            //Eclaboussure
            Blood blood = null;

            switch (type)
            {
                case BloodType.A:
                    blood = new Blood1();
                    break;
                case BloodType.B:
                    blood = new Blood2();
                    break;
                case BloodType.C:
                    blood = new Blood3();
                    break;
                case BloodType.D:
                    blood = new Blood4();
                    break;
            }

            blood.SetPosition(position);
            blood.SetDirection(direction);
            blood.SetColor(color);
            AddBlood(blood);

            //Sang sur le sol
            blood = new BloodFloor1();
            blood.SetPosition(position);
            var angle = (float)Math.Atan2(direction.Y, direction.X);
            blood.SetDirection(angle + (float)((RandomGenerator.Instance.Random.NextDouble() * 2) - 1));
            blood.SetColor(color);
            AddStaticBlood(blood);
        }
Esempio n. 3
0
 public void Draw(Graphics graphics, Color4ub color)
 {
     foreach (var instance in m_instances)
     {
         graphics.Draw(instance.Rectangle, instance.Sprite, color);
     }
 }
Esempio n. 4
0
 public static Color4ub Next(this Random random, Color4ub min, Color4ub max)
 {
     return new Color4ub(
         (byte)random.Next(min.R, max.R + 1),
         (byte)random.Next(min.G, max.G + 1),
         (byte)random.Next(min.B, max.B + 1),
         (byte)random.Next(min.A, max.A + 1)
     );
 }
Esempio n. 5
0
 public Triangle(Vector3 p1, Vector3 p2, Vector3 p3)
 {
     P1      = p1;
     P2      = p2;
     P3      = p3;
     ColorP1 = new Color4ub(255, 255, 0, 255);
     ColorP2 = new Color4ub(255, 255, 0, 255);
     ColorP3 = new Color4ub(255, 255, 0, 255);
 }
Esempio n. 6
0
 public Triangle(Vector3 p1, Vector3 p2, Vector3 p3)
 {
     P1 = p1;
     P2 = p2;
     P3 = p3;
     ColorP1 = new Color4ub(255, 255, 0, 255);
     ColorP2 = new Color4ub(255, 255, 0, 255);
     ColorP3 = new Color4ub(255, 255, 0, 255);
 }
Esempio n. 7
0
 public Triangle(Vector3 p1, Vector3 p2, Vector3 p3,
                 Color4ub colorP1, Color4ub colorP2, Color4ub colorP3)
 {
     P1      = p1;
     P2      = p2;
     P3      = p3;
     ColorP1 = colorP1;
     ColorP2 = colorP2;
     ColorP3 = colorP3;
 }
Esempio n. 8
0
 public Triangle(Vector3 p1, Vector3 p2, Vector3 p3,
     Color4ub colorP1, Color4ub colorP2, Color4ub colorP3)
 {
     P1 = p1;
     P2 = p2;
     P3 = p3;
     ColorP1 = colorP1;
     ColorP2 = colorP2;
     ColorP3 = colorP3;
 }
Esempio n. 9
0
        public void AddSpriteSequence(SpriteSequence sequence, Vector2 position, Vector2i size, string layer, Color4ub? color = null)
        {
            var ro = new RenderObject()
            {
                SpriteSequence = sequence,
                Position = new Vector2[] { position },
                Size = size,
                Color = color.HasValue ? color.Value : new Color4ub(255, 255, 255, 255)
            };

            m_renderObjects[GetLayerId(layer)].Add(ro);
        }
Esempio n. 10
0
 public Light(Vector2 position, float radius, Color4ub startColor, Color4ub endColor)
 {
     m_position = position;
     m_light    = new Cone(
         position,
         radius,
         (float)Math.PI * 2f,
         startColor,
         endColor,
         0
         );
 }
Esempio n. 11
0
 public Light(Vector2 position, float radius, Color4ub startColor, Color4ub endColor)
 {
     m_position = position;
     m_light = new Cone(
         position,
         radius,
         (float)Math.PI * 2f,
         startColor,
         endColor,
         0
         );
 }
Esempio n. 12
0
        public Cone(Vector2 p, float radius, float angle, Color4ub startColor, Color4ub endColor, float startAngle = 0)
        {
            Center = p;
            Radius = radius;
            Angle = angle;
            StartAngle = startAngle;
            StartColor = startColor;
            EndColor = endColor;

            m_slots = new Slot[SLOTS];
            Clear();
        }
Esempio n. 13
0
        public Cone(Vector2 p, float radius, float angle, float startAngle = 0)
        {
            Center = p;
            Radius = radius;
            Angle = angle;
            StartAngle = startAngle;
            StartColor = new Color4ub(0, 0, 255, 255);
            EndColor = new Color4ub(0, 0, 255, 255);

            m_slots = new Slot[SLOTS];
            Clear();
        }
Esempio n. 14
0
        public Ennemy()
        {
            m_location = new LocationComponent(this);
            m_move = new MoveComponent(this, m_location);
            m_rigidBody = new RigidBodyComponent(this, m_location);
            m_life = new LifeComponent(this, 50);

            var r = (byte)RandomGenerator.Instance.Random.Next(0, 255);
            var g = (byte)RandomGenerator.Instance.Random.Next(0, 255);
            var b = (byte)RandomGenerator.Instance.Random.Next(0, 255);
            m_bloodColor = new Color4ub(r, g, b, 255);
        }
Esempio n. 15
0
        public Cone(Vector2 p, float radius, float angle, Color4ub startColor, Color4ub endColor, float startAngle = 0)
        {
            Center     = p;
            Radius     = radius;
            Angle      = angle;
            StartAngle = startAngle;
            StartColor = startColor;
            EndColor   = endColor;

            m_slots = new Slot[SLOTS];
            Clear();
        }
Esempio n. 16
0
        public Cone(Vector2 p, float radius, float angle, float startAngle = 0)
        {
            Center     = p;
            Radius     = radius;
            Angle      = angle;
            StartAngle = startAngle;
            StartColor = new Color4ub(0, 0, 255, 255);
            EndColor   = new Color4ub(0, 0, 255, 255);

            m_slots = new Slot[SLOTS];
            Clear();
        }
Esempio n. 17
0
        public Ennemy()
        {
            m_location  = new LocationComponent(this);
            m_move      = new MoveComponent(this, m_location);
            m_rigidBody = new RigidBodyComponent(this, m_location);
            m_life      = new LifeComponent(this, 50);

            var r = (byte)RandomGenerator.Instance.Random.Next(0, 255);
            var g = (byte)RandomGenerator.Instance.Random.Next(0, 255);
            var b = (byte)RandomGenerator.Instance.Random.Next(0, 255);

            m_bloodColor = new Color4ub(r, g, b, 255);
        }
Esempio n. 18
0
 public Particle(Texture2D texture, Vector2 position, Vector2 velocity,
     float angle, float angularVelocity, Color4ub color, float size, int ttl)
 {
     Texture = texture;
     Position = position;
     Velocity = velocity;
     Angle = angle;
     AngularVelocity = angularVelocity;
     Color = color;
     Size = size;
     TTL = ttl;
     TTLMax = ttl;
 }
Esempio n. 19
0
        public void Draw(Vector2 position, Font font, string text, Color4ub color)
        {
            foreach (var c in text)
            {
                var glyph = font.GetGlyph(c);

                if (glyph != null)
                {
                    Draw(new Box2(position, glyph.Size), glyph.Sprite, color);
                    position = new Vector2(position.X + glyph.Size.X, position.Y);
                }
            }
        }
        public IPointInstance AddVertex(Vector3 position, Color4ub color)
        {
            var instance = new PointInstance(this);

            instance.P = position;
            instance.Color = color;

            lock (m_instances)
            {
                m_instances.Add(instance);
            }

            return instance;
        }
        public IPointInstance AddVertex(Vector3 position, Color4ub color)
        {
            var instance = new PointInstance(this);

            instance.P     = position;
            instance.Color = color;

            lock (m_instances)
            {
                m_instances.Add(instance);
            }

            return(instance);
        }
Esempio n. 22
0
        public Shoot(Vector2 position, Vector2 direction, Color4ub startColor, Color4ub endColor, float angle = 2, float radius = 2)
        {
            m_location = new LocationComponent(this);
            m_location.SetPosition(position);

            m_cone = new Cone(
                position,
                radius,
                angle,
                startColor,
                endColor,
                (float)((Math.Atan2(direction.Y, direction.X) + Math.PI * 2) - (angle / 2.0) - Math.PI * 2)
                );

            m_lifeTimeTotal = 0.2;
            m_lifeTime      = m_lifeTimeTotal;
        }
Esempio n. 23
0
        public Shoot(Vector2 position, Vector2 direction, Color4ub startColor, Color4ub endColor, float angle = 2, float radius = 2)
        {
            m_location = new LocationComponent(this);
            m_location.SetPosition(position);

            m_cone = new Cone(
                position,
                radius,
                angle,
                startColor,
                endColor,
                (float)((Math.Atan2(direction.Y, direction.X) + Math.PI*2) - (angle / 2.0) - Math.PI*2)
                );

            m_lifeTimeTotal = 0.2;
            m_lifeTime = m_lifeTimeTotal;
        }
Esempio n. 24
0
        public void Draw(Box2 rectangle, Color4ub color)
        {
            if (m_queueSize == m_queueCapacity)
            {
                Flush();
            }

            m_queue[m_queueSize++] = new QuadData()
            {
                Transform = new Matrix3x2(
                    m_transform.M00 * rectangle.Size.X,
                    m_transform.M01 * rectangle.Size.X,

                    m_transform.M10 * rectangle.Size.Y,
                    m_transform.M11 * rectangle.Size.Y,

                    m_transform.M00 * rectangle.Position.X + m_transform.M10 * rectangle.Position.Y + m_transform.M20,
                    m_transform.M01 * rectangle.Position.X + m_transform.M11 * rectangle.Position.Y + m_transform.M21
                    ),
                Color   = color,
                Texture = -1
            };
        }
Esempio n. 25
0
 public UILabel()
 {
     Color = new Color4ub(0x00, 0x00, 0x00, 0xFF);
 }
Esempio n. 26
0
 public void Draw(Box2 rectangle, Sprite sprite, Color4ub color)
 {
     Draw(rectangle, sprite.Texture, sprite.TextureCoordinates0, sprite.TextureCoordinates1, color);
 }
Esempio n. 27
0
 public UILabel()
 {
     Color = new Color4ub(0x00, 0x00, 0x00, 0xFF);
 }
Esempio n. 28
0
        public void Draw(Box2 rectangle, Texture2D texture, Vector2 textureCoordinates0, Vector2 textureCoordinates1, Color4ub color)
        {
            if (m_queueSize == m_queueCapacity)
            {
                Flush();
            }

            m_queue[m_queueSize++] = new QuadData()
            {
                Transform = new Matrix3x2(
                    m_transform.M00 * rectangle.Size.X,
                    m_transform.M01 * rectangle.Size.X,

                    m_transform.M10 * rectangle.Size.Y,
                    m_transform.M11 * rectangle.Size.Y,

                    m_transform.M00 * rectangle.Position.X + m_transform.M10 * rectangle.Position.Y + m_transform.M20,
                    m_transform.M01 * rectangle.Position.X + m_transform.M11 * rectangle.Position.Y + m_transform.M21
                ),
                Color = color,
                Texture = (sbyte)GetTextureIndex(texture),
                TextureCoordinates0 = textureCoordinates0,
                TextureCoordinates1 = textureCoordinates1
            };
        }
Esempio n. 29
0
 public Segment(Vector2 p1, Vector2 p2, Color4ub color)
 {
     P1 = p1;
     P2 = p2;
     Color = color;
 }
Esempio n. 30
0
        public void Draw(Vector2 position, Font font, string text, Color4ub color)
        {
            foreach (var c in text)
            {
                var glyph = font.GetGlyph(c);

                if (glyph != null)
                {
                    Draw(new Box2(position, glyph.Size), glyph.Sprite, color);
                    position = new Vector2(position.X + glyph.Size.X, position.Y);
                }
            }
        }
Esempio n. 31
0
        public void Draw(Box2 rectangle, Color4ub color)
        {
            if (m_queueSize == m_queueCapacity)
            {
                Flush();
            }

            m_queue[m_queueSize++] = new QuadData()
            {
                Transform = new Matrix3x2(
                    m_transform.M00 * rectangle.Size.X,
                    m_transform.M01 * rectangle.Size.X,

                    m_transform.M10 * rectangle.Size.Y,
                    m_transform.M11 * rectangle.Size.Y,

                    m_transform.M00 * rectangle.Position.X + m_transform.M10 * rectangle.Position.Y + m_transform.M20,
                    m_transform.M01 * rectangle.Position.X + m_transform.M11 * rectangle.Position.Y + m_transform.M21
                ),
                Color = color,
                Texture = -1
            };
        }
Esempio n. 32
0
 public Segment(Vector2 p1, Vector2 p2, Color4ub color)
 {
     P1    = p1;
     P2    = p2;
     Color = color;
 }
Esempio n. 33
0
 public void SetColor(Color4ub? color)
 {
     m_color = color;
 }
Esempio n. 34
0
        public IEnumerable <PointRadius> GetPath()
        {
            var points = new List <PointRadius>();

            points.Add(new PointRadius()
            {
                Point = new Vector3(Center.X, Center.Y, 0),
                Color = StartColor
            });

            var i0 = 0;
            var i1 = SLOTS;

            if (Angle < PI_2)
            {
                i0 = (int)(Math.Floor(((StartAngle + PI_2) % PI_2) / SLOT_ANGLE));
                i1 = (int)(Math.Ceiling(((StartAngle + Angle + PI_2) % PI_2) / SLOT_ANGLE));
            }


            for (int i = i0; i < i1; i++)
            {
                var prev = (SLOTS + i - 1) % SLOTS;

                if (m_slots[i].Segment != m_slots[prev].Segment)
                {
                    Vector3 p0;
                    Vector3 p1;

                    {
                        var ray  = s_rays[i];
                        var slot = m_slots[prev];
                        var x    = ray.X * slot.Radius + Center.X;
                        var y    = ray.Y * slot.Radius + Center.Y;

                        p0 = new Vector3(x, y, 0);
                    }

                    {
                        var ray  = s_rays[i];
                        var slot = m_slots[i];
                        var x    = ray.X * slot.Radius + Center.X;
                        var y    = ray.Y * slot.Radius + Center.Y;

                        p1 = new Vector3(x, y, 0);
                    }

                    if (p0 != p1)
                    {
                        points.Add(new PointRadius()
                        {
                            Point = p0,
                            Color = Color4ub.Mix(StartColor, EndColor, (m_slots[prev].Radius / Radius))
                        });
                        points.Add(new PointRadius()
                        {
                            Point = p1,
                            Color = Color4ub.Mix(StartColor, EndColor, (m_slots[i].Radius / Radius))
                        });
                    }
                    else
                    {
                        points.Add(new PointRadius()
                        {
                            Point = p0,
                            Color = Color4ub.Mix(StartColor, EndColor, (m_slots[prev].Radius / Radius))
                        });
                    }
                }
            }

            if (Angle >= PI_2)
            {
                points.Add(points[1]);
            }

            return(points);
        }
Esempio n. 35
0
 public void Draw(Graphics graphics, Color4ub color)
 {
     foreach (var instance in m_instances)
     {
         graphics.Draw(instance.Rectangle, instance.Sprite, color);
     }
 }
Esempio n. 36
0
        private Particle GenerateNewParticle()
        {
            Texture2D texture = null;// textures[random.Next(textures.Count)];
            Vector2 position = EmitterLocation;
            Vector2 velocity = new Vector2(m_velocity.X + (float)random.Next(-10, 10), m_velocity.Y);

            float angle = 0;
            float angularVelocity = 1f * (float)(random.NextDouble() * 2 - 1);
            Color4ub color = new Color4ub(
                        (byte)random.Next(80, 100),
                        (byte)random.Next(30, 50),
                        (byte)random.Next(10, 25),
                        1);
            float size = m_size * (float)random.NextDouble();
            int ttl = m_ttl + random.Next((int)(m_ttl * 0.4));

            return new Particle(texture, position, velocity, angle, angularVelocity, color, size, ttl);
        }
Esempio n. 37
0
        static InternalFonts()
        {
            s_texture = new Lazy <Texture2D>(() =>
            {
                var bytes = new byte[c_width * c_height];

                using (var mstream = new MemoryStream(s_bytes))
                {
                    using (var cstream = new GZipStream(mstream, CompressionMode.Decompress))
                    {
                        cstream.Read(bytes, 0, bytes.Length);
                    }
                }

                var pixels = new Color4ub[c_width * c_height * 4];

                for (int i = 0; i < c_width * c_height; i++)
                {
                    pixels[i] = new Color4ub(0xFF, 0xFF, 0xFF, bytes[i]);
                }

                var texture = new Texture2D();
                texture.SetData(c_width, c_height, pixels);
                return(texture);
            });

            s_regularSmallVariableWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularSmallVariableWidthFontGlyphs);

                return(font);
            });

            s_boldSmallVariableWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_boldSmallVariableWidthFontGlyphs);

                return(font);
            });

            s_italicSmallVariableWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_italicSmallVariableWidthFontGlyphs);

                return(font);
            });

            s_regularBigVariableWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularBigVariableWidthFontGlyphs);

                return(font);
            });

            s_regularSmallFixedWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularSmallFixedWidthFontGlyphs);

                return(font);
            });

            s_boldSmallFixedWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_boldSmallFixedWidthFontGlyphs);

                return(font);
            });

            s_italicSmallFixedWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_italicSmallFixedWidthFontGlyphs);

                return(font);
            });

            s_regularBigFixedWidthFont = new Lazy <Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularBigFixedWidthFontGlyphs);

                return(font);
            });
        }
Esempio n. 38
0
        static InternalFonts()
        {
            s_texture = new Lazy<Texture2D>(() =>
            {
                var bytes = new byte[c_width * c_height];

                using (var mstream = new MemoryStream(s_bytes))
                {
                    using (var cstream = new GZipStream(mstream, CompressionMode.Decompress))
                    {
                        cstream.Read(bytes, 0, bytes.Length);
                    }
                }

                var pixels = new Color4ub[c_width * c_height * 4];

                for (int i = 0; i < c_width * c_height; i++)
                {
                    pixels[i] = new Color4ub(0xFF, 0xFF, 0xFF, bytes[i]);
                }

                var texture = new Texture2D();
                texture.SetData(c_width, c_height, pixels);
                return texture;
            });

            s_regularSmallVariableWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularSmallVariableWidthFontGlyphs);

                return font;
            });

            s_boldSmallVariableWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_boldSmallVariableWidthFontGlyphs);

                return font;
            });

            s_italicSmallVariableWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_italicSmallVariableWidthFontGlyphs);

                return font;
            });

            s_regularBigVariableWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularBigVariableWidthFontGlyphs);

                return font;
            });

            s_regularSmallFixedWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularSmallFixedWidthFontGlyphs);

                return font;
            });

            s_boldSmallFixedWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_boldSmallFixedWidthFontGlyphs);

                return font;
            });

            s_italicSmallFixedWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_italicSmallFixedWidthFontGlyphs);

                return font;
            });

            s_regularBigFixedWidthFont = new Lazy<Font>(() =>
            {
                var font = new Font(s_texture.Value, s_regularBigFixedWidthFontGlyphs);

                return font;
            });
        }
Esempio n. 39
0
 public Segment(Vector2 p1, Vector2 p2)
 {
     P1 = p1;
     P2 = p2;
     Color = new Color4ub(255, 0, 0, 255);
 }
Esempio n. 40
0
        public void AddTriangle(Vector2[] position, string layer, Vector2i? size = null, Color4ub? color = null)
        {
            var ro = new RenderObject()
            {
                Position = position,
                Size = size.HasValue ? size.Value : new Vector2i(1, 1),
                Color = color.HasValue ? color.Value : new Color4ub(255, 255, 255, 255)
            };

            m_renderObjects[GetLayerId(layer)].Add(ro);
        }
Esempio n. 41
0
        public void Draw(Box2 rectangle, Texture2D texture, Vector2 textureCoordinates0, Vector2 textureCoordinates1, Color4ub color)
        {
            if (m_queueSize == m_queueCapacity)
            {
                Flush();
            }

            m_queue[m_queueSize++] = new QuadData()
            {
                Transform = new Matrix3x2(
                    m_transform.M00 * rectangle.Size.X,
                    m_transform.M01 * rectangle.Size.X,

                    m_transform.M10 * rectangle.Size.Y,
                    m_transform.M11 * rectangle.Size.Y,

                    m_transform.M00 * rectangle.Position.X + m_transform.M10 * rectangle.Position.Y + m_transform.M20,
                    m_transform.M01 * rectangle.Position.X + m_transform.M11 * rectangle.Position.Y + m_transform.M21
                    ),
                Color               = color,
                Texture             = (sbyte)GetTextureIndex(texture),
                TextureCoordinates0 = textureCoordinates0,
                TextureCoordinates1 = textureCoordinates1
            };
        }
Esempio n. 42
0
 public void Draw(Box2 rectangle, Sprite sprite, Color4ub color)
 {
     Draw(rectangle, sprite.Texture, sprite.TextureCoordinates0, sprite.TextureCoordinates1, color);
 }
Esempio n. 43
0
 public Segment(Vector2 p1, Vector2 p2)
 {
     P1    = p1;
     P2    = p2;
     Color = new Color4ub(255, 0, 0, 255);
 }