// 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");
        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");
        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");
        FLabel label3 = new FLabel("Tiny", "Tiny Font");

        label3.y = 3;
        Futile.stage.AddChild(label3);
    }
Пример #2
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;
 }
Пример #3
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);
    }
Пример #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);
    }
Пример #5
0
    public World(int level)
    {
        string beginningMessage = "";

        if (beginningMessages.Length > level)
        {
            beginningMessage = beginningMessages[level];
        }
        beginningLabel       = new FLabel("Large", beginningMessage);
        beginningLabel.alpha = 1.0f;
        beginningLabel.y     = -70;

        beginningLabelShadow       = new FLabel("Large", beginningMessage);
        beginningLabelShadow.color = Color.black;
        beginningLabelShadow.SetPosition(beginningLabel.GetPosition());

        beginningLabelShadow.x += 1;
        beginningLabelShadow.y += -1;


        this.currentLevelNum = level;
        string levelName = "Maps/map" + level;

        this.startNumPlayers = enemiesOnLevel[level];

        clock = new Clock();
        clock.enableSound();
        enemyClock = new EnemyClock();

        gui = new FCamObject();
        gui.AddChild(clock);
        gui.AddChild(enemyClock);

        setClock(clock);

        Futile.stage.AddChild(playerLayer);

        tmxMap.LoadTMX(levelName);
        tilemap = (FTilemap)(tmxMap.getLayerNamed("Tilemap"));

        FTilemap objectLayer = (FTilemap)(tmxMap.getLayerNamed("Objects"));

        for (int xInd = 0; xInd < objectLayer.widthInTiles; xInd++)
        {
            for (int yInd = 0; yInd < objectLayer.heightInTiles; yInd++)
            {
                switch (objectLayer.getFrameNum(xInd, yInd))
                {
                case 0:

                    break;

                case 10:
                    FNode newSpawn = new FNode();
                    newSpawn.x = xInd * tilemap._tileWidth + tilemap._tileWidth / 2;
                    newSpawn.y = -yInd * tilemap._tileHeight - tilemap._tileHeight / 2;
                    spawnPoints.Add(newSpawn);
                    break;

                case 11:
                    playerSpawn   = new FNode();
                    playerSpawn.x = xInd * tilemap._tileWidth + tilemap._tileWidth / 2;
                    playerSpawn.y = -yInd * tilemap._tileHeight - tilemap._tileHeight / 2;
                    break;
                }
            }
        }
        this.miniMap = new Minimap(this);
        playerLayer.AddChild(tmxMap);
        tilemap.clipNode = gui;

        Player player = new Player(true);

        gui.follow(player);
        addPlayer(player);
        player.setScale(2.0f, true);

        miniMap.setFollow(player);

        for (int ind = 0; ind < startNumPlayers; ind++)
        {
            Player p = new Player();
            addPlayer(p);
        }

        Futile.stage.AddChild(gui);

        gui.AddChild(new MuteMusicButton());
        gui.AddChild(miniMap);
        gui.AddChild(beginningLabelShadow);
        gui.AddChild(beginningLabel);
    }