public void EditConditionData(ResourceLoad resourceLoad, CLCondition condition, UnityAction <object> confirm, UnityAction cancel = null) { var databox = Instantiate(EventDataEditorDialogBoxTemplate, transform).GetComponent <EventDataDialogBox>(); databox.resourceLoad = resourceLoad; databox.SetEventData(condition); databox.ConfirmEvent = confirm; databox.CancelEvent = cancel; databox.gameObject.SetActive(true); }
private void PmsClick(CLCondition condition, bool isleft) { CLCondition con = isleft ? condition.condition1 : condition.condition2; if (con == null) { con = new CLCondition(); } if (condition.conditiontype == CLConditionType.negate || condition.conditiontype == CLConditionType.and || condition.conditiontype == CLConditionType.or) { DialogBoxManager.dialogBoxManager.EditConditionData(resourceLoad, con, confirm => { if (isleft) { condition.condition1 = confirm as CLCondition; } else { condition.condition2 = confirm as CLCondition; } SetEventData(condition); }); } else { con.conditiontype = CLConditionType.val; CLValue value = con.value; if (value == null) { value = new CLValue() { parameterindex = 0, name = "触发物体0" } } ; DialogBoxManager.dialogBoxManager.EditCLValueData(resourceLoad, value, s => { con.value = s as CLValue; if (isleft) { condition.condition1 = con; } else { condition.condition2 = con; } SetEventData(condition); }); } }
public void SetEventData(CLCondition condition) { dataBase = new CLCondition(); Tool.CopyValue(dataBase, condition); IsCondition = true; Title.text = "编辑值-布尔"; string[] funstrs = Enum.GetNames(typeof(CLConditionType)); if (funstrs.Length != Function.options.Count + 1) { Function.options.Clear(); for (int i = 0; i < funstrs.Length - 1; i++) { if (funstrs[i] == "or" || funstrs[i] == "and" || funstrs[i] == "negate") { Function.options.Add(new Dropdown.OptionData("[布尔]" + funstrs[i])); } else { Function.options.Add(new Dropdown.OptionData("[实数]" + funstrs[i])); } if (funstrs[i] == condition.conditiontype.ToString()) { Function.value = i; } } Function.RefreshShownValue(); Function.onValueChanged.AddListener(res => { var condi = new CLCondition() { conditiontype = (CLConditionType)res }; SetEventData(condi); }); } Pm1.text = condition.condition1 == null ? "null" : condition.condition1.ToString(); FunTip.text = condition.conditiontype.ToString(); val.gameObject.SetActive(false); if (condition.conditiontype == CLConditionType.negate) { Pm2.gameObject.SetActive(false); } else { Pm2.gameObject.SetActive(true); Pm2.text = condition.condition2 == null ? "null" : condition.condition2.ToString(); } fun.Select(); }
void Start() { Remark.onValueChanged.AddListener(s => { resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Remark = s; }); EventType.onValueChanged.AddListener(s => { resourceLoad.EventInfos[classify_event.Key][classify_event.Value].EventType = (CLEventType)s; }); Condition.GetComponent <Button>().onClick.AddListener(() => { CLCondition con = resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Condition; if (con == null) { con = new CLCondition(); } DialogBoxManager.dialogBoxManager.EditConditionData(resourceLoad, con, confirm => { resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Condition = confirm as CLCondition; LoadEventInfo(resourceLoad.EventInfos[classify_event.Key][classify_event.Value]); }); }); Action.onValueChanged.AddListener(s => { resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Action.type = (CLActionType)s; }); Pm1.GetComponent <Button>().onClick.AddListener(() => { CLValue value = resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Action.values[0]; if (value == null) { value = new CLValue(); } DialogBoxManager.dialogBoxManager.EditCLValueData(resourceLoad, value, confirm => { resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Action.values[0] = confirm as CLValue; LoadEventInfo(resourceLoad.EventInfos[classify_event.Key][classify_event.Value]); }); }); Pm2.GetComponent <Button>().onClick.AddListener(() => { CLValue value = resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Action.values[1]; if (value == null) { value = new CLValue(); } DialogBoxManager.dialogBoxManager.EditCLValueData(resourceLoad, value, confirm => { resourceLoad.EventInfos[classify_event.Key][classify_event.Value].Action.values[1] = confirm as CLValue; LoadEventInfo(resourceLoad.EventInfos[classify_event.Key][classify_event.Value]); }); }); }
private object AnalysisCondition(CLCondition condition, params object[] objs) { if (condition == null) { return(true); } if (condition.conditiontype == CLConditionType.val) { return(AnalysisValue(condition.value, objs)); } var type = condition.conditiontype; object cond1 = AnalysisCondition(condition.condition1, objs); object cond2 = AnalysisCondition(condition.condition2, objs); object res = null; if (type == CLConditionType.add) { float c1 = float.Parse(cond1.ToString()); float c2 = float.Parse(cond2.ToString()); res = c1 + c2; } else if (type == CLConditionType.sub) { float c1 = float.Parse(cond1.ToString()); float c2 = float.Parse(cond2.ToString()); res = c1 - c2; } else if (type == CLConditionType.mul) { float c1 = float.Parse(cond1.ToString()); float c2 = float.Parse(cond2.ToString()); res = c1 * c2; } else if (type == CLConditionType.div) { float c1 = float.Parse(cond1.ToString()); float c2 = float.Parse(cond2.ToString()); res = c1 / c2; } else if (type == CLConditionType.greater) { float c1 = float.Parse(cond1.ToString()); float c2 = float.Parse(cond2.ToString()); res = c1 > c2; } else if (type == CLConditionType.less) { float c1 = float.Parse(cond1.ToString()); float c2 = float.Parse(cond2.ToString()); res = c1 < c2; } else if (type == CLConditionType.equal) { res = cond1.ToString() == cond2.ToString(); } else if (type == CLConditionType.negate) { res = !(bool)cond1; } else if (type == CLConditionType.and) { res = (bool)cond1 && (bool)cond2; } else if (type == CLConditionType.or) { res = (bool)cond1 || (bool)cond2; } else { res = true; } return(res); }