Example #1
0
 public Texture(uint id, float width, float height, int tileSize, int tileSize2, string name, TextureProgram program, uint vao, uint vbo)
 {
     ID            = id;
     Width         = width;
     Height        = height;
     TileSizeX     = tileSize;
     TileSizeY     = tileSize2;
     Name          = name;
     Program       = program;
     baseVAO       = vao;
     baseVBO       = vbo;
     BaseTexMatrix = Matrix4x4f.Scaled(tileSize / width, tileSize2 / height, 1f);
 }
Example #2
0
 public BGSpriteCollection(Texture texture, Game game)
 {
     Color           = Color.White;
     BaseColor       = Color.White;
     BackgroundColor = Color.Black;
     Texture         = texture;
     program         = texture.Program;
     buffer          = new float[] { };
     texMatrix       = Matrix4x4f.Scaled(texture.TileSizeX / texture.Width, texture.TileSizeY / texture.Height, 1f);
     save            = new JArray();
     owner           = game;
     Width           = Game.RESOLUTION_WIDTH;
     Height          = Game.RESOLUTION_HEIGHT;
 }
Example #3
0
        public void Load(JToken loadFrom, Game game)
        {
            string name = (string)loadFrom["Name"] ?? "";

            if (name == Name)
            {
                return;
            }
            Name    = name;
            Texture = game.TextureFromName((string)loadFrom["Texture"] ?? "");
            program = Texture.Program;
            Clear();
            texMatrix = Matrix4x4f.Scaled(Texture.TileSizeX / Texture.Width, Texture.TileSizeY / Texture.Height, 1f);
            save      = new JArray();
            float mx = (float)(loadFrom["XSpeed"] ?? 1);
            float my = (float)(loadFrom["YSpeed"] ?? 0);

            MovementSpeed    = new PointF(mx, my);
            BaseColor        = Color.FromArgb((int)(loadFrom["Color"] ?? -1));
            InheritRoomColor = (bool)(loadFrom["InheritColor"] ?? false);
            JArray objs = (JArray)loadFrom["Objects"];

            for (int i = 0; i < objs.Count; i++)
            {
                switch ((string)objs[i]["Type"])
                {
                case "Fill":
                {
                    Animation animation = Texture.AnimationFromName((string)objs[i]["Animation"] ?? "");
                    if (animation is object)
                    {
                        Fill(animation);
                    }
                }
                break;

                case "Distribute":
                {
                    Animation animation = Texture.AnimationFromName((string)objs[i]["Animation"]);
                    if (animation is object)
                    {
                        float x   = (float)(objs[i]["StartX"] ?? 0f);
                        float y   = (float)(objs[i]["StartY"] ?? 0f);
                        float stx = (float)(objs[i]["StrideX"] ?? 0f);
                        float sty = (float)(objs[i]["StrideY"] ?? 0f);
                        int   amx = (int)(objs[i]["AmountX"] ?? 0);
                        int   amy = (int)(objs[i]["AmountY"] ?? 0);
                        Distribute(animation, new PointF(x, y), new PointF(stx, sty), new Point(amx, amy));
                    }
                }
                break;

                case "Populate":
                {
                    int    count = (int)(objs[i]["Count"] ?? 1);
                    JArray anims = (JArray)objs[i]["Options"];
                    if (anims is object)
                    {
                        Animation[] options = new Animation[anims.Count];
                        for (int j = 0; j < anims.Count; j++)
                        {
                            options[j] = Texture.AnimationFromName((string)anims[j] ?? "");
                        }
                        float layer  = (float)(objs[i]["Layer"] ?? 1);
                        float xSpeed = (float)(objs[i]["XSpeed"] ?? 1);
                        float ySpeed = (float)(objs[i]["YSpeed"] ?? 0);
                        bool  even   = (bool)(objs[i]["Even"] ?? true);
                        Populate(count, options, layer, new PointF(xSpeed, ySpeed), even);
                    }
                }
                break;

                case "Scatter":
                {
                    int       count     = (int)(objs[i]["Count"] ?? 1);
                    Animation animation = Texture.AnimationFromName((string)objs[i]["Animation"] ?? "");
                    float     speed     = (float)(objs[i]["Speed"] ?? 1);
                    Scatter(count, animation, speed);
                }
                break;
                }
            }
        }
Example #4
0
 public MultipleTextures(TextureProgram parent)
 {
     this.parent = parent;
 }