public void GetMin8ColorsFromDBTest() { //Arrange IColorsDB colorsDB = new ColorsDB(); int minNumberOfColors = 8; //Act //colorsDB.AddColor(Color.Blue); IEnumerable <Color> colors = colorsDB.GetColors(); //Assert Assert.IsTrue(colors.Count() >= minNumberOfColors); }
//O- Turning 180° animation --------------------------------------------- #endregion #region Own Methods private void Material() { ColorsDB cCopy = gameManager.GetComponent <ColorsDB>(); //Getting a random color and be sure that there are some left: #region Pick one random color //There are surely cleaner way to do it, but it works var rand = Random.Range(0, gridSize - 1); colorToChoose = cCopy.colorDBCopy[rand]; maxIterations = gridSize; while (!isChosen) { if (colorToChoose.number > 0) { //Setting it to the material of Tile's child (ColoredPart) GameObject child = transform.GetChild(0).gameObject; child.GetComponent <Renderer>().material = cCopy.colorDBCopy[rand].material; //Remove one cCopy.colorDBCopy[rand].number -= 1; isChosen = true; } else if (maxIterations > 0) { maxIterations -= 1; rand += 1; if (rand > gridSize - 1) { rand = 0; } colorToChoose = cCopy.colorDBCopy[rand]; } else if (maxIterations <= 0) { Debug.LogError("ERROR: There is no space left"); break; } } #endregion }
//Awake is always called before any Start functions void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); }
private GameManagement() { IColorsDB colorsDB = new ColorsDB(); Colors = colorsDB.GetColors().ToArray(); }