public void UsingItem(PropertyChar p) { if (p.Count > 0) { p.Count = p.Count - 1; } FlagAction.DoFlagAction(TriggerGame.Instance.WorldFlag, AutoTileMap_Editor.Instance.MapsData.ListFlagAction, p.PropertyBase.ActionUsing); if (p.Count <= 0) { PropertysChar.Remove(p); } ShouldUpdateGUIContent = true; }
private void GoNextChoise(ScriptGui.MsgboxChoise choise, int countStack = 0) { // UI InputFieldHelper.Instance.HidePopupAction(); // InputFieldHelper.Instance.HideChatBottom(); // Logic var scriptGameMSG = mScriptGameMSG; // ResumeMainChar(); mScriptGameMSG = null; mMsgboxChat = null; //Check Action Flag if (choise.Action != null && choise.Action.Key != null && scriptGameMSG.Script.FlagActions.IndexOf(choise.Action) > 0 && scriptGameMSG.Flags != null && scriptGameMSG.Flags.ContainsKey(choise.Action.Key)) { FlagAction.DoFlagAction(scriptGameMSG.Flags, scriptGameMSG.Script.FlagActions, choise.Action); } scriptGameMSG.NextActionTo(choise.Next, countStack); }
private void DoAction(int scopeIndext, int countStack) { if (countStack > 24) { InputFieldHelper.Instance.ShowNoti(string.Format("Error at Script ({0}): : Over stack scope call!", IdxScript)); EndAction(); return; } ScriptGui.ActionData action = _scriptTarget.ActionDataAt(scopeIndext); switch (action.Format) { case ScriptGui.EFormatScope.End: { if (mIsMain) { Debug.Log("DoAction: End"); } EndAction(); return; } case ScriptGui.EFormatScope.Check: { if (mIsMain) { Debug.Log("DoAction: Check"); } var flagTarget = FlagByTarget(action.Check.Target); string flag = (action.Check.Flag != null ? action.Check.Flag : ""); if (flag == "" || flagTarget == null || flagTarget.ContainsKey(flag) == false) { InputFieldHelper.Instance.ShowNoti(string.Format("Error at Script ({0}): Not found flag {1}", IdxScript, flag)); EndAction(); return; } if (ScriptGui.Compare_A_B(flagTarget[flag], action.Check.Value, (ScriptGui.ECompare)action.Check.Compare)) { var t = action.Check.Right; NextActionTo(t, countStack + 1); } else { if (action.Check.SubCheck != null) { for (int i = 0; i < action.Check.SubCheck.Count; i++) { var subCheck = action.Check.SubCheck[i]; if (subCheck == null) { continue; } if (ScriptGui.Compare_A_B(flagTarget[flag], subCheck.Value, (ScriptGui.ECompare)subCheck.Compare)) { NextActionTo(subCheck.Right, countStack + 1); return; } } } var t = action.Check.Wrong; NextActionTo(t, countStack + 1); } return; } case ScriptGui.EFormatScope.Set: { if (mIsMain) { Debug.Log("DoAction: Set"); } var flagTarget = FlagByTarget(action.Set.Target); List <FlagAction> flagActions = ListFlagActionByTarget(action.Set.Target); FlagAction.DoFlagAction(flagTarget, flagActions, action.Set.Action); var t = action.Set.Next; NextActionTo(t, countStack + 1); return; } case ScriptGui.EFormatScope.MsgboxChat: { if (!mIsMain) { InputFieldHelper.Instance.ShowNoti(string.Format("Error at Script ({0}): Can't using Msg Box Chat on Sub Script", IdxScript)); EndAction(); return; } if (TriggerGame.Instance.MSG.ScriptGameMSG == null || TriggerGame.Instance.MSG.ScriptGameMSG == this) { Debug.Log("MsgboxChat, Name: " + action.Name + ", Index: " + scopeIndext); if (OBJTarget != null && OBJTarget.activeSelf) { AutoTileMap_Editor.Instance.RequestAgentFaceToNpc(OBJTarget, () => { TriggerGame.Instance.StartMsg(this, action, countStack); }); } else { TriggerGame.Instance.StartMsg(this, action, countStack); } } else { EndAction(); } return; } case ScriptGui.EFormatScope.NPC: { var npc = action.NPCAction; DoActionNPC(scopeIndext, countStack, npc); return; } case ScriptGui.EFormatScope.MainChar: { var mainAction = action.MainCharAction; if (!mIsMain) { InputFieldHelper.Instance.ShowNoti(string.Format("Error at Script ({0}): Can't control MainChar on Sub Script", IdxScript)); EndAction(); return; } switch (mainAction.Action) { case ScriptGui.MainCharAction.EAction.WaitMoveToPos: { InputFieldHelper.Instance.HidePopupAction(); InputFieldHelper.Instance.HideChatBottom(); AutoTileMap_Editor.Instance.ResetMainCamWithAni(() => { bool success = TriggerGame.Instance.WaitGoToCheckPoint(this, mainAction.x, mainAction.y, () => { TriggerGame.Instance.SetTip(""); // Next action var t = mainAction.Next; NextActionTo(t, 0); }); if (!success) { EndAction(); } }); break; } case ScriptGui.MainCharAction.EAction.WaitMoveToHouse: { if (mainAction.IdHouse < 0) { EndAction(); return; } InputFieldHelper.Instance.HidePopupAction(); InputFieldHelper.Instance.HideChatBottom(); AutoTileMap_Editor.Instance.ResetMainCamWithAni(() => { bool success = TriggerGame.Instance.WaitEnterHouse(this, mainAction, (int houseIdx) => { // Next action TriggerGame.Instance.SetTip(""); var t = mainAction.Next; NextActionTo(t, 0); }); if (!success) { EndAction(); } }); break; } case ScriptGui.MainCharAction.EAction.WaitInteractionsNPC: { if (mainAction.IdNpc < 0) { EndAction(); return; } InputFieldHelper.Instance.HidePopupAction(); InputFieldHelper.Instance.HideChatBottom(); AutoTileMap_Editor.Instance.ResetMainCamWithAni(() => { bool success = TriggerGame.Instance.WaitInteractionNPC(this, mainAction, (int r) => { // Next action TriggerGame.Instance.SetTip(""); var t = mainAction.Next; NextActionTo(t, 0); return(true); }); if (!success) { EndAction(); } }); break; } case ScriptGui.MainCharAction.EAction.RewardItem: { PropertysGame.Instance.AddItem(AutoTileMap_Editor.Instance.MapsData.Propertys, mainAction.SlugItem); TriggerGame.Instance.SetTip(""); var t = mainAction.Next; NextActionTo(t, 0); return; } case ScriptGui.MainCharAction.EAction.CheckItem: { if (PropertysGame.Instance.IsHaveItem(mainAction.SlugItem)) { NextActionTo(mainAction.Next, 0); } else { NextActionTo(mainAction.Wrong, 0); } return; } case ScriptGui.MainCharAction.EAction.BuyItem: { SerializablePackages.Package package = AutoTileMap_Editor.Instance.MapsData.Packages.PackageBySlug(mainAction.SlugPackage); if (package == null) { EndAction(); } else { // TriggerGame.Instance.StopMainChar(); TriggerGame.Instance.ResetLogChat(); var lastAction = action; ShopGame.Instance.ShowWithData(AutoTileMap_Editor.Instance.MapsData.Propertys, package, () => { // Close dialog NextActionTo(mainAction.Wrong, 0); }, (ControlShop pm) => { // If buy something if (mainAction.Next == null || mainAction.Next == lastAction) { // Try buy orther InputFieldHelper.Instance.ShowChatBottom("Continue shopping?", false, (TypingEffectByLine ty) => { pm.contentPane.visible = true; }); } else { NextActionTo(mainAction.Next, 0); } }); } return; } case ScriptGui.MainCharAction.EAction.WarpTo: { EndAction(); var triggerRef = mainAction.IdWarp; if (triggerRef >= 0 && triggerRef < AutoTileMap_Editor.Instance.MapSelect.WarpsData.Count) { var w = AutoTileMap_Editor.Instance.MapSelect.WarpsData[triggerRef]; Debug.Log("GoTo: " + w.map + "_" + w.x + "_" + w.y); AutoTileMap_Editor.Instance.WarpsTo(w.map, w.x, w.y); // AutoTileMap_Editor.Instance.SetModePlay(true, w.map); } return; } default: { EndAction(); return; } } if (mainAction.Tip != "") { TriggerGame.Instance.SetTip(mainAction.Tip); } break; } default: { EndAction(); break; } } }