public void buildBehaviorTree()
    {
        Task[] tasks = new Task[2];

        tasks[0] = new DoorUnlocked(door);
        tasks[1] = new OpenDoor(door);
        Task sequence = new Sequence(tasks);

        tasks    = new Task[2];
        tasks[0] = new DoorClosed(door);
        tasks[1] = new BargeDoor(door);
        Task sequence2 = new Sequence(tasks);

        tasks    = new Task[2];
        tasks[0] = sequence;
        tasks[1] = sequence2;
        Task selector = new Selector(tasks);

        tasks    = new Task[2];
        tasks[0] = new DoorOpen(door);
        tasks[1] = new MoveRoom(this.transform);
        sequence = new Sequence(tasks);

        tasks     = new Task[3];
        tasks[0]  = new MoveDoor(this.transform);
        tasks[1]  = selector;
        tasks[2]  = new MoveRoom(this.transform);
        sequence2 = new Sequence(tasks);

        tasks    = new Task[2];
        tasks[0] = sequence;
        tasks[1] = sequence2;

        task = new Selector(tasks);
    }
Beispiel #2
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,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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;
                    }
                }
            }
        }