/// <summary> /// Initializes the game board based from proposed picture models generated by game meachanic handler. Handles the pairing mechanism. Guarantees that each model has a pair. /// </summary> private void InitializeGameBoard() { PictureModel[] generatedModels = GameMechanicHandler.Instance.GeneratePictureModels(); List <PictureComponent> pictureComponentList = new List <PictureComponent> (); for (int i = 0; i < generatedModels.Length * 2; i++) { GameObject pictureObject = GameObject.Instantiate(this.pictureRefCopy.gameObject, this.pictureParent); pictureObject.gameObject.SetActive(true); PictureComponent pictureComponent = pictureObject.GetComponent <PictureComponent> (); pictureComponent.Reset(); pictureComponentList.Add(pictureComponent); } for (int i = 0; i < generatedModels.Length; i++) { int firstIndex = Random.Range(0, pictureComponentList.Count); //assign first pair then remove it from the list this.pictureComponentsSpawned.Add(pictureComponentList [firstIndex]); pictureComponentList [firstIndex].AssignPictureModel(generatedModels [i]); pictureComponentList.RemoveAt(firstIndex); int secondIndex = Random.Range(0, pictureComponentList.Count); //assign second pair then remove it from the list this.pictureComponentsSpawned.Add(pictureComponentList [secondIndex]); pictureComponentList [secondIndex].AssignPictureModel(generatedModels [i]); pictureComponentList.RemoveAt(secondIndex); } }
private void OnIncreasedLevel() { PictureModel[] generatedModels = GameMechanicHandler.Instance.GeneratePictureModels(); int additionalCount = (generatedModels.Length * 2) - this.pictureComponentsSpawned.Count; Debug.Log("Generated models: " + (generatedModels.Length * 2) + " Components spawned: " + this.pictureComponentsSpawned.Count + " Additional count: " + additionalCount); List <PictureComponent> componentList = new List <PictureComponent> (); //reset all existing components for (int i = 0; i < this.pictureComponentsSpawned.Count; i++) { this.pictureComponentsSpawned [i].TweenedReset(); componentList.Add(this.pictureComponentsSpawned [i]); } //instantiate additional components for (int i = 0; i < additionalCount; i++) { GameObject pictureObject = GameObject.Instantiate(this.pictureRefCopy.gameObject, this.pictureParent); pictureObject.gameObject.SetActive(true); PictureComponent pictureComponent = pictureObject.GetComponent <PictureComponent> (); pictureComponent.Reset(); this.pictureComponentsSpawned.Add(pictureComponent); componentList.Add(pictureComponent); } this.StartCoroutine(this.DelayAssignModel(generatedModels, componentList, 0.25f)); }
public void AuditMethods_PictureComponentCreateAllThumbnails_MethodGrantedToEveryone() { var component = new PictureComponent(); var methodInfo = typeof(PictureComponent).GetMethod("CreateAllThumbnails"); var attribute = Attribute.GetCustomAttribute(methodInfo, typeof(GrantedAttribute), true); Assert.NotNull(attribute, "attribute"); }