Esempio n. 1
0
 public World()
 {
     loadMap = new FTmxMap();
     loadMap.LoadTMX("Maps/loadMap");
     FTilemap loadMapBG = ((FTilemap)loadMap.getLayerNamed("background"));
     loadMapBG.clipNode = C.getCameraInstance();
     loadMapBG.repeatX = true;
     loadMapBG.repeatY = true;
     this.AddChild(loadMap);
     this.AddChild(backgroundLayer);
     this.AddChild(playerLayer);
     this.AddChild(foregroundLayer);
     playerLayer.shouldSortByZ = true;
     Futile.instance.SignalUpdate += OnUpdate;
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        FutileParams fparams = new FutileParams(true, true, false, false);
        fparams.AddResolutionLevel(480.0f, 2.0f, 1.0f, "");
        fparams.origin = new Vector2(0.5f, 0.5f);
        fparams.backgroundColor = new Color(0.15f, 0.15f, 0.3f);
        Futile.instance.Init(fparams);

        // load image atlas (within Resources/Atlases folder)
        Futile.atlasManager.LoadAtlas("Atlases/Burglar");

        // Add tilemap
        FTmxMap tmx1 = new FTmxMap();
        tmx1.x = -120;
        tmx1.y = 80;
        tmx1.LoadTMX("CSVs/testTmx"); // load tmx text file (within Resources/CSVs folder)
        Futile.stage.AddChild(tmx1);

        // create burglar
        burglar = new FAnimatedSprite("Burglar");
        burglar.y = -44;
        int[] frames = { 1,1,2,1,1,1,10,1,11,1 }; // idle anim
        burglar.addAnimation(new FAnimation("idle", frames, 400, true));
        int[] frames2 = { 3,4,5,6,4,7 }; // run anim
        burglar.addAnimation(new FAnimation("run", frames2, 180, true));
        Futile.stage.AddChild(burglar); // add burglar to stage

        // load font atlas
        Futile.atlasManager.LoadAtlas("Atlases/Fonts");

        // Add large font text
        Futile.atlasManager.LoadFont("Large", "Large Font", "Atlases/Large Font", 0, 0);
        FLabel label1 = new FLabel("Large", "LARGE FONT");
        label1.y = 26;
        Futile.stage.AddChild(label1);

        // Add small font text
        Futile.atlasManager.LoadFont("Small", "Small Font", "Atlases/Small Font", 0, 0);
        FLabel label2 = new FLabel("Small", "Small Font");
        label2.y = 12;
        Futile.stage.AddChild(label2);

        // Add tiny font text
        Futile.atlasManager.LoadFont("Tiny", "Tiny Font", "Atlases/Tiny Font", 0, 0);
        FLabel label3 = new FLabel("Tiny", "Tiny Font");
        label3.y = 3;
        Futile.stage.AddChild(label3);
    }
Esempio n. 3
0
    public World()
    {
        map = new FTmxMap();

        playerLayer.shouldSortByZ = true;

        this.AddChild(background);
        this.AddChild(playerLayer);
        this.AddChild(foreground);
        Futile.instance.SignalUpdate += Update;
        loadingBG = new FSprite("loadingBG");
        loadingBG.isVisible = false;
        loadingBG.x = -Futile.screen.halfWidth - loadingBG.width / 2;

        C.getCameraInstance().AddChild(loadingBG);
        ui = new UI();
    }
Esempio n. 4
0
    public void LoadMap(string mapName)
    {
        GetEnemyCounts();
        map = new FTmxMap();
        objects.Clear();
        spawnPoints.Clear();
        enemySpawns.Clear();
        backgroundLayer.RemoveAllChildren();
        foregroundLayer.RemoveAllChildren();
        playerLayer.RemoveAllChildren();
        map.LoadTMX("Maps/" + mapName);
        backgroundTilemap = (FTilemap)map.getLayerNamed("background");
        collisionTilemap = (FTilemap)map.getLayerNamed("collision");
        foregroundTilemap = (FTilemap)map.getLayerNamed("foreground");

        backgroundTilemap.clipNode = C.getCameraInstance();
        collisionTilemap.clipNode = C.getCameraInstance();
        foregroundTilemap.clipNode = C.getCameraInstance();

        if (p == null)
        {
            p = new Player(this);
            ui = new UI(this);
            C.getCameraInstance().AddChild(ui);
        }

        backgroundLayer.AddChild(backgroundTilemap);
        backgroundLayer.AddChild(collisionTilemap);
        foregroundLayer.AddChild(foregroundTilemap);
        playerLayer.AddChild(p);

        MapLoader.loadObjects(this, map.objects);

        SpawnPlayer(p);
    }
Esempio n. 5
0
    public void LoadMap(string mapName)
    {
        C.Save.lastMap = mapName;
        spawnPoints.Clear();
        signs.Clear();
        villagers.Clear();
        hitSwitches.Clear();
        collisionObjects.Clear();
        damageObjects.Clear();

        playerLayer.RemoveAllChildren();
        background.RemoveAllChildren();
        foreground.RemoveAllChildren();
        this.map = new FTmxMap();
        this.map.LoadTMX("Maps/" + mapName);

        FSoundManager.PlayMusic(map.mapMusic);

        collisionTilemap = (FTilemap)this.map.getLayerNamed("collision");
        wallCollisionTilemap = (FTilemap)this.map.getLayerNamed("walls");
        backgroundTilemap = (FTilemap)this.map.getLayerNamed("background");
        foregroundTilemap = (FTilemap)this.map.getLayerNamed("foreground");
        background.AddChild(backgroundTilemap);
        background.AddChild(collisionTilemap);
        background.AddChild(wallCollisionTilemap);
        foreground.AddChild(foregroundTilemap);

        if (player == null)
        {
            player = new Player(this);
            C.getCameraInstance().follow(player);
            player.LoadLastSave();
        }
        collisionObjects.Add(player);
        playerLayer.AddChild(player);
        this.y = -16;
        C.getCameraInstance().setWorldBounds(new Rect(0, -collisionTilemap.height - 16, collisionTilemap.width, collisionTilemap.height + 16));
        foregroundTilemap.clipNode = C.getCameraInstance();
        collisionTilemap.clipNode = C.getCameraInstance();
        wallCollisionTilemap.clipNode = C.getCameraInstance();
        backgroundTilemap.clipNode = C.getCameraInstance();

        MapLoader.loadObjects(this, map.objects);
    }