/// <summary> Called by <c>EventOptionUI</c> </summary> public void OnOptionSelect(int idx) { var option = eventWrapper.Sobj.options[idx]; option.wrapper.OnSelected?.Invoke(option); // cache this (?) optionList.gameObject.SetActive(false); foreach (var opt in options) { Destroy(opt.gameObject); } var result = option.results.TryTrigger(); if (result == null) { //Debug.LogError($"Result not found for {eventWrapper.Sobj.readableName} {option.mainDescription}"); NextEvent(); return; } mainDesc.text = result.substituteDescription; resultWrapper = result.wrapper; continueButton.gameObject.SetActive(true); }
private void SetCurrentEvent(EventWrapper wrapper) { continueButton.gameObject.SetActive(false); resultWrapper = null; eventWrapper = wrapper; var sobj = wrapper.Sobj; title.text = sobj.readableName; mainDesc.text = sobj.mainDescription; mainImage.sprite = sobj.mainImage; optionList.gameObject.SetActive(true); var numOpts = sobj.options.Length; if (numOpts == 0) { NextEvent(); } else { options = new EventOptionUI[numOpts]; for (var i = 0; i < numOpts; ++i) { CreateOption(sobj.options[i], i); } } }
private void NextEvent() { if (resultWrapper != null) { var rstWrapper = resultWrapper; resultWrapper = null; rstWrapper.OnTrigger(rstWrapper); } var evmgr = EventManager.Instance; if (!evmgr.Empty()) { var ev = evmgr.PullEvent(); SetCurrentEvent(ev); return; } // disable canvas gameObject.SetActive(false); // clean up TMP title.text = ""; mainDesc.text = ""; mainImage.sprite = null; GameLoop.Instance.TransToMap(); }
public EventOptionWrapper(EventOptionSobj sobj, EventSobj source) { Sobj = sobj; Sobj.wrapper = this; EventSource = source; foreach (var result in sobj.results) { var wrapper = new EventResultWrapper(result, sobj); } }
public static void PropOnTrigger(EventResultWrapper result, float immune = 0) { var factor = Extension.GetTurnFactor(result.EventSource.type); factor *= (1 - immune); var ins = result.Sobj.instantOutcome * factor; if (ins.Any(p => p != 0)) { PropertyManager.Instance.AddProperty(ins); } var buff = result.Sobj.buffOutcome; if (buff.ActiveTurns > 0 && buff.PropertyGroup.Any(p => p != 0)) { BuffQueue.Instance.Add(buff.CreateBuff(factor)); } }
public static void DefaultOnTrigger(EventResultWrapper result) { PropOnTrigger(result, 0); }