public void GenerateProject(Project.ProjectDifficulty difficulty, int index) { var project = _projectList.GetRandomProject(difficulty); //Set the Project Card var cardScript = ProjectCards[index].GetComponent <ProjectCard>(); cardScript.Project = project; cardScript.Initialize(); //Set the Card Building Shape var i = 0; for (var y = 1; y < 3; y++) { for (var x = 0; x < 3; x++) { bool isBuild = project.Building.IsBuild(new Vector2(x, y)); ProjectCards[index].transform.GetChild(2).GetChild(i).gameObject.SetActive(isBuild); i++; } } Button button = ProjectCards[index].transform.GetChild(3).GetComponent <Button>(); button.onClick.RemoveAllListeners(); // Reset the button //Add button click button.onClick.AddListener(() => StartCoroutine(ChooseProject(project))); }
public Project GetRandomProject(Project.ProjectDifficulty difficulty) { var projects = ProjectsList.FindAll(j => j.Difficulty == difficulty); var randomProject = projects[Random.Range(0, projects.Count)]; randomProject.Occurance += 1; return(randomProject); }
public BuildingShape(Project.ProjectDifficulty difficulty) { //TODO Get a random shape based on difficulty (and space available?) }