Exemplo n.º 1
0
        /*-----Functions-----*/
        public static void initLevel()
        {
            string levelFile = "Levels/" + LevelID.ToString() + ".txt";

            try
            {
                using (StreamReader sr = new StreamReader(levelFile))
                {
                    LevelWidth  = Convert.ToInt32(sr.ReadLine());
                    LevelHeight = Convert.ToInt32(sr.ReadLine());
                    LevelDesign = sr.ReadLine();
                    TileID      = new TextureID[LevelWidth, LevelHeight];
                    string line;
                    for (int y = 0; y < LevelHeight; y++)
                    {
                        line = sr.ReadLine();
                        string[] row = line.Split(new Char[] { ',' });
                        for (int x = 0; x < LevelWidth; x++)
                        {
                            switch (Convert.ToInt32(row[x]))
                            {
                            case 1:
                                TileID[x, y] = TextureID.wall;
                                break;

                            case 2:
                                TileID[x, y] = TextureID.platformC;
                                break;

                            case 3:
                                TileID[x, y] = TextureID.platformL;
                                break;

                            case 4:
                                TileID[x, y] = TextureID.platformR;
                                break;

                            default:
                                TileID[x, y] = TextureID.air;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
            }
        }
Exemplo n.º 2
0
    ////////////////////////////////////////////////////////////////

    private bool InitializePlayerSpawnPointToStartFrom(LevelID level)
    {
        SetPlayerSpawnPoint(m_PlayerSpawnPoints.Find((PlayerSpawnPoint psp) => {
            return(psp.Index == m_PlayerSpawnPointToStartFrom.Value.ID && psp._LevelID == m_PlayerSpawnPointToStartFrom.Value.Level);
        }));

        SoundManager.Get().FitSoundToArea(m_CurrentPlayerSpawnPoint._AreaID);

        Debug.Assert(m_CurrentPlayerSpawnPoint != null, "Could not find serialized player spawnpoint ID " + m_PlayerSpawnPointToStartFrom.Value.ID + " in level " + level.ToString());

        return(m_CurrentPlayerSpawnPoint != null);
    }