private bool ValidateChoiceState(ValidationContext stateContext, ChoiceState choiceState) { var merged = MergeParentVisited(); var hasPathToTerminal = false; if (!string.IsNullOrEmpty(choiceState.DefaultStateName)) { hasPathToTerminal = new GraphValidator(stateContext, merged, choiceState.DefaultStateName, _states) .Validate(); } var index = 0; foreach (var choice in choiceState.Choices) { var nextStateName = ((NextStateTransition)choice.Transition).NextStateName; // It's important hasPathToTerminal is last in the OR so it doesn't short circuit the choice validation hasPathToTerminal = new GraphValidator(stateContext.Choice(index), merged, nextStateName, _states) .Validate() || hasPathToTerminal; index++; } return(hasPathToTerminal); }
public virtual void Initialize(ChoiceState choiceState) { ChoiceState = choiceState; OnSummaryTextChanged?.Invoke(choiceState.Summary); onSummaryTextChanged?.Invoke(choiceState.Summary); }
public virtual void AddChoiceButton(ChoiceState choice) { if (removeAllButtonsPending) { removeAllButtonsPending = false; RemoveAllChoiceButtons(); } var choicePrefab = string.IsNullOrWhiteSpace(choice.ButtonPath) ? defaultButtonPrefab : Resources.Load <ChoiceHandlerButton>(choice.ButtonPath); var choiceButton = Instantiate(choicePrefab); choiceButton.transform.SetParent(buttonsContainer, false); choiceButton.Initialize(choice); choiceButton.OnButtonClicked += () => OnChoice?.Invoke(choice); if (choice.OverwriteButtonPosition) { choiceButton.transform.localPosition = choice.ButtonPosition; } choiceButtons.Add(choiceButton); if (focusChoiceButtons && EventSystem.current) { EventSystem.current.SetSelectedGameObject(choiceButton.gameObject); } }
private void Reset() { disabled = false; wasChosen = false; image.enabled = true; button.enabled = true; LetterText.enabled = true; State = ChoiceState.IDLE; }
private void ChangeMainState(ChoiceState state) { MemberPage.ShowUI(state == ChoiceState.Member); ActivityPage.ShowUI(state == ChoiceState.Activity); TechnologyPage.ShowUI(state == ChoiceState.Technology); DonatePage.ShowUI(state == ChoiceState.Donate); MessagePage.ShowUI(state == ChoiceState.Message); MedalPage.ShowUI(state == ChoiceState.Medal); MercenaryPage.ShowUI(state == ChoiceState.Mercenary); }
/// <summary> /// 点击事件标题 /// </summary> private void OnClickChoiceMessage() { MainChoiceState = ChoiceState.Message; LegionLogic.GetInstance().IsHaveNewEvent = false; LTRedPointSystem.Instance.SetRedPointNodeNum(RedPointConst.haveevent, 0); if (LegionEvent.SendGetLegionMessages != null) { LegionEvent.SendGetLegionMessages(); } }
private void Reset() { disabled = false; wasChosen = false; image.enabled = true; button.enabled = true; LetterText.enabled = true; State = ChoiceState.IDLE; LetterText.gameObject.SetActive(true); }
public virtual void AddChoiceButton(ChoiceState choice) { if (removeAllButtonsPending) { removeAllButtonsPending = false; RemoveAllChoiceButtons(); } if (choiceButtons.Any(b => b.ChoiceState.Id == choice.Id)) { return; // Could happen on rollback. } var choicePrefab = string.IsNullOrWhiteSpace(choice.ButtonPath) ? defaultButtonPrefab : Resources.Load <ChoiceHandlerButton>(choice.ButtonPath); if (!choicePrefab) { Debug.LogError($"Failed to add `{choice.ButtonPath}` choice button. Make sure the button prefab is stored in a `Resources` folder of the project."); return; } var choiceButton = Instantiate(choicePrefab); choiceButton.transform.SetParent(buttonsContainer, false); choiceButton.Initialize(choice); choiceButton.OnButtonClicked += () => OnChoice?.Invoke(choice); if (backlogUI != null) { choiceButton.OnButtonClicked += () => backlogUI.AddChoice(choiceButtons .Select(b => new Tuple <string, bool>(b.ChoiceState.Summary, b.ChoiceState.Id == choice.Id)).ToList()); } if (choice.OverwriteButtonPosition) { choiceButton.transform.localPosition = choice.ButtonPosition; } choiceButtons.Add(choiceButton); if (focusChoiceButtons) { switch (FocusModeType) { case FocusMode.Visibility: if (EventSystem.current) { EventSystem.current.SetSelectedGameObject(choiceButton.gameObject); } break; case FocusMode.Navigation: FocusOnNavigation = choiceButton.gameObject; break; } } }
void CancelState() { state = ChoiceState.UNIT; selectedUnit.selectedAbility = null; selectedUnit = null; target = new Vector2(); foreach (AbilityCircle c in circles) { Destroy(c); } circles.Clear(); }
public Items(string title, ContentManager content) : base(title, content) { background = content.Load <Texture2D>("Content\\Menu\\ItemsBackground"); hand = content.Load <Texture2D>("Content\\Menu\\menuHand"); emptyBar = content.Load <Texture2D>("Content\\Menu\\EmptyBar"); fullBar = content.Load <Texture2D>("Content\\Menu\\FullBar"); spriteFont = content.Load <SpriteFont>("Content\\Fonts\\Arial13"); smallFont = content.Load <SpriteFont>("Content\\Fonts\\Arial9"); handIndex = 0; state = ChoiceState.Home; itemIndex = 0; first = true; waitingKey = (Keys)Input.Left; }
public override async UniTask ExecuteAsync(CancellationToken cancellationToken = default) { var handlerId = Assigned(HandlerId) ? HandlerId.Value : HandlerManager.Configuration.DefaultHandlerId; var choiceHandler = await HandlerManager.GetOrAddActorAsync(handlerId); if (cancellationToken.IsCancellationRequested) { return; } if (!choiceHandler.Visible && ShowHandler) { choiceHandler.ChangeVisibilityAsync(true, Duration, cancellationToken: cancellationToken).Forget(); } var builder = new StringBuilder(); if (Assigned(SetExpression)) { builder.AppendLine($"{CommandScriptLine.IdentifierLiteral}{nameof(SetCustomVariable)} {SetExpression}"); } if (Assigned(GotoPath)) { builder.AppendLine($"{CommandScriptLine.IdentifierLiteral}{nameof(Goto)} {GotoPath.Name ?? string.Empty}{(GotoPath.NamedValue.HasValue ? $".{GotoPath.NamedValue.Value}" : string.Empty)}"); } else if (Assigned(GosubPath)) { builder.AppendLine($"{CommandScriptLine.IdentifierLiteral}{nameof(Gosub)} {GosubPath.Name ?? string.Empty}{(GosubPath.NamedValue.HasValue ? $".{GosubPath.NamedValue.Value}" : string.Empty)}"); } if (Assigned(OnSelected)) { foreach (var line in OnSelected) { builder.AppendLine(line); } } var onSelectScript = builder.ToString()?.TrimFull(); var buttonPos = Assigned(ButtonPosition) ? (Vector2?)ArrayUtils.ToVector2(ButtonPosition) : null; var autoPlay = !Assigned(GotoPath) && !Assigned(GosubPath) && !Assigned(OnSelected); var choice = new ChoiceState(ChoiceSummary, ButtonPath, buttonPos, onSelectScript, autoPlay); choiceHandler.AddChoice(choice); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = JObject.Load(reader); var type = obj["Type"].Value <string>(); State.IBuilder <State> result = null; switch (Enum.Parse(typeof(StateType), type)) { case StateType.Choice: result = ChoiceState.GetBuilder(); break; case StateType.Fail: result = FailState.GetBuilder(); break; case StateType.Parallel: result = ParallelState.GetBuilder(); break; case StateType.Pass: result = PassState.GetBuilder(); break; case StateType.Succeed: result = SucceedState.GetBuilder(); break; case StateType.Task: result = TaskState.GetBuilder(); break; case StateType.Wait: result = WaitState.GetBuilder(); break; case StateType.Map: result = MapState.GetBuilder(); break; } serializer.Populate(obj.CreateReader(), result); return(result); }
private void ChoiceButton_OnRelease(UIEvent e) { int friendlyPlayerId = GameState.Get().GetFriendlyPlayerId(); ChoiceState state = this.m_choiceStateMap[friendlyPlayerId]; if (this.m_friendlyChoicesShown) { this.m_choiceButton.SetText(GameStrings.Get("GLOBAL_SHOW")); this.HideChoiceCards(state); this.m_friendlyChoicesShown = false; } else { this.m_choiceButton.SetText(GameStrings.Get("GLOBAL_HIDE")); this.ShowChoiceCards(state, true, this.m_ChoiceEffectData.m_AlwaysPlayChoiceEffects); this.m_friendlyChoicesShown = true; } }
/// <summary> /// 打开后传参 /// </summary> /// <param name="param"></param> public override void SetMenuData(object param) { base.SetMenuData(param); Hashtable table = param as Hashtable; if (table == null) { LegionData data = param as LegionData; if (data == null) { return; } SetData(data); MainChoiceState = ChoiceState.Member; titleCtrl.SetTitleBtn((int)MainChoiceState); } else { if (table["legionData"] != null) { LegionData data = (LegionData)table["legionData"]; if (data == null) { return; } SetData(data); } if (table["choiceState"] != null) { ChoiceState state = (ChoiceState)table["choiceState"]; titleCtrl.SetTitleBtn((int)state); MainChoiceState = state; } } //刷新军团被雇佣次数 LegionLogic.GetInstance().OnSendGetCurDonateInfo((ha) => { DataLookupsCache.Instance.CacheData(ha); }); }
public override async UniTask ExecuteAsync(CancellationToken cancellationToken = default) { var handlerId = Assigned(HandlerId) ? HandlerId.Value : HandlerManager.Configuration.DefaultHandlerId; var choiceHandler = await HandlerManager.GetOrAddActorAsync(handlerId); if (cancellationToken.IsCancellationRequested) { return; } if (!choiceHandler.Visible && ShowHandler) { choiceHandler.ChangeVisibilityAsync(true, Duration, cancellationToken: cancellationToken).Forget(); } var buttonPos = Assigned(ButtonPosition) ? (Vector2?)ArrayUtils.ToVector2(ButtonPosition) : null; var choice = new ChoiceState(ChoiceSummary, ButtonPath, buttonPos, GotoPath?.Name, GotoPath?.NamedValue, SetExpression); choiceHandler.AddChoice(choice); }
public override int Visit(ChoiceState choiceState) { _currentContext.AssertIsValidInputPath(choiceState.InputPath); _currentContext.AssertIsValidOutputPath(choiceState.OutputPath); if (choiceState.DefaultStateName != null) { _currentContext.AssertStringNotEmpty(choiceState.DefaultStateName, PropertyNames.DEFAULT_STATE); AssertContainsState(choiceState.DefaultStateName); } _currentContext.AssertNotEmpty(choiceState.Choices, PropertyNames.CHOICES); var index = 0; foreach (var choice in choiceState.Choices) { var choiceContext = _currentContext.Choice(index); ValidateTransition(choiceContext, choice.Transition); ValidateCondition(choiceContext, choice.Condition); index++; } return(0); }
private void OnClickMercenaryBtn() { SceneLogic.BattleType = eBattleType.None;//进入佣兵界面置为none,防止Heroitem显示错误 MainChoiceState = ChoiceState.Mercenary; }
/// <summary> /// 点击勋章标题 /// </summary> private void OnClickChoiceMedal() { MedalPage.SetLegionMemberData(legionData.listMember); MainChoiceState = ChoiceState.Medal; }
public void ShowChoiceCards(ChoiceState state, bool friendly, bool playEffects) { object[] objArray1 = new object[] { state, friendly, playEffects }; base.method_8("ShowChoiceCards", objArray1); }
/// <summary> /// 点击捐献标题 /// </summary> private void OnClickChoiceDonate() { MainChoiceState = ChoiceState.Donate; }
/// <summary> /// 点击科技标题 /// </summary> private void OnClickChoiceTechnology() { MainChoiceState = ChoiceState.Technology; TechnologyPage.SetTechnologyInfo(legionData); }
/// <summary> /// 点击活动标题 /// </summary> private void OnClickChoiceActivity() { MainChoiceState = ChoiceState.Activity; }
public void AbilitySelected() { state = ChoiceState.TARGET; }
void OpenAbilities() { Debug.Log("abilities"); Resources.Load(""); state = ChoiceState.ABILITY; int parts = selectedUnit.abilities.Count; Vector2 cpos = selectedUnit.coordinates; double currentAngle = Math.PI / 2.0; if (useHexagonalCirclesLayout) { if (parts <= 6) { double angleDifference = (2.0 * Math.PI) / parts; for (int ii = 0; ii < parts; ii++) { AbilityCircle c = Instantiate(abilityCirclePrefab, new Vector3((float)Math.Cos(currentAngle) + cpos.x, (float)Math.Sin(currentAngle) + cpos.y), Quaternion.identity); circles.Add(c); c.Assign(selectedUnit, selectedUnit.abilities[ii]); currentAngle -= angleDifference; } } else { double angleDifference = Math.PI / 3.0; int sn = 0; int seqTreshold = 0; int lineTreshold = 0; Vector3 lineStartpoint = new Vector3(0f, 0f, 0f); Vector3 lineEndpoint = new Vector3(0f, 0f, 0f); for (int ii = 0; ii < parts; ii++) { if (ii == lineTreshold + sn) { lineTreshold += sn; if (lineTreshold == seqTreshold) { sn++; seqTreshold += 6 * sn; currentAngle = Math.PI / 6.0; lineStartpoint = new Vector3(0f, sn); } else { lineStartpoint = lineEndpoint; currentAngle -= angleDifference; } lineEndpoint = new Vector3(sn * (float)Math.Cos(currentAngle), sn * (float)Math.Sin(currentAngle)); } AbilityCircle c = Instantiate(abilityCirclePrefab, (new Vector3(cpos.x, cpos.y)) + Vector3.Lerp(lineStartpoint, lineEndpoint, (ii - lineTreshold) / sn), Quaternion.identity); circles.Add(c); c.Assign(selectedUnit, selectedUnit.abilities[ii]); } } } else { double angleDifference = (2.0 * Math.PI) / parts; float radius = parts > 6 ? 0.5f / (float)Math.Sin(Math.PI / parts) : 1.0f; for (int ii = 0; ii < parts; ii++) { AbilityCircle c = Instantiate(abilityCirclePrefab, new Vector3(radius * (float)Math.Cos(currentAngle) + cpos.x, radius * (float)Math.Sin(currentAngle) + cpos.y), Quaternion.identity); circles.Add(c); c.Assign(selectedUnit, selectedUnit.abilities[ii]); currentAngle -= angleDifference; } } }
public void PlayChoiceEffects(ChoiceState state, bool friendly) { object[] objArray1 = new object[] { state, friendly }; base.method_8("PlayChoiceEffects", objArray1); }
public void HideChoicesFromPacket(int playerId, ChoiceState state, Network.EntitiesChosen chosen) { object[] objArray1 = new object[] { playerId, state, chosen }; base.method_8("HideChoicesFromPacket", objArray1); }
public override bool UpdateSubMenu(KeyboardState keyboard, Party party) { if (first == true) { if (keyboard.IsKeyUp((Keys)Input.Confirm)) { first = false; } return(true); } switch (state) { case ChoiceState.Home: if (keyboard.IsKeyDown((Keys)Input.Left) && handIndex > 0) { state = ChoiceState.HomeReady; waitingKey = (Keys)Input.Left; } else if (keyboard.IsKeyDown((Keys)Input.Right) && handIndex < 2) { state = ChoiceState.HomeReady; waitingKey = (Keys)Input.Right; } else if (keyboard.IsKeyDown((Keys)Input.Cancel)) { first = true; return(false); } else if (keyboard.IsKeyDown((Keys)Input.Confirm) && inventory.Count > 0) { if (handIndex == 0) { state = ChoiceState.UseReady; waitingKey = (Keys)Input.Confirm; } else if (handIndex == 1) { state = ChoiceState.SortReady; waitingKey = (Keys)Input.Confirm; } else if (handIndex == 2) { state = ChoiceState.DiscardReady; waitingKey = (Keys)Input.Confirm; } Sounds.PlayCue("MenuNav"); handIndex = 0; } return(true); case ChoiceState.HomeReady: if (keyboard.IsKeyUp((Keys)Input.Left) && waitingKey == (Keys)Input.Left && handIndex > 0) { Sounds.PlayCue("MenuNav"); handIndex--; state = ChoiceState.Home; } else if (keyboard.IsKeyUp((Keys)Input.Right) && waitingKey == (Keys)Input.Right && handIndex < 2) { Sounds.PlayCue("MenuNav"); handIndex++; state = ChoiceState.Home; } else if (keyboard.IsKeyUp((Keys)Input.Cancel) && waitingKey == (Keys)Input.Cancel) { state = ChoiceState.Home; handIndex = 0; } return(true); case ChoiceState.UseReady: if (keyboard.IsKeyUp((Keys)Input.Confirm) && waitingKey == (Keys)Input.Confirm) { Sounds.PlayCue("MenuNav"); state = ChoiceState.Use; } else if (keyboard.IsKeyUp((Keys)Input.Down) && waitingKey == (Keys)Input.Down) { Sounds.PlayCue("MenuNav"); handIndex++; state = ChoiceState.Use; } else if (keyboard.IsKeyUp((Keys)Input.Up) && waitingKey == (Keys)Input.Up) { Sounds.PlayCue("MenuNav"); handIndex--; state = ChoiceState.Use; } else if (keyboard.IsKeyUp((Keys)Input.Cancel) && waitingKey == (Keys)Input.Cancel) { state = ChoiceState.Use; handIndex = itemIndex; } return(true); case ChoiceState.Use: if (keyboard.IsKeyDown((Keys)Input.Cancel)) { state = ChoiceState.HomeReady; waitingKey = (Keys)Input.Cancel; } else if (keyboard.IsKeyDown((Keys)Input.Down) && handIndex < inventory.Count - 1) { state = ChoiceState.UseReady; waitingKey = (Keys)Input.Down; } else if (keyboard.IsKeyDown((Keys)Input.Up) && handIndex > 0) { state = ChoiceState.UseReady; waitingKey = (Keys)Input.Up; } else if (keyboard.IsKeyDown((Keys)Input.Confirm)) { state = ChoiceState.UseCharReady; waitingKey = (Keys)Input.Confirm; itemIndex = handIndex; handIndex = 0; } return(true); case ChoiceState.UseCharReady: if (keyboard.IsKeyUp((Keys)Input.Confirm) && waitingKey == (Keys)Input.Confirm) { Sounds.PlayCue("MenuNav"); state = ChoiceState.UseChar; } else if (keyboard.IsKeyUp((Keys)Input.Down) && waitingKey == (Keys)Input.Down) { Sounds.PlayCue("MenuNav"); state = ChoiceState.UseChar; handIndex++; } else if (keyboard.IsKeyUp((Keys)Input.Up) && waitingKey == (Keys)Input.Up) { Sounds.PlayCue("MenuNav"); state = ChoiceState.UseChar; handIndex--; } return(true); case ChoiceState.UseChar: if (keyboard.IsKeyDown((Keys)Input.Confirm)) { waitingKey = (Keys)Input.Confirm; state = ChoiceState.ApplyItemReady; } else if (keyboard.IsKeyDown((Keys)Input.Up) && handIndex > 0) { state = ChoiceState.UseCharReady; waitingKey = (Keys)Input.Up; } else if (keyboard.IsKeyDown((Keys)Input.Down) && handIndex < party.ActiveMembers.Count - 1) { state = ChoiceState.UseCharReady; waitingKey = (Keys)Input.Down; } else if (keyboard.IsKeyDown((Keys)Input.Cancel)) { state = ChoiceState.UseReady; waitingKey = (Keys)Input.Cancel; } return(true); case ChoiceState.ApplyItemReady: if (keyboard.IsKeyUp((Keys)Input.Confirm) && waitingKey == (Keys)Input.Confirm) { Sounds.PlayCue("Save"); state = ChoiceState.ApplyItem; } return(true); case ChoiceState.ApplyItem: //still need to change items around, can't use item right now state = ChoiceState.Use; handIndex = itemIndex; //Also, need to remove item after use, and determine if index is still ok. return(true); default: return(true); } }
public void ShowChoices(ChoiceState state, bool friendly) { object[] objArray1 = new object[] { state, friendly }; base.method_8("ShowChoices", objArray1); }
/// <summary> /// 点击成员标题 /// </summary> private void OnClickChoiceMember() { MainChoiceState = ChoiceState.Member; }
void UnitSelected() { state = ChoiceState.ACTION; }