Exemplo n.º 1
0
        private static Research GetRandomResearch(Research[] researchArray)
        {
            var      randomWeight     = Random.Range(0, SumRandomWeights(researchArray));
            Research selectedResearch = null;

            foreach (var research in researchArray)
            {
                if (randomWeight < research.randomWeight)
                {
                    selectedResearch = research;
                    break;
                }
                else
                {
                    randomWeight -= research.randomWeight;
                }
            }

            return(selectedResearch);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Load UI with data from SO.
 /// </summary>
 /// <param name="newResearch"></param>
 public void LoadInfo(Research researchSO)
 {
     infoText.text = researchSO.description;
     costText.text = researchSO.goldCost.ToString();
 }
Exemplo n.º 3
0
 protected override void Start()
 {
     currentResearch = GetRandomResearch(researchArray);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Called by Button.
 /// </summary>
 public override void OnReadyIconPressed()
 {
     base.OnReadyIconPressed();
     currentResearch = GetRandomResearch(researchArray);
     infoPromptControllerInstance.LoadInfo(currentResearch);
 }
 /// <summary>
 /// Load UI with data from SO.
 /// </summary>
 /// <param name="newResearch"></param>
 public void ReadResearchSO(Research researchSO)
 {
     researchInfoText.text = researchSO.description;
     researchCostText.text = researchSO.goldCost.ToString();
     windowTitleText.text  = researchSO.researchName.ToString();
 }