public EventChoice(string ChoiceText, float SuccessChance, AssemblyCSharp.EventCard SuccessNextCard, AssemblyCSharp.EventCard FailureNextCard, AssemblyCSharp.EventCard AltNextCard) { successChance = SuccessChance; choiceText = ChoiceText; successNextCard = SuccessNextCard; failureNextCard = FailureNextCard; altNextCard = AltNextCard; }
public void Options(AssemblyCSharp.EventCard eventCard) { var allButtons = new [] { new { name = option1, choice = eventCard.Choice1 }, new { name = option2, choice = eventCard.Choice2, }, new { name = option3, choice = eventCard.Choice3, }, new { name = option4, choice = eventCard.Choice4, }, new { name = option5, choice = eventCard.Choice5, } }; foreach (var option in allButtons) { option.name.gameObject.SetActive(false); if (option.choice != null) { modalPanelObject.SetActive(true); player.canMove = false; this.prompt.text = eventCard.Prompt; this.prompt.gameObject.SetActive(true); option.name.gameObject.SetActive(true); option.name.gameObject.GetComponentsInChildren <Text> () [0].text = option.choice.choiceText; option.name.onClick.RemoveAllListeners(); if (option.choice.successChance == 0) { option.name.onClick.AddListener(ClosePanel); } else { float random = Random.value; print(random); print(option.choice.successChance); if (random >= .99 && option.choice.altNextCard != null) { option.name.onClick.AddListener(delegate { TestOption1(option.choice.altNextCard); }); } if (option.choice.successChance > random * 100) { option.name.onClick.AddListener(delegate { TestOption1(option.choice.successNextCard); }); } else if (option.choice.successChance != 0) { option.name.onClick.AddListener(delegate { TestOption1(option.choice.failureNextCard); }); } } } } }
void TestOption1(AssemblyCSharp.EventCard eventCard) { Options(eventCard); }