Beispiel #1
0
    public MainHub(MainGame tempGame) : base("Sprites/MainHub.png", 32, 24, "Sprites/MainHub.png", 32, 24, "colors.png", 1, 1, tempGame)
    {
        FileName = @"Screens/MainHub/MainHub.tmx";

        Map _levelData = MapParser.ReadMap(FileName);

        SpawnCollisionTiles(_levelData);
        SpawnBackgroundTiles(_levelData, true);
        SpawnObjects(_levelData);
        SpawnOverlapTiles(_levelData);

        _game       = tempGame;
        _displayTut = _game.DisplayTutorial;

        _tickets = new TicketDisplay(_game);
        AddChild(_tickets);

        _clock = new Clock();
        AddChild(_clock);

        if (_displayTut)
        {
            _c = new ConversationBox("Text/Tutorial.txt", this);
            AddChild(_c);
        }

        FirstInstance = false;

        _shopKeeper = new ShopKeeper();
        AddChild(_shopKeeper);
    }
Beispiel #2
0
    void Start()
    {
        inputController = Camera.main.GetComponent <TutorialInputController>();
        uiController    = Camera.main.GetComponent <TutorialUIController>();
        soundController = gameObject.GetComponent <SoundController>();
        camController   = Camera.main.GetComponent <CameraController>();

        TileFactory.tileMaterial = tileMaterial;
        matrix = new Matrix(MapParser.ReadMap("Maps/tutorial"));
        MapDrawer.instantiateMap(matrix.getIterable());
        players = new List <Player> ();
        players.Add(new Player("Jugador", StatsFactory.GetStat(SlimeCoreTypes.SLOTH)));         // Test with 2 players
        //players.Add(new Player("IA Tutorial", 1, StatsFactory.GetStat(SlimeCoreTypes.SLOTH))); // Test with 2 players
        players[0].SetColor(new Color(1, 1, 1));
        //players[1].SetColor(new Color(1,0,1));
        playerSlime = SlimeFactory.instantiateSlime(players[0], new Vector2(0f, -2f));
        //SlimeFactory.instantiateSlime(players[1], new Vector2(0f,2f));
        status        = GameControllerStatus.WAITINGFORACTION;
        currentPlayer = players [0];
        uiController.UpdateRound(currentTurn + 1);
        uiController.UpdatePlayer(GetCurrentPlayer().GetColor());
        uiController.UpdateActions(playerActions, GetCurrentPlayer().actions);
        uiController.ShowBothPanels();

        InitDialogChains();
        InitMarker();
        marker.SetParentTransform(playerSlime.transform);
        marker.SetMarkerRelativeSize();
        marker.SetActive(false);
        FloatingTextController.Initialize();
    }
    public BarHub(MainGame tempGame) : base("Sprites/Bar.png", 32, 24, "Sprites/Bar.png", 32, 24, "colors.png", 1, 1, tempGame)
    {
        FileName = @"Screens/BarHub/BarHub.tmx";

        Map _levelData = MapParser.ReadMap(FileName);

        SpawnCollisionTiles(_levelData);
        SpawnBackgroundTiles(_levelData, false);
        SpawnObjects(_levelData);
        SpawnOverlapTiles(_levelData);

        FirstInstance = false;

        _game = tempGame;

        _tickets = new TicketDisplay(_game);
        AddChild(_tickets);

        _clock = new Clock();
        AddChild(_clock);

        _dj = new DJ();
        LateAddChild(_dj);

        _barMan = new BarMan();
        LateAddChild(_barMan);

        _devil = new DevilNPC();
        LateAddChild(_devil);

        _cat = new CatManNPC();
        LateAddChild(_cat);
    }
Beispiel #4
0
 public Challenge(string name, string description, int maxTurns, int modo, int map)
 {
     this.name        = name;
     this.description = description;
     this.maxTurns    = maxTurns;
     this.modo        = modo;
     this.map         = new Matrix(MapParser.ReadMap((MapTypes)map));
 }
Beispiel #5
0
    public Level(string fileName)
    {
        String pathName  = Path.GetDirectoryName(fileName);
        Map    levelData = MapParser.ReadMap(fileName);

        PlaceImageLayer(levelData, pathName);
        SpawnTiles(levelData);
        SpawnObjects(levelData);
    }
    public LevelLoader(string mapName)
    {
        _mapData    = MapParser.ReadMap(mapName);
        _tileWidth  = (short)_mapData.TileWidth;
        _tileHeight = (short)_mapData.TileHeight;

        //Calls both methods to create tiles and objects
        this.LoadLevel(_mapData);
        this.LoadGameObjects(_mapData);

        AddChild(hud);
    }
Beispiel #7
0
    public ArkanoidLevelScreen(string filename, MainGame tempGame)
    {
        _game   = tempGame;
        _blocks = new List <Block>();
        Map leveldata = MapParser.ReadMap(filename); // Reads the data of the .tmx file

        SpawnObjects(leveldata);                     // Calls SpawnObjects method to spawn the objects from the .tmx file in the level.

        // Plays an audio file as background music
        Sound backgroundMusic = new Sound("ArkanoidSounds/LevelStart.mp3", false, true);

        _backgroundMusicChannel        = backgroundMusic.Play();
        _backgroundMusicChannel.Volume = 1f;
        _isLevelStarted = false;
    }
Beispiel #8
0
    public LevelRoadRacer(MainGame tempGame)
    {
        _game    = tempGame;
        FileName = @"RoadRacerLevel/RoadRacer.tmx";
        Map _levelData = MapParser.ReadMap(FileName);

        SpawnRoad(_levelData);

        _obst = new Obstacles(tempGame);
        _obst.SetXY(game.width / 2, 0);
        AddChild(_obst);

        _overlay = new Overlay();
        AddChild(_overlay);
        _player = new PlayerRoadRacer(this, tempGame);
        AddChild(_player);

        Sound backgroundMusic = new Sound("Sounds/RoadRacerSong.mp3", true, true);

        _backgroundMusicChannel        = backgroundMusic.Play();
        _backgroundMusicChannel.Volume = 1f;
    }
    void OnGUI()
    {
        //GUI.skin = Skin;

        if (GUI.Button(new Rect(5, 5, 160, 35), "Load map"))
        {
            string[] path = StandaloneFileBrowser.OpenFilePanel("Open trk file", CrashdayPath + "/user/", "trk", false);
            if (path.Length != 0 && path[0].Length != 0)
            {
                PlayerPrefs.SetString("lastmappath", path[0]);
                Track = MapParser.ReadMap(path[0]);
                GetComponent <TrackManager>().LoadTrack(Track);
            }
        }

        if (GUI.Button(new Rect(175, 5, 160, 35), "Save map"))
        {
            string path = StandaloneFileBrowser.SaveFilePanel("Save trk file", CrashdayPath + "/user/", "my_awesome_track", "trk");
            if (path.Length != 0)
            {
                MapParser.SaveMap(GetComponent <TrackManager>().CurrentTrack, path);
            }
        }
    }
 public static void SaveTrackInfo(string path)
 {
     TRACK     = MapParser.ReadMap(path);
     Trackname = Path.GetFileNameWithoutExtension(path);
 }
Beispiel #11
0
        public void generateLevel(int index)
        {
            _filename = "Data/Levels/level" + index + ".tmx";

            //Background creation
            Bitmap     Bmp   = new Bitmap(800, 600);
            Graphics   gfx   = Graphics.FromImage(Bmp);
            SolidBrush brush = new SolidBrush(Color.FromArgb(135, 206, 235));

            gfx.FillRectangle(brush, 0, 0, 800, 600);

            Sprite _background = new Sprite(Bmp);

            AddChild(_background);
            _background.width  = 2000;
            _background.height = 2000;

            Map level = MapParser.ReadMap(_filename);

            for (int i = 0; i < level.Layers.Length; i++)
            {
                Layer _currentLayer = level.Layers[i];

                Data leveldata = _currentLayer.Data;

                String levelData = _currentLayer.Data.innerXML.ToString();

                levelData = levelData.Replace("\n", "");

                int[] _tilesArray = Array.ConvertAll(levelData.Split(','), int.Parse);

                int _columns = level.Layers[i].Width;
                int _rows    = level.Layers[i].Height;

                int tileset_number;

                if (i == 3)
                {
                    tileset_number = 1;
                }
                else
                {
                    tileset_number = 0;
                }

                for (int j = 0; j < _tilesArray.Length; j++)
                {
                    if (_tilesArray[j] != 0)
                    {
                        int x = j % _columns;
                        int y = j / _columns;

                        _tiles.Add(new Tile(_tilesArray[j], "Data" + level.TileSets[tileset_number].Image.FileName, level.TileSets[tileset_number].Columns, level.TileSets[tileset_number].Rows));
                        _tiles[_num_objects].currentFrame = _tilesArray[j] - level.TileSets[tileset_number].FirstGId;
                        _tiles[_num_objects].x            = (x * 30) + level.Layers[i].offsetx;
                        _tiles[_num_objects].y            = (y * 32) + level.Layers[i].offsety - level.TileSets[tileset_number].TileHeight;
                        AddChild(_tiles[_num_objects]);

                        _num_objects++;
                    }
                }
            }

            {
                bool flipped = false;
                if (index == 2)
                {
                    flipped = true;
                }
                TiledObject _object = level.ObjectGroups[2].Objects[0];

                _player = new Player(_object.X, _object.Y, flipped);
            }

            for (int i = 0; i < level.ObjectGroups[0].Objects.Length; i++)
            {
                TiledObject _object = level.ObjectGroups[0].Objects[i];

                switch (_object.Type)
                {
                case "Coin":
                    Coin _coin = new Coin(_object.X, _object.Y);
                    AddChild(_coin);
                    break;

                case "Chest":
                    ChestBox _chest = new ChestBox(_object.X, _object.Y);
                    AddChild(_chest);
                    break;

                case "Trigger":
                    Trigger _trigger = new Trigger(_object.X, _object.Y);
                    AddChild(_trigger);
                    break;
                }
            }

            AddChild(_player);

            for (int i = 0; i < level.ObjectGroups[1].Objects.Length; i++)
            {
                TiledObject _object = level.ObjectGroups[1].Objects[i];

                switch (_object.Type)
                {
                case "Swordman":
                    Swordman swordman = new Swordman(_object.X, _object.Y);
                    AddChild(swordman);
                    break;

                case "Fire":
                    Fire fire = new Fire(_object.X, _object.Y);
                    AddChild(fire);
                    break;

                case "Wizard":
                    Wizard wizard = new Wizard(_object.X, _object.Y);
                    AddChild(wizard);
                    break;
                }
            }

            _hud = new HUD();
            _hud.SetXY(300, 570);
            game.AddChild(_hud);

            _shop         = new Shop(175, 50);
            _shop.visible = false;
            game.AddChild(_shop);

            _player.LoadHUD();
        }
Beispiel #12
0
    //----------------------------------------------------------------------------------------------------------------------
    //                                                      CONSTRUCTOR
    //----------------------------------------------------------------------------------------------------------------------
    public MapLevel(string s, Level level, Timer timer, HandHeld handHeld)
    {
        this.handHeld = handHeld;

        _doorsYellow = new List <Door>();
        _doorsBlue   = new List <Door>();
        _objectList  = new List <Sprite>();

        _level = level;

        Map map = MapParser.ReadMap(s);

        _tileNewSize = game.height / map.Height;
        _width       = map.Width * _tileNewSize;
        _height      = map.Height * _tileNewSize;

        _timer = timer;

        backgroundSetup();

        for (int l = 0; l < map.Layers.Length; l++)
        {
            //get string from file
            string layerData = map.Layers[l].Data.ToString();

            //split string by the comma
            string[] tileData = layerData.Split(',');

            //create list for storing data
            List <int> data = new List <int>();

            //go through all the strings in the tileData array (created by Split)
            for (int i = 0; i < tileData.Length; i++)
            {
                //get a single array entry
                string tile = tileData[i];

                //try to convert entry to integer
                if (Int32.TryParse(tile, out int tileID))
                {
                    //if it works, add it to the list
                    data.Add(tileID);
                }
            }

            foreach (int tile in data)
            {
                //Console.Write(String.Format( "{0}, ", tile));
                if (tile > 0)
                {
                    HandleMap(tile, map.Height);            // Map Gets Created
                }
                posX = posX + 1;
                if (posX >= map.Width)
                {
                    posX = 0;
                    posY = posY + 1;
                }
            }
            SetupForwardObjects();
        }
    }