Пример #1
0
 public AnimationClass Copy()
 {
     AnimationClass ac = new AnimationClass();
     ac.Rectangles = Rectangles;
     ac.Color = Color;
     ac.Origin = Origin;
     ac.Rotation = Rotation;
     ac.Scale = Scale;
     ac.IsLooping = IsLooping;
     ac.Frames = Frames;
     ac.texture = texture;
     return ac;
 }
Пример #2
0
        public AnimationClass Copy()
        {
            AnimationClass ac = new AnimationClass();

            ac.Rectangles = Rectangles;
            ac.Color      = Color;
            ac.Origin     = Origin;
            ac.Rotation   = Rotation;
            ac.Scale      = Scale;
            ac.IsLooping  = IsLooping;
            ac.Frames     = Frames;
            ac.texture    = texture;
            return(ac);
        }
Пример #3
0
        public void addAnimation(Texture2D texture,string name, int row, int frames, AnimationClass animation)
        {
            Rectangle[] recs = new Rectangle[frames];

            width = texture.Width / frames;
            height = texture.Height;
            for (int i = 0; i < frames; i++)
            {
                recs[i] = new Rectangle(i * width, (row - 1) * height, width, height);
            }
            animation.Frames = frames;
            animation.texture = texture;
            animation.Rectangles = recs;
            Animations.Add(name, animation);
        }
Пример #4
0
        public TestLevel(Texture2D texture,string mapname,Vector2 position)
        {
            this.mapname = mapname;
            this.position = position;

            switch (mapname)
            {
                case "map":
                    map = new int[,]
                    {
                                    /*items*/
                        // 1 = blok      // 3 = ladder  // 5 = item // 7 = schuif obj // 9 = falldoor button // 11
                        // 2 = steen     // 4 = button  // 6 = door // 8 = fall door // 10 = pressure plate

                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,1,0,1,0,1,0,3,0,0,0,0,0,0,0,1,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {1,1,1,1,0,0,0,0,0,10,0,10,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,3,0,0,0,6,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {1,1,1,1,11,0,0,0,1,1,1,1,3,1,1,1,1,1,1,1,0,0,4,0,0,0,1,0,1,1,1,3,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,3,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {1,1,1,1,0,0,0,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,6,0,0,0,1,0,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,4,1,0,1,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                        {1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,5,0,0,1,1,1,0,0,0,0,0,0,0,0,6,0,0,0,0,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,2,0,0,0,0,0},
                        {1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,5,0,9,0,0,0,0,1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0},
                        {1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,0,0,1,1,1,3,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                        {1,1,1,1,1,1,1,3,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,5,0,4,0,0,0,0,0,0,1,1,1,1,0,0,0,0,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                        {1,1,1,1,1,1,1,0,1,1,0,5,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,5,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                        {1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,0,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                        {1,1,1,1,1,1,1,0,5,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,1,1,1,1,1,1,1,5,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                        {1,1,1,1,1,1,1,1,1,1,1,0,0,0,4,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                    };
                    break;
            }

            buttons = new List<Door_button>();
            ladders = new List<Ladder>();
            stones = new List<Steen>();
            Tiles = new List<blok>();
            collectibles = new List<CollectItem>();
            doors = new List<Door>();
            moveObjects = new List<MoveObject>();
            Mdoors = new List<MoveDoor>();
            Mbuttons = new List<MoveDoorButton>();
            plates = new List<PressurePlate>();

            CheckRtiles = new List<blok>();
            CheckLtiles = new List<blok>();
            CheckBtiles = new List<blok>();

            this.tiletexture = texture;

            buttonIndex = 0;
            ladderIndex = 0;
            doorIndex = 0;

            center = new Vector2(this.Width / 2 * 44, this.Heigth / 2*44);
            SpawnNextlvl = false;

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Heigth; y++)
                {
                    //Assets in het Grid genereren
                    int textureIndex = map[y, x];
                    if (textureIndex == 0)
                        continue;
                    switch (textureIndex)
                    {
                        case 1:
                            blok tile = new blok(tiletexture, new Vector2(position.X + x * 44,position.Y + y * 44));
                            Tiles.Add(tile);
                            break;

                        case 2:
                            Steen steen = new Steen(Game1.crushstone,13, 1);
                            AnimationClass animate = new AnimationClass();
                            steen.position = new Vector2(position.X + x * 44, position.Y + y * 44);
                            steen.addAnimation(Game1.crushstone,"idle",1,13, animate.Copy());
                            steen.Animation = "idle";

                            stones.Add(steen);
                            break;

                        case 3:
                            Ladder ladder = new Ladder(Game1.laddertextures[ladderIndex], new Vector2(position.X + x * 44, position.Y + y * 44));
                            ladderIndex++;
                            ladders.Add(ladder);
                            break;

                        case 4:
                           Door_button button = new Door_button(Game1.button_tex, 12, 1, buttonIndex);
                            AnimationClass animate2 = new AnimationClass();
                            button.position = new Vector2(position.X + x * 44, position.Y + y * 44);
                            button.addAnimation(Game1.button_tex, "idle", 1, 12, animate2.Copy());
                            button.Animation = "idle";
                            buttonIndex++;
                            buttons.Add(button);
                            break;

                        case 5:
                            CollectItem item = new CollectItem(Game1.slaktex, 50, 1);
                            AnimationClass animate3 = new AnimationClass();
                            item.position = new Vector2(position.X + x * 44, position.Y + y * 44);
                            item.addAnimation(Game1.slaktex, "idle", 1, 50, animate3.Copy());
                            item.Animation = "idle";
                            collectibles.Add(item);
                            break;

                        case 6:
                            Door door = new Door(Game1.door_tex, new Vector2(position.X + x * 44, position.Y + y * 44), doorIndex);
                            doorIndex++;
                            doors.Add(door);
                            break;

                        case 7:
                            MoveObject obj = new MoveObject(Game1.stonetex,15, 1);
                            AnimationClass animate5 = new AnimationClass();
                            obj.position = new Vector2(position.X + x * 44, position.Y + y * 44);
                            obj.addAnimation(Game1.stonetex,"idle2",1, 15, animate5.Copy());
                            obj.Animation = "idle2";
                            moveObjects.Add(obj);
                            break;

                        case 8:
                            MoveDoor objdoor = new MoveDoor(Game1.fallStone, new Vector2(position.X + x * 44, position.Y + y * 44),moveDoorIndex);
                            moveDoorIndex++;
                            Mdoors.Add(objdoor);
                            break;

                        case 9:
                            MoveDoorButton button2 = new MoveDoorButton(Game1.button_tex,12, 1,moveButtonIndex);
                            AnimationClass animate6 = new AnimationClass();
                            button2.position = new Vector2(position.X + x * 44, position.Y + y * 44);
                            button2.addAnimation(Game1.button_tex, "idle", 1, 12, animate6.Copy());
                            button2.Animation = "idle";
                            moveButtonIndex++;
                            Mbuttons.Add(button2);
                            break;

                        case 10:
                            PressurePlate plate = new PressurePlate(Game1.pressureplate, new Vector2(position.X + x * 44, position.Y + y * 55));
                            plates.Add(plate);
                            break;

                        case 11:
                            liftobject = new LiftObject(Game1.liftobj, new Vector2(position.X + x * 44, position.Y + y * 44));
                            break;
                    }

                }
            }
        }
Пример #5
0
        public void LoadContent(ContentManager content)
        {
            //animaties inladen
            IdleAnimate = new AnimationClass();
            FramesPerSecond = 17;

            addAnimation(Game1.Hanstextures[0], "idle", 1, 11, IdleAnimate.Copy());
            addAnimation(Game1.Hanstextures[1], "walk", 1, 14, IdleAnimate.Copy());
            addAnimation(Game1.Hanstextures[2], "jump", 1, 6, IdleAnimate.Copy());

            position = new Vector2(3700, 600);
            spriteEffects = SpriteEffects.FlipHorizontally;
        }
Пример #6
0
        public void LoadContent(ContentManager content)
        {
            IdleAnimate = new AnimationClass();
            FramesPerSecond = 17;

            //Animaties
            addAnimation(Game1.Gretatextures[0], "walk", 1, 28, IdleAnimate.Copy());
            addAnimation(Game1.Gretatextures[1],"idle",1, 12, IdleAnimate.Copy());
            addAnimation(Game1.Gretatextures[2], "smash", 1, 24, IdleAnimate.Copy());
            addAnimation(Game1.Gretatextures[3], "jump", 1, 10, IdleAnimate.Copy());

            position = new Vector2(3700, 600);
        }
Пример #7
0
        public void addAnimation(Texture2D texture, string name, int row, int frames, AnimationClass animation)
        {
            //animatie toevoegen aan Dictionary
            Rectangle[] recs = new Rectangle[frames];

            width  = texture.Width / frames;
            height = texture.Height;
            for (int i = 0; i < frames; i++)
            {
                recs[i] = new Rectangle(i * width, (row - 1) * height, width, height);
            }
            animation.Frames     = frames;
            animation.texture    = texture;
            animation.Rectangles = recs;
            Animations.Add(name, animation);
        }