Beispiel #1
0
    private void Awake()
    {
        dl  = ServiceLocator.Get <DataLoader>();
        dtl = ServiceLocator.Get <DataToLoad>();


        iSource  = dl.LoadedDataSources[dtl.GetLevelToLoad()];
        jSonData = iSource as JsonDataSource;

        InitializeValues();
    }
Beispiel #2
0
    // Use this for initialization
    void Awake()
    {
        dl  = ServiceLocator.Get <DataLoader>();
        dtl = ServiceLocator.Get <DataToLoad>();

        iSource  = dl.LoadedDataSources[dtl.GetLevelToLoad()];
        jSonData = iSource as JsonDataSource;

        InitializeValues();

        source = GetComponent <AudioSource>();

        piecePrefabDict = new Dictionary <PieceType, GameObject>();

        for (int i = 0; i < piecePrefabs.Length; ++i)
        {
            if (!piecePrefabDict.ContainsKey(piecePrefabs[i].type))
            {
                piecePrefabDict.Add(piecePrefabs[i].type, piecePrefabs[i].prefab);
            }
        }

        for (int x = 0; x < xDim; ++x)
        {
            for (int y = 0; y < yDim; ++y)
            {
                GameObject backgroung = Instantiate(backGroundPrefab, GetWorldPosition(x, y) * 9.5f, Quaternion.identity);
                backgroung.transform.parent = transform;
            }
        }

        pieces = new GamePiece [xDim, yDim];

        for (int i = 0; i < initialPieces.Length; i++)
        {
            if (initialPieces[i].x >= 0 && initialPieces[i].x < xDim && initialPieces[i].y >= 0 && initialPieces[i].y < yDim)
            {
                SpawnNewPiece(initialPieces[i].x, initialPieces[i].y, initialPieces[i].type);
            }
        }


        for (int x = 0; x < xDim; ++x)
        {
            for (int y = 0; y < yDim; ++y)
            {
                if (pieces[x, y] == null)
                {
                    SpawnNewPiece(x, y, PieceType.EMPTY);
                }
            }
        }
    }
Beispiel #3
0
    private void Awake()
    {
        dl  = ServiceLocator.Get <DataLoader>();
        dtl = ServiceLocator.Get <DataToLoad>();


        iSource  = dl.LoadedDataSources[dtl.GetLevelToLoad()];
        jSonData = iSource as JsonDataSource;

        InitializeValues();

        levelAS    = GetComponent <AudioSource>();
        gamePlayAS = GameObject.Find("GameplayMusic").GetComponent <AudioSource>();
    }
Beispiel #4
0
    public void GoToLevel(int level)
    {
        dtl.SetCurrentLevel(level);

        iSource  = dl.LoadedDataSources[dtl.GetLevelToLoad()];
        jSonData = iSource as JsonDataSource;

        string levelType = jSonData.DataDictionary["LevelType"].ToString();

        if (levelType == "TargetScore")
        {
            SceneManager.LoadScene(3);
        }
        else if (levelType == "BreakingObstacle")
        {
            SceneManager.LoadScene(4);
        }
        else if (levelType == "Timer")
        {
            SceneManager.LoadScene(5);
        }
    }