public T CreateDialog <T>(DialogEnum dialogType, DialogView.IDialogCallBack callBack, DialogBean dialogBean, float delayDelete) where T : DialogView
    {
        string     dialogName = EnumUtil.GetEnumName(dialogType);
        GameObject objDialog  = CreateDialog(dialogName);

        if (objDialog)
        {
            DialogView dialogView = objDialog.GetComponent <DialogView>();
            if (dialogView == null)
            {
                Destroy(objDialog);
            }
            dialogView.SetCallBack(callBack);
            dialogView.SetData(dialogBean);
            if (delayDelete != 0)
            {
                dialogView.SetDelayDelete(delayDelete);
            }

            //改变焦点
            EventSystem.current.SetSelectedGameObject(objDialog);

            listDialog.Add(dialogView);
            return(dialogView as T);
        }
        else
        {
            LogUtil.LogError("没有找到指定Toast:" + "Resources/UI/Toast/" + dialogName);
            return(null);
        }
    }
    public void StartDialog(DialogEnum dialogenum, UnityEngine.Events.UnityAction afterbuttonclicked, string closebuttontext)
    {
        DialogDataHolder dialogDataHolder = GetDialogDataHolder(dialogenum);
        string           text             = GetLanguageText(dialogDataHolder);
        Sprite           sprite           = GetLanguageImage(dialogDataHolder);

        DialogBoxController.instance.ShowDialogBox(text, TEXT_DELAY, sprite, afterbuttonclicked, closebuttontext);
    }
Exemple #3
0
        public static ContentDialog GetContentDialog(DialogEnum dialogType, object dialogContent = default)
        {
            ContentDialog dialog;

            switch (dialogType)
            {
            case DialogEnum.EditNoteDialog:
                dialog = new EditNoteContentDialog
                {
                    Height      = Window.Current.Bounds.Height,
                    Width       = Window.Current.Bounds.Width,
                    DataContext = (UpdateNote)dialogContent
                };
                break;

            case DialogEnum.DeleteNoteDialog:
                dialog = new DeleteNoteContentDialog
                {
                    DataContext = dialogContent
                };
                break;

            case DialogEnum.DeleteAccountDialog:
                dialog = new DeleteAccountContentDialog
                {
                    DataContext = dialogContent
                };
                break;

            case DialogEnum.DeleteFavoriteDialog:
                dialog = new DeleteFavoriteContentDialog
                {
                    DataContext = dialogContent
                };
                break;

            case DialogEnum.ConnectNetworkDialog:
                dialog = new ConnectNetworkDialog();
                break;

            case DialogEnum.CreateUserDialog:
                dialog = new CreateUserDialog
                {
                    Height      = Window.Current.Bounds.Height,
                    Width       = Window.Current.Bounds.Width,
                    DataContext = (CreateAccount)dialogContent
                };
                break;

            default:
                var content = (string)dialogContent;
                dialog = new StandardDialog(content);
                break;
            }

            return(dialog);
        }
 public bool ShowDialog(DialogEnum dialogEnum, string title, string message)
 {
     this.Owner = Application.Current.MainWindow;
     this.Icon  = Application.Current.MainWindow.Icon;
     ((DialogWindowViewModel)this.DataContext).DialogTitle   = title;
     ((DialogWindowViewModel)this.DataContext).DialogMessage = message;
     this.CannelBtn.Visibility = dialogEnum == DialogEnum.Ok ? Visibility.Collapsed : Visibility.Visible;
     return(this.ShowDialog() ?? false);
 }
Exemple #5
0
    /*****************************************************************************/
    /*							DIALOGS											 */
    /*****************************************************************************/

    // display a line of a Dialog. Return false if the dialog is finished.
    public void DisplayDialog(DialogEnum dialogEnum)
    {
        Dialog dialog = dialogDico [dialogEnum];

        gc.DisplayDialog(true);          // pause the game
        dialogPanel.SetActive(true);
        DisplayTopUI(false);
        DisplayMobileController(true, false);
        dialogPanel.GetComponent <DialogController> ().dialog = dialog;
        dialogPanel.GetComponent <DialogController> ().DisplayDialog();
    }
    public void StartDialog(DialogEnum dialogenum)
    {
        DialogDataHolder dialogDataHolder = GetDialogDataHolder(dialogenum);
        string           text             = GetLanguageText(dialogDataHolder);
        Sprite           sprite           = GetLanguageImage(dialogDataHolder);

        try
        {
            DialogBoxController.instance.ShowDialogBox(text, TEXT_DELAY, sprite);
        }

        catch
        {
            Debug.LogError("something went wrong when looking up the key in the dictionary");
        }
    }
Exemple #7
0
    public T CreateDialog <T>(DialogEnum dialogType, Action <DialogView, DialogBean> actionSubmit, Action <DialogView, DialogBean> actionCancel, DialogView.IDialogCallBack callBack, DialogBean dialogBean, float delayDelete) where T : DialogView
    {
        string     dialogName     = EnumUtil.GetEnumName(dialogType);
        GameObject objDialogModel = manager.GetDialogModel(dialogName);

        if (objDialogModel == null)
        {
            LogUtil.LogError("没有找到指定Dialog:" + dialogName);
            return(null);
        }

        GameObject objDialog = Instantiate(gameObject, objDialogModel);

        if (objDialog)
        {
            DialogView dialogView = objDialog.GetComponent <DialogView>();
            if (dialogView == null)
            {
                Destroy(objDialog);
            }
            dialogView.SetCallBack(callBack);
            dialogView.SetAction(actionSubmit, actionCancel);
            dialogView.SetData(dialogBean);
            if (delayDelete != 0)
            {
                dialogView.SetDelayDelete(delayDelete);
            }

            //改变焦点
            EventSystem.current.SetSelectedGameObject(objDialog);
            manager.AddDialog(dialogView);
            return(dialogView as T);
        }
        else
        {
            LogUtil.LogError("没有实例化Dialog成功:" + dialogName);
            return(null);
        }
    }
Exemple #8
0
 public T CreateDialog <T>(DialogEnum dialogType, DialogBean dialogBean, Action <DialogView, DialogBean> actionSubmit, Action <DialogView, DialogBean> actionCancel) where T : DialogView
 {
     return(CreateDialog <T>(dialogType, actionSubmit, actionCancel, null, dialogBean, 0));
 }
Exemple #9
0
 public T CreateDialog <T>(DialogEnum dialogType, DialogView.IDialogCallBack callBack, DialogBean dialogBean) where T : DialogView
 {
     return(CreateDialog <T>(dialogType, null, null, callBack, dialogBean, 0));
 }
Exemple #10
0
        private void OpenDialog(DialogEnum dialogEnum)
        {
            ViewModelBase viewModelBase = null;
            var           dialogKey     = string.Empty;

            switch (dialogEnum)
            {
            case DialogEnum.TabellaFilettatura:
            {
                var tabellaFilettatura = PathFolderHelper.GetTabellaFilettatura();

                /*
                 * todo prendere measure unit da preferenze
                 */
                viewModelBase = new TabellaFilettaturaViewModel(tabellaFilettatura, Singleton.Instance.MeasureUnit);

                dialogKey = Constants.TabellaFilettaturaModalDialog;
            } break;

            case DialogEnum.MacchineDialogo:
            {
                viewModelBase = new MacchineDialogViewModel(_machines);
                dialogKey     = Constants.MacchineModalDialog;
            } break;

            case DialogEnum.MaterialiDialogo:
            {
                //var magazzinoUtensile = PathFolderHelper.GetMagazzinoUtensile();

                viewModelBase = new MaterialiDialogoViewModel();

                dialogKey = Constants.MaterialiModalDialog;
            } break;

            case DialogEnum.UtensiliDialogo:
            {
                //var magazzinoUtensile = PathFolderHelper.GetMagazzinoUtensile();

                viewModelBase = new UtensiliDialogoViewModel(Singleton.Instance.MeasureUnit);

                dialogKey = Constants.UtensiliModalDialog;
            } break;

            case DialogEnum.DettagliArticolo:
            {
                viewModelBase = new ArticleDetailViewModel();

                dialogKey = Constants.ArticleDetailDialog;
            } break;

            case DialogEnum.ProgramPreference:
            {
                var preference = PathFolderHelper.GetPreferenceData();

                if (preference == null)
                {
                    // Creo nuovo e apro finestra dialogo preferenze
                    preference = new ProgramPreference();
                    PathFolderHelper.SavePreferenceFile(preference);
                }

                viewModelBase = new ProgramPreferenceViewModel(preference);

                dialogKey = Constants.PreferenceModalDialog;
            } break;

            case DialogEnum.UnitSelection:
            {
                var preference = PathFolderHelper.GetPreferenceData();

                if (preference == null)
                {
                    // Creo nuovo e apro finestra dialogo preferenze
                    preference = new ProgramPreference();
                    PathFolderHelper.SavePreferenceFile(preference);
                }

                viewModelBase = new ProgramPreferenceViewModel(preference);

                dialogKey = Constants.UnitSelectionDialog;
            } break;

            default:
                throw new NotImplementedException("MainViewModel.OpenDialog");
            }

            var dialog = SimpleServiceLocator.Instance.Get <IModalWindow>(dialogKey);

            _modalDialogService.ShowDialog(dialog, viewModelBase,
                                           returnedViewModelInstance =>
            {
                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    if (viewModelBase is IDialog)
                    {
                        var d = viewModelBase as IDialog;

                        d.Save(this);
                    }
                }
            });
        }
Exemple #11
0
        protected override void Update(GameTime gameTime)
        {
            t += dt;
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || currentGameState == GameStateEnum.WINDOW_CLOSE)
            {
                this.Exit();
            }



            Global.keyboardHelper.Update(gameTime);
            Global.mouseHelper.Update(gameTime);

            if (dialogEven == DialogEnum.SHOW_ANNOUNCE)
            {
                if (Global.mouseHelper.isLButtonUp())
                {
                    if (annouceDialog.getOption(Global.mouseHelper.getCurrentMousePosition()) == 0)
                    {
                        dialogEven = DialogEnum.NONE;
                    }
                    dialogEven = DialogEnum.NONE;
                }
                return;
            }
            if (dialogEven == DialogEnum.INPUTTEXT)
            {
                if (Global.keyboardHelper.IsKeyPressed(Keys.Back))
                {
                    playerName = "";
                    inputDialog.setText(playerName);
                }
                else if (Global.keyboardHelper.IsKeyPressed(Keys.Enter))
                {
                    dialogEven       = DialogEnum.NONE;
                    currentGameState = GameStateEnum.GAME_LOAD;
                }
                else if (Global.mouseHelper.isLButtonUp())
                {
                    if (annouceDialog.getOption(Global.mouseHelper.getCurrentMousePosition()) == 0)
                    {
                        dialogEven       = DialogEnum.NONE;
                        currentGameState = GameStateEnum.GAME_LOAD;
                    }
                }

                else if (Global.keyboardHelper.isPressAnykey() && t % 1 == 0)
                {
                    Keys k = Global.keyboardHelper.getKeyUp();
                    if (k != Keys.NumLock)
                    {
                        playerName += k.ToString();
                        inputDialog.setText(playerName);
                    }
                }

                return;
            }

            if (currentGameState == GameStateEnum.GAME_PAUSE)
            {
                //Window.Title = " all step " + player.TotalStep + " treasuse: " + player.TreaseList.Count;
                return;
            }
            #region show menu
            if (currentGameState == GameStateEnum.GAME_MENU)
            {
                if (Global.mouseHelper.isLButtonUp())
                {
                    if (menu.getOption(Global.mouseHelper.getCurrentMousePosition()) == 0)
                    {
                        dialogEven = DialogEnum.INPUTTEXT;
                    }
                }
            }
            #endregion

            #region game load
            if (currentGameState == GameStateEnum.GAME_LOAD)
            {
                //load(currentRow, currentCol, 2, 2, 2, 8);
                load();
                player.transact(Global.map.getEntrance());
                currentGameState = GameStateEnum.GAME_START;
            }
            #endregion

            #region game start
            if (currentGameState == GameStateEnum.GAME_START)
            {
                player.Update(gameTime);
                if (Global.keyboardHelper.isPressAnykey())
                {
                    currentGameState = GameStateEnum.GAME_PLAYING;
                }
            }
            #endregion

            #region game playing
            if (currentGameState == GameStateEnum.GAME_PLAYING)
            {
                //Global.playerPos.X = player.LogicX;
                //Global.playerPos.Y = player.LogicY;


                if (Global.keyboardHelper.IsKeyPressed(Keys.A))
                {
                    player.setState(UnitStateEnum.MOVELEFT);
                    if (Global.map.canGo((int)player.LogicX - 1, (int)player.LogicY))
                    {
                        player.transact(player.LogicX - 1, player.LogicY);
                    }
                }
                else if (Global.keyboardHelper.IsKeyPressed(Keys.D))
                {
                    player.setState(UnitStateEnum.MOVERIGHT);
                    if (Global.map.canGo((int)player.LogicX + 1, (int)player.LogicY))
                    {
                        player.transact(player.LogicX + 1, player.LogicY);
                    }
                }
                else if (Global.keyboardHelper.IsKeyPressed(Keys.W))
                {
                    player.setState(UnitStateEnum.MOVEBACK);
                    if (Global.map.canGo((int)player.LogicX, (int)player.LogicY - 1))
                    {
                        player.transact(player.LogicX, player.LogicY - 1);
                    }
                }
                else if (Global.keyboardHelper.IsKeyPressed(Keys.S))
                {
                    player.setState(UnitStateEnum.MOVEFORWAR);
                    if (Global.map.canGo((int)player.LogicX, (int)player.LogicY + 1))
                    {
                        player.transact(player.LogicX, player.LogicY + 1);
                    }
                }

                subMenu.updateTotalStep(player.TotalStep);

                //Win game
                Vector2 exit = Global.map.getExit();
                if (player.LogicX == exit.X && player.LogicY == exit.Y)
                {
                    currentGameState = GameStateEnum.GAME_END;
                }

                int n = monsterList.Count;
                for (int i = 0; i < n; i++)
                {
                    monsterList[i].Update(gameTime);
                    if (monsterList[i].isOverridePlayer(player.LogicX, player.LogicY))
                    {
                        currentGameState = GameStateEnum.GAME_END;
                    }
                }

                player.Update(gameTime);

                int tn = treasureList.Count;
                for (int i = 0; i < tn; i++)
                {
                    treasureList[i].Update(gameTime);
                    if (treasureList[i].isOverridePlayer(player.LogicX, player.LogicY))
                    {
                        if (player.collectTreasure(treasureList[i]))
                        {
                            collect.Play();
                            treasureList.RemoveAt(i);
                            subMenu.updateTotalWeight(player.getTotalWeight());
                            subMenu.updateTotalTreasure(player.TreaseList.Count);
                            tn--;
                        }
                    }
                }
            }
            #endregion

            #region game end
            if (currentGameState == GameStateEnum.GAME_END)
            {
                float playerScore = 0;
                if (player.TreaseList.Count > 1 && player.isOverridePlayer(Global.map.getExit()))
                {
                    int   count = Global.map.getListRoad().Count;
                    float score = 3 * count - player.TotalStep;
                    playerScore = score > 0 ? score : 0;
                }
                MediaPlayer.Stop();
                endGame.Play();

                resultDialog.updateResultDialog(playerScore);
                currentGameState = GameStateEnum.SHOW_RESULT;
            }
            #endregion

            #region show result
            if (currentGameState == GameStateEnum.SHOW_RESULT)
            {
                if (Global.mouseHelper.isLButtonUp())
                {
                    int result = resultDialog.getOption(Global.mouseHelper.getCurrentMousePosition());
                    switch (result)
                    {
                    case 0:
                        currentGameState = GameStateEnum.WINDOW_CLOSE;
                        break;

                    case 1:
                        currentGameState = GameStateEnum.GAME_LOAD;
                        break;

                    case 2:
                        log.outJsonFile();
                        annouceDialog.setText("File have been save!");
                        dialogEven = DialogEnum.SHOW_ANNOUNCE;
                        break;
                    }
                }
            }
            #endregion

            if (currentGameState == GameStateEnum.GAME_PLAYING || currentGameState == GameStateEnum.GAME_START)
            {
                if (Global.mouseHelper.isLButtonUp())
                {
                    int result = subMenu.getOption(Global.mouseHelper.getCurrentMousePosition());
                    switch (result)
                    {
                    case 0:    //exit
                        currentGameState = GameStateEnum.GAME_END;
                        break;

                    case 1:    //10x15
                        currentRow       = 10;
                        currentCol       = 15;
                        currentGameState = GameStateEnum.GAME_LOAD;
                        break;

                    case 2:    //15x15
                        currentRow       = 15;
                        currentCol       = 15;
                        currentGameState = GameStateEnum.GAME_LOAD;
                        break;

                    case 3:    //15x20
                        currentRow       = 15;
                        currentCol       = 20;
                        currentGameState = GameStateEnum.GAME_LOAD;
                        break;
                    }
                }
            }

            base.Update(gameTime);
        }
 DialogDataHolder GetDialogDataHolder(DialogEnum dialogenum)
 {
     return(arrayDialogDataHolder.Where(p => p.dialogEnum == dialogenum).First());
 }