Beispiel #1
0
        public static void Init(UIHost host)
        {
            uiHost = host;
            tasks.Clear();
            foreach (var taskXmlFile in ProjectFiles.GetFiles("task"))
            {
                XElement xmlRoot = Tools.LoadXml(Application.dataPath + taskXmlFile);
                foreach (var taskNode in xmlRoot.Elements("task"))
                {
                    Task task = new Task();
                    task.key   = Tools.GetXmlAttribute(taskNode, "key");
                    task.desc  = Tools.GetXmlAttribute(taskNode, "desc");
                    task.type  = Tools.GetXmlAttribute(taskNode, "type");
                    task.value = Tools.GetXmlAttribute(taskNode, "value");
                    if (taskNode.Attribute("repeat") != null)
                    {
                        task.repeat = Tools.GetXmlAttribute(taskNode, "repeat") == "once" ? false : true;
                    }
                    else
                    {
                        task.repeat = true;
                    }

                    tasks.Add(task.key, task);
                }
            }
        }
Beispiel #2
0
        protected ListViewModel(IApi api, UIHost uiHost)
        {
            Api    = api;
            UIHost = uiHost;

            ShowEditorCommand = new RelayCommand(ShowEditor);
        }
Beispiel #3
0
 public static void Init(UIHost host)
 {
     uiHost = host;
     storys = new Dictionary <string, Story>();
     foreach (string dialogXmlFile in ProjectFiles.GetFiles("story"))
     {
         XElement xmlRoot = Tools.LoadXml(Application.dataPath + dialogXmlFile);
         foreach (var storyNode in xmlRoot.Elements("story"))
         {
             Story story = new Story();
             story.Name = Tools.GetXmlAttribute(storyNode, "name");
             //actions
             foreach (var actionNode in storyNode.Elements("action"))
             {
                 story.Actions.Add(Action.Parse(actionNode));
             }
             //results
             foreach (var resultNode in storyNode.Elements("result"))
             {
                 story.Results.Add(Result.Parse(resultNode));
             }
             storys.Add(story.Name, story);
         }
     }
 }
Beispiel #4
0
        public MainViewModel(IApi api, UIHost uiHost, FolderListViewModel folderList, NoteListViewModel noteList)
        {
            Api        = api;
            UIHost     = uiHost;
            FolderList = folderList;
            NoteList   = noteList;

            ShowSettingsCommand = new RelayCommand(ShowSettings);
        }
Beispiel #5
0
 public override void Cleanup()
 {
     if (UIHost != null)
     {
         UIHost.Cleanup();
         UIHost = null;
     }
     base.Cleanup();
 }
        public virtual void TickLogic()
        {
            var rc = CEngine.Instance.RenderContext;

            World?.Tick();
            World?.CheckVisible(rc.ImmCommandList, mCamera);
            UIHost?.Commit(rc.ImmCommandList);
            mRP_OffScreen.TickLogic(null, rc);
        }
Beispiel #7
0
        public NoteListViewModel(IApi api, UIHost uiHost, FolderListViewModel folderList) : base(api, uiHost)
        {
            FolderList = folderList;
            FolderList.SelectionChanged += FolderList_SelectionChanged;

            Api.EventBus.Subscribe <NoteAddedEvent>(Note_Added, x => x.Model.FolderId == FolderList.SelectedItem?.Id);
            Api.EventBus.Subscribe <NoteUpdatedEvent>(Note_Updated, x => x.Model.FolderId != FolderList.SelectedItem?.Id);
            Api.EventBus.Subscribe <NoteMovedToFolderEvent>(Note_MovedToFolder, x => x.FolderId != FolderList.SelectedItem?.Id);
            Api.EventBus.Subscribe <NoteDeletedEvent>(Note_Deleted);
        }
Beispiel #8
0
        protected ListItemViewModel(Guid id, IApi api, UIHost uiHost)
        {
            Id = id;

            Api    = api;
            UIHost = uiHost;

            ShowEditorCommand = new RelayCommand(ShowEditor);
            DeleteCommand     = new AsyncRelayCommand(Delete, CanDelete);
        }
Beispiel #9
0
        public NoteItemViewModel(NoteModel model, IApi api, UIHost uiHost) : base(model.Id, api, uiHost)
        {
            FolderId            = model.FolderId;
            ToggleFlagCommand   = new AsyncRelayCommand(ToggleFlag);
            MoveToFolderCommand = new AsyncRelayCommand <Guid>(MoveToFolder);

            Update(model);

            Api.EventBus.Subscribe <NoteUpdatedEvent>(x => Update(x.Model), x => x.Model.Id == Id);
            Api.EventBus.Subscribe <NoteFlagChangedEvent>(x => IsFlagged = x.IsFlagged, x => x.Id == Id);
        }
Beispiel #10
0
        private void AddPostDrawHook()
        {
            if (Main.dedServ)
            {
                return;
            }

            UIHost = new UIHost();

            Main.OnPostDraw += OnPostDraw;
        }
Beispiel #11
0
        public BattleBlock(BattleField bfield, UIHost uihost)
        {
            InitializeComponent();
            this.MouseEnter        += new MouseEventHandler(BattleBlock_MouseEnter);
            this.MouseLeave        += new MouseEventHandler(BattleBlock_MouseLeave);
            this.MouseLeftButtonUp += new MouseButtonEventHandler(BattleBlock_MouseLeftButtonUp);
            battleField             = bfield;
            this.uiHost             = uihost;

            ResetColor();
        }
Beispiel #12
0
        public void displayMove(UIHost uihost)
        {
            //uihost.battleFieldContainer.field.BlockUnselective();
            //uihost.battleFieldContainer.field.Status = BattleStatus.Moving;
            uihost.battleFieldContainer.field.RoleMoveTo(x, y, true);

            //Spirit currentSpirit = uihost.battleFieldContainer.field.currentSpirit;
            //currentSpirit.X = x;
            //currentSpirit.Y = y;
            //currentSpirit.FaceRight = faceright;
        }
Beispiel #13
0
 private static void ShowContextMenuInternal(int menuId, POINTS[] p, IOleCommandTarget commandTarget)
 {
     try
     {
         VsUIShell.ShowContextMenu(uint.MaxValue, ref CommandSetGuid, menuId, p, commandTarget);
     }
     catch (Exception ex)
     {
         int num = (int)UIHost.ShowException(ex);
     }
 }
Beispiel #14
0
 public void displaySkill(UIHost uihost, CommonSettings.VoidCallBack callback)
 {
     if (OLBattleGlobalSetting.Instance.battleData.currentSkill.actionType == "SKILL")
     {
         uihost.battleFieldContainer.field.ShowOLSkillAnimation(callback);
     }
     else
     {
         callback();
     }
 }
        internal static void OpenSolutionWithWorkspace(Workspace workspace, string serverItem, VersionSpec spec)
        {
            serverItem = VersionControlPath.GetFullPath(serverItem);
            WorkingFolder folderForServerItem1;

            try
            {
                folderForServerItem1 = workspace.TryGetWorkingFolderForServerItem(serverItem);
            }
            catch (Exception ex)
            {
                Output.Exception(ex);
                return;
            }
            if (folderForServerItem1 != null)
            {
                if (folderForServerItem1.IsCloaked)
                {
                    int num1 = (int)Error(UIHost.DefaultParentWindow, GuiResources.Format("SolutionIsCloaked", (object)VersionControlPath.GetFileName(serverItem)), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    try
                    {
                        VssProvider.OpenFromSCC(serverItem, FileSpec.GetDirectoryName(folderForServerItem1.LocalItem), spec.DisplayString, VersionControlOpenFromSccOverwrite.openscc_open_local_version);
                    }
                    catch (Exception ex)
                    {
                        Output.Exception(ex);
                    }
                }
            }
            else
            {
                string folderName = VersionControlPath.GetFolderName(serverItem);
                using (var dialogSetLocalFolder = (Form)TeamControlFactory.CreateDialogSetLocalFolder(workspace, folderName))
                {
                    if (UIHost.ShowModalDialog((Form)dialogSetLocalFolder) != DialogResult.OK)
                    {
                        return;
                    }
                }
                try
                {
                    WorkingFolder folderForServerItem2 = workspace.GetWorkingFolderForServerItem(serverItem);
                    VssProvider.OpenFromSCC(serverItem, FileSpec.GetDirectoryName(folderForServerItem2.LocalItem), spec.DisplayString, VersionControlOpenFromSccOverwrite.openscc_open_local_version);
                }
                catch (Exception ex)
                {
                    Output.Exception(ex);
                }
            }
        }
Beispiel #16
0
        //判断天赋是否能发动
        public bool JudgeConditions(Role source, Role target, UIHost uihost)
        {
            bool triggered = true;

            foreach (TalentCondition condition in conditions)
            {
                if (!condition.JudgeCondition(source, target, uihost))
                {
                    triggered = false;
                    break;
                }
            }
            return(triggered);
        }
Beispiel #17
0
        public bool JudgeCondition(Role source, Role target, UIHost uihost)
        {
            if (type == "攻击方生命少于" && (source.Attributes["hp"] / (double)source.Attributes["maxhp"] > double.Parse(value)))
            {
                return(false);
            }

            if (type == "防御方生命少于" && (target.Attributes["hp"] / (double)target.Attributes["maxhp"] > double.Parse(value)))
            {
                return(false);
            }

            return(true);
        }
Beispiel #18
0
        public void GetLatest(string item)
        {
            Workspace workspace = this.GetWorkspace(item);

            if (workspace == null)
            {
                return;
            }

            string serverPath = workspace.TryGetServerItemForLocalItem(item);

            if (serverPath != null)
            {
                using (UIHost.GetWaitCursor())
                {
                    IVsFileChangeEx fce = serviceProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;
                    int             hr  = 0;

                    if (fce != null)
                    {
                        try
                        {
                            // Ignore file changes, so there is no Reload dialog
                            hr = fce.IgnoreFile(VSConstants.VSCOOKIE_NIL, item, 1);
                            Debug.Assert(hr == VSConstants.S_OK);
                            GetRequest getRequest = new GetRequest(serverPath, RecursionType.None, VersionSpec.Latest);
                            GetStatus  status     = workspace.Get(getRequest, GetOptions.None, null, null);
                            if (status != null && status.NumConflicts > 0)
                            {
                                // Trigger resolve conflicts tool window if there are any, to be consistent with solution explorer
                                this.dte.ExecuteCommand("File.TfsResumeConflictResolution");
                            }
                        }
                        finally
                        {
                            // Sync file so that file changes do not trigger events later when we un-ignore
                            hr = fce.SyncFile(item);
                            Debug.Assert(hr == VSConstants.S_OK);
                            hr = fce.IgnoreFile(VSConstants.VSCOOKIE_NIL, item, 0);
                            Debug.Assert(hr == VSConstants.S_OK);
                        }
                    }
                }
            }
        }
Beispiel #19
0
 public static void ShowContextMenu(Control control, int menuId, MouseEventArgs mouseArg, IOleCommandTarget commandTarget)
 {
     try
     {
         POINTS[] p = new POINTS[1]
         {
             new POINTS()
         };
         p[0].x = (short)mouseArg.X;
         p[0].y = (short)mouseArg.Y;
         Action action = (Action)(() => ShowContextMenuInternal(menuId, p, commandTarget));
         control.BeginInvoke((Delegate)action);
     }
     catch (Exception ex)
     {
         int num = (int)UIHost.ShowException(ex);
     }
 }
Beispiel #20
0
 public static void ShowContextMenu(System.Windows.Controls.Control control, int menuId, Point point, IOleCommandTarget commandTarget)
 {
     try
     {
         POINTS[] p = new POINTS[1]
         {
             new POINTS()
         };
         p[0].x = (short)point.X;
         p[0].y = (short)point.Y;
         Action action = (Action)(() => ShowContextMenuInternal(menuId, p, commandTarget));
         control.Dispatcher.BeginInvoke((Delegate)action);
     }
     catch (Exception ex)
     {
         int num = (int)UIHost.ShowException(ex);
     }
 }
Beispiel #21
0
        public void displayPreBattleEffect(UIHost uihost)
        {
            BattleField field = uihost.battleFieldContainer.field;

            //文字效果
            foreach (Spirit sp in field.Spirits)
            {
                if (preRoleWords.ContainsKey(sp.battleID))
                {
                    field.ShowSmallDialogBox(sp, preRoleWords[sp.battleID], 1.0);
                }

                if (preRoleAttackInfo.ContainsKey(sp.battleID))
                {
                    foreach (BattleWord battleWord in preRoleAttackInfo[sp.battleID])
                    {
                        sp.AddAttackInfo(battleWord.word, battleWord.color);
                    }
                }
            }

            //人物属性
            foreach (Spirit sp in field.Spirits)
            {
                if (preRoles.ContainsKey(sp.battleID))
                {
                    sp.Role = preRoles[sp.battleID];
                }

                if (preSpiritInfos.ContainsKey(sp.battleID))
                {
                    SpiritInfo info = preSpiritInfos[sp.battleID];
                    sp.X         = info.X;
                    sp.Y         = info.Y;
                    sp.FaceRight = info.faceright == 0?false:true;
                    sp.ItemCd    = info.itemCD;
                }

                sp.Refresh();
            }
        }
Beispiel #22
0
        public void Load(string battleKey, CommonSettings.IntCallBack callback)
        {
            CurrentScrollDirection = ScrollDirection.NONE;
            //战斗开始前先选择我方角色
            UIHost uihost = RuntimeData.Instance.gameEngine.uihost;

            uihost.mapUI.resetHead();
            uihost.scence.HideHeads();
            uihost.arenaSelectRole.confirmBack = () =>
            {
                //初始化战场
                uihost.Dispatcher.BeginInvoke(() =>
                {
                    this.Visibility = System.Windows.Visibility.Visible;
                    field.Load(battleKey, callback);
                    this.BattleFieldScrollable = true;
                    //uiHost.Chat(storyScenario);

                    this.IsEnabled = false;
                    this.FadeOut.Stop();
                    this.FadeIn.Begin();
                });
            };
            uihost.arenaSelectRole.cancel.Visibility = Visibility.Collapsed;

            int    maxFriendsNo = 0;
            Battle battle       = BattleManager.GetBattle(battleKey);

            foreach (BattleRole role in battle.battleRoles)
            {
                if (role.team == 1 && role.roleKey == null)
                {
                    maxFriendsNo += 1;
                }
            }

            uihost.arenaSelectRole.load(maxFriendsNo, battle.GetBattleMusts());
        }
 public static void ViewPendingChanges(Workspace workspace, IEnumerable <PendingChange> changes)
 {
     using (UIHost.GetWaitCursor())
     {
         foreach (PendingChange pendingChange in changes)
         {
             if (pendingChange.ItemType == ItemType.File)
             {
                 if ((pendingChange.ServerItem).EndsWith(".sln"))
                 {
                     TeamFoundationTrace.Info(VCTraceKeywordSets.PendingChanges, "View(VS):Opening solution/project '{0}'", (object)pendingChange.ServerItem);
                     OpenSolutionWithWorkspace(workspace, pendingChange.ServerItem, VersionSpec.Latest);
                 }
                 else
                 {
                     var str = VersionControlPath.GetTempFileName(pendingChange.ServerItem, pendingChange.Version);
                     pendingChange.DownloadBaseFile(str);
                     TryOpenFile(str);
                 }
             }
         }
     }
 }
        public virtual async System.Threading.Tasks.Task <bool> InitEnviroment(UInt32 w, UInt32 h, string name)
        {
            mWidth  = w;
            mHeight = h;
            var rc = EngineNS.CEngine.Instance.RenderContext;

            mCamera = new EngineNS.Graphics.CGfxCamera();
            mCamera.Init(rc, false);

            Vector3 Eye = new Vector3();

            Eye.SetValue(0.0f, 0.0f, -3.0f);
            Vector3 At = new Vector3();

            At.SetValue(0.0f, 0.0f, 0.0f);
            Vector3 Up = new Vector3();

            Up.SetValue(0.0f, 1.0f, 0.0f);
            mCamera.LookAtLH(Eye, At, Up);

            mCamera.PerspectiveFovLH(mCamera.mDefaultFoV, (float)mWidth, (float)mHeight, 0.1f, 1000.0f);
            mCamera.BeforeFrame();
            mCamera.SwapBuffer(false);

            mRP_OffScreen           = new EngineNS.Graphics.RenderPolicy.CGfxRP_OffScreen();
            mRP_OffScreen.OnDrawUI += (CCommandList cmd, Graphics.View.CGfxScreenView view) =>
            {
                if (UIHost != null)
                {
                    UIHost.Draw(CEngine.Instance.RenderContext, cmd, view);
                }
            };
            await mRP_OffScreen.Init(rc, mWidth, mHeight, mCamera, IntPtr.Zero);

            return(await InitWorld(name));
        }
 internal static DialogResult Error(IWin32Window owner, string text, string helpTopic, MessageBoxButtons buttons, MessageBoxIcon icon)
 {
     return(UIHost.ShowMessageBox(owner, text, helpTopic, "Error", buttons, icon, MessageBoxDefaultButton.Button1));
 }
Beispiel #26
0
 protected internal override void Initialize()
 {
     UI = new UIHost();
 }
        private void RefreshMyItems()
        {
            StackPanel  currentPanel = null;
            UIHost      uiHost       = RuntimeData.Instance.gameEngine.uihost;
            List <Item> xiangziItems = XiangziManager.Items;
            int         count        = 0;

            uiHost.shopPanel.myItemsPanel.RootPanel.Children.Clear();
            List <string> visitedItem = new List <string>();

            foreach (var item in RuntimeData.Instance.Items)
            {
                if (ItemTypeCombo.SelectedItem.ToString() == "武器" && (item.Type != (int)ItemType.Weapon))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "消耗品" && (item.Type != (int)ItemType.Costa))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "防具" && (item.Type != (int)ItemType.Armor))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "饰品" && (item.Type != (int)ItemType.Accessories))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "经书" && (item.Type != (int)ItemType.Book))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "任务物品" && (item.Type != (int)ItemType.Mission))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "技能书" && (item.Type != (int)ItemType.TalentBook) && item.Type != (int)ItemType.Upgrade)
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "残章" && (item.Type != (int)ItemType.Canzhang))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "特殊物品" && (item.Type != (int)ItemType.Special))
                {
                    continue;
                }
                if (count > 5)
                {
                    count = 0;
                }

                //只能存装备和残章
                if (item.Type != (int)ItemType.Armor &&
                    item.Type != (int)ItemType.Canzhang &&
                    item.Type != (int)ItemType.Weapon &&
                    item.Type != (int)ItemType.Accessories)
                {
                    continue;
                }
                if (count == 0)
                {
                    currentPanel             = new StackPanel();
                    currentPanel.Orientation = Orientation.Horizontal;
                    currentPanel.Height      = 58;
                    currentPanel.Margin      = new Thickness(2, 2, 2, 0);
                    uiHost.shopPanel.myItemsPanel.RootPanel.Children.Add(currentPanel);
                }
                int itemCount = 1;
                //如果不是装备,则层叠
                if (!(item.Type == (int)ItemType.Armor || item.Type == (int)ItemType.Accessories || item.Type == (int)ItemType.Weapon))
                {
                    if (visitedItem.Contains(item.Name))
                    {
                        continue;
                    }
                    itemCount = RuntimeData.Instance.Items.Count(p => p.Name == item.Name);
                    visitedItem.Add(item.Name);
                }
                ItemUnit c = new ItemUnit();
                c.BindItem(item);
                c.Margin    = new Thickness(2, 2, 2, 5);
                c.ItemCount = itemCount;
                Item tmp = item;
                c.MouseLeftButtonUp += (s, e) =>
                {
                    lock (this)
                    {
                        int maxItemCount = 4 + RuntimeData.Instance.Round * 3;
                        if (xiangziItems.Count + 1 > maxItemCount)
                        {
                            MessageBox.Show("你这个周目最多存放" + maxItemCount + "个装备");
                            uiHost.shopPanel.storePanel.ShowXiangzi();
                            //this.ShowXiangzi();
                            return;
                        }
                        xiangziItems.Add(item);
                        XiangziManager.Items = xiangziItems;
                        RuntimeData.Instance.Items.Remove(item);
                        //this.ShowXiangzi();
                        uiHost.shopPanel.storePanel.ShowXiangzi();
                        e.Handled = true;
                    }
                };
                ToolTipService.SetToolTip(c, item.GenerateTooltip());
                currentPanel.Children.Add(c);
                count++;
            }
        }
        // <summary>
        // 显示
        // </summary>
        // 只显示价格为正的产品(价格为零的是非卖品)
        public void Show(Shop shop)
        {
            AllSellButton.Visibility = System.Windows.Visibility.Collapsed;
            Type      = ShopType.SHOP;
            this.shop = shop;
            UIHost uiHost = RuntimeData.Instance.gameEngine.uihost;

            uiHost.RightClickCallback                = null;
            uiHost.shopPanel.SuggestText.Text        = "右键快捷购买";
            uiHost.shopPanel.myItemsPanel.Visibility = Visibility.Collapsed;
            Dictionary <ShopItem, int> sales = shop.GetAvaliableSales();

            RootPanel.Children.Clear();
            uiHost.itemSelectPanel.Show(RuntimeData.Instance.Items);//刷新物品栏
            this.money.Text   = RuntimeData.Instance.Money.ToString();
            this.yuanbao.Text = RuntimeData.Instance.YuanBao.ToString();

            foreach (var sale in sales.Keys)
            {
                Item item     = sale.Item;
                int  maxLimit = sales[sale];
                if (ItemTypeCombo.SelectedItem.ToString() == "武器" && (item.Type != (int)ItemType.Weapon))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "消耗品" && (item.Type != (int)ItemType.Costa))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "防具" && (item.Type != (int)ItemType.Armor))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "饰品" && (item.Type != (int)ItemType.Accessories))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "经书" && (item.Type != (int)ItemType.Book))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "任务物品" && (item.Type != (int)ItemType.Mission))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "技能书" && (item.Type != (int)ItemType.TalentBook) && item.Type != (int)ItemType.Upgrade)
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "残章" && (item.Type != (int)ItemType.Canzhang))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "特殊物品" && (item.Type != (int)ItemType.Special))
                {
                    continue;
                }

                ItemUnit c = new ItemUnit();
                c.image.Source = item.Pic;
                c.ItemName     = item.Name;
                c.Margin       = new Thickness(2, 2, 2, 5);
                if (maxLimit != -1)
                {
                    c.count.Text = maxLimit.ToString();
                }
                else
                {
                    c.count.Text = "";
                }
                string   info  = item.ToString();
                int      price = sale.Price;
                ShopItem tmp   = sale;
                c.MouseRightButtonUp += (s, e) =>
                {
                    if (uiHost.selectPanel.Visibility == System.Windows.Visibility.Visible)
                    {
                        return;
                    }
                    if (tmp.YuanBao == -1)
                    {
                        if (RuntimeData.Instance.Money >= price)
                        {
                            RuntimeData.Instance.Money -= price;
                            RuntimeData.Instance.Items.Add(tmp.Item.Clone());
                            AudioManager.PlayEffect(ResourceManager.Get("音效.装备"));
                            this.money.Text = RuntimeData.Instance.Money.ToString();
                            shop.BuyItem(tmp.Name);
                            this.Show(shop);
                        }
                        else
                        {
                            uiHost.dialogPanel.ShowDialog("汉家松鼠", "你的金钱不足!", null);
                        }
                    }
                    else
                    {
                        if (RuntimeData.Instance.YuanBao >= tmp.YuanBao)
                        {
                            RuntimeData.Instance.YuanBao -= tmp.YuanBao;
                            RuntimeData.Instance.Items.Add(tmp.Item.Clone());
                            AudioManager.PlayEffect(ResourceManager.Get("音效.装备"));
                            shop.BuyItem(tmp.Name);
                            this.Show(shop);
                        }
                        else
                        {
                            uiHost.dialogPanel.ShowDialog("汉家松鼠", "你的元宝不足!", null);
                        }
                    }
                    e.Handled = true;
                };
                c.MouseLeftButtonUp += (s, e) =>
                {
                    BuyItemWindow win = new BuyItemWindow();
                    win.Bind(tmp.Item, "购买物品", (number) =>
                    {
                        if (tmp.YuanBao == -1)
                        {
                            if (RuntimeData.Instance.Money >= price * number)
                            {
                                RuntimeData.Instance.Money -= price * number;
                                for (int i = 0; i < number; ++i)
                                {
                                    RuntimeData.Instance.Items.Add(tmp.Item.Clone());
                                }
                                AudioManager.PlayEffect(ResourceManager.Get("音效.装备"));
                                shop.BuyItem(tmp.Name, number);
                                this.Show(shop);
                            }
                            else
                            {
                                uiHost.dialogPanel.ShowDialog("汉家松鼠", "你的金钱不足!", null);
                            }
                        }
                        else
                        {
                            if (RuntimeData.Instance.YuanBao >= tmp.YuanBao * number)
                            {
                                RuntimeData.Instance.YuanBao -= tmp.YuanBao * number;
                                for (int i = 0; i < number; ++i)
                                {
                                    RuntimeData.Instance.Items.Add(tmp.Item.Clone());
                                }
                                AudioManager.PlayEffect(ResourceManager.Get("音效.装备"));
                                shop.BuyItem(tmp.Name, number);
                                this.Show(shop);
                            }
                            else
                            {
                                uiHost.dialogPanel.ShowDialog("汉家松鼠", "你的元宝不足!", null);
                            }
                        }
                    }, maxLimit);
                    win.Show();
                };



                RichTextBox rtb = item.GenerateTooltip();
                (rtb.Blocks[0] as Paragraph).Inlines.Add(new LineBreak());
                (rtb.Blocks[0] as Paragraph).Inlines.Add(new LineBreak());
                if (sale.YuanBao != -1)
                {
                    (rtb.Blocks[0] as Paragraph).Inlines.Add(new Run()
                    {
                        Text = "价格:" + tmp.YuanBao.ToString() + "个元宝", FontSize = 12, FontWeight = FontWeights.Bold
                    });
                }
                else
                {
                    (rtb.Blocks[0] as Paragraph).Inlines.Add(new Run()
                    {
                        Text = "价格:" + price.ToString() + "两白银", FontSize = 12, FontWeight = FontWeights.Bold
                    });
                }

                ToolTipService.SetToolTip(c, rtb);
                RootPanel.Children.Add(c);
            }

            this.Visibility = System.Windows.Visibility.Visible;
        }
        /// <summary>
        /// 显示箱子
        /// </summary>
        public void ShowXiangzi()
        {
            AllSellButton.Visibility = System.Windows.Visibility.Collapsed;
            Type = ShopType.XIANGZI;
            UIHost uiHost = RuntimeData.Instance.gameEngine.uihost;

            uiHost.RightClickCallback                = null;
            uiHost.shopPanel.SuggestText.Text        = "单击鼠标左键取出或存入装备";
            uiHost.shopPanel.myItemsPanel.Visibility = Visibility.Visible;
            uiHost.shopPanel.myItemsPanel.Type       = ShopType.MYITEMS;
            List <Item> xiangziItems = XiangziManager.Items;

            RootPanel.Children.Clear();

            this.money.Text = "";
            StackPanel    currentPanel = null;
            int           count        = 0;
            List <string> visitedItem  = new List <string>();

            foreach (var item in xiangziItems)
            {
                if (ItemTypeCombo.SelectedItem.ToString() == "武器" && (item.Type != (int)ItemType.Weapon))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "消耗品" && (item.Type != (int)ItemType.Costa))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "防具" && (item.Type != (int)ItemType.Armor))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "饰品" && (item.Type != (int)ItemType.Accessories))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "经书" && (item.Type != (int)ItemType.Book))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "任务物品" && (item.Type != (int)ItemType.Mission))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "技能书" && (item.Type != (int)ItemType.TalentBook) && item.Type != (int)ItemType.Upgrade)
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "残章" && (item.Type != (int)ItemType.Canzhang))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "特殊物品" && (item.Type != (int)ItemType.Special))
                {
                    continue;
                }
                if (count > 5)
                {
                    count = 0;
                }
                if (count == 0)
                {
                    currentPanel             = new StackPanel();
                    currentPanel.Orientation = Orientation.Horizontal;
                    currentPanel.Height      = 58;
                    currentPanel.Margin      = new Thickness(2, 2, 2, 0);
                    RootPanel.Children.Add(currentPanel);
                }
                int itemCount = 1;
                //如果不是装备,则层叠
                if (!(item.Type == (int)ItemType.Armor || item.Type == (int)ItemType.Accessories || item.Type == (int)ItemType.Weapon))
                {
                    if (visitedItem.Contains(item.Name))
                    {
                        continue;
                    }
                    itemCount = xiangziItems.Count(p => p.Name == item.Name);
                    visitedItem.Add(item.Name);
                }

                ItemUnit c = new ItemUnit();
                c.BindItem(item);
                c.Margin    = new Thickness(2, 2, 2, 5);
                c.ItemCount = itemCount;
                Item tmp = item;
                c.MouseLeftButtonUp += (s, e) =>
                {
                    lock (this)
                    {
                        if (xiangziItems.Remove(item))
                        {
                            RuntimeData.Instance.Items.Add(item);
                        }
                        XiangziManager.Items = xiangziItems;
                    }
                    this.ShowXiangzi();
                };
                ToolTipService.SetToolTip(c, item.GenerateTooltip());
                currentPanel.Children.Add(c);
                count++;
            }

            RefreshMyItems();

            this.Visibility = System.Windows.Visibility.Visible;
        }
        // <summary>
        // 显示
        // </summary>
        // 只显示价格为正的产品(价格为零的是非卖品)
        public void Show(SellShop shop)
        {
            AllSellButton.Visibility = System.Windows.Visibility.Visible;
            Type     = ShopType.SELL;
            sellShop = shop;
            UIHost uiHost = RuntimeData.Instance.gameEngine.uihost;

            uiHost.RightClickCallback = null;
            uiHost.shopPanel.myItemsPanel.Visibility = Visibility.Collapsed;
            uiHost.shopPanel.SuggestText.Text        = "右键快捷出售";
            Dictionary <Item, int> items = shop.GetAvaliableItems();
            int count = 0;

            RootPanel.Children.Clear();
            this.money.Text   = RuntimeData.Instance.Money.ToString();
            this.yuanbao.Text = RuntimeData.Instance.YuanBao.ToString();

            List <string> visitedItem = new List <string>();

            foreach (var item in items.Keys)
            {
                if (ItemTypeCombo.SelectedItem.ToString() == "武器" && (item.Type != (int)ItemType.Weapon))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "消耗品" && (item.Type != (int)ItemType.Costa))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "防具" && (item.Type != (int)ItemType.Armor))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "饰品" && (item.Type != (int)ItemType.Accessories))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "经书" && (item.Type != (int)ItemType.Book))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "任务物品" && (item.Type != (int)ItemType.Mission))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "技能书" && (item.Type != (int)ItemType.TalentBook) && item.Type != (int)ItemType.Upgrade)
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "残章" && (item.Type != (int)ItemType.Canzhang))
                {
                    continue;
                }
                if (ItemTypeCombo.SelectedItem.ToString() == "特殊物品" && (item.Type != (int)ItemType.Special))
                {
                    continue;
                }
                int itemCount = 1;
                //如果不是装备,则层叠
                if (!(item.Type == (int)ItemType.Armor || item.Type == (int)ItemType.Accessories || item.Type == (int)ItemType.Weapon))
                {
                    if (visitedItem.Contains(item.Name))
                    {
                        continue;
                    }
                    itemCount = items.Keys.Count(p => p.Name == item.Name);
                    visitedItem.Add(item.Name);
                }

                if (count > 5)
                {
                    count = 0;
                }

                ItemUnit c = new ItemUnit();
                c.BindItem(item);
                c.ItemCount = itemCount;
                c.Margin    = new Thickness(2, 2, 2, 5);
                string info  = item.ToString();
                int    price = items[item];
                Item   tmp   = item;
                c.MouseRightButtonUp += (s, e) =>
                {
                    if (uiHost.selectPanel.Visibility == System.Windows.Visibility.Visible)
                    {
                        return;
                    }
                    RuntimeData.Instance.Money += price;
                    RuntimeData.Instance.Items.Remove(tmp);
                    AudioManager.PlayEffect(ResourceManager.Get("音效.装备"));
                    this.money.Text = RuntimeData.Instance.Money.ToString();
                    //uiHost.itemSelectPanel.Show(RuntimeData.Instance.Items);//刷新物品栏
                    this.Show(shop);
                    e.Handled = true;
                };
                c.MouseLeftButtonUp += (s, e) =>
                {
                    //uiHost.selectPanel.CallBack = () =>
                    //{
                    //    if (uiHost.selectPanel.currentSelection == "yes")
                    //    {
                    //        RuntimeData.Instance.Money += price;
                    //        RuntimeData.Instance.Items.Remove(tmp);
                    //        AudioManager.PlayEffect(ResourceManager.Get("音效.装备"));
                    //        this.money.Text = RuntimeData.Instance.Money.ToString();
                    //        //uiHost.itemSelectPanel.Show(RuntimeData.Instance.Items);//刷新物品栏
                    //        this.Show(shop);
                    //    }
                    //};
                    //uiHost.selectPanel.title.Text = "确定出售?";
                    //uiHost.selectPanel.yes.Content = "出售";
                    //uiHost.selectPanel.no.Content = "取消";
                    //uiHost.selectPanel.ShowSelection();
                    BuyItemWindow win = new BuyItemWindow();
                    win.Bind(tmp, "出售物品", (number) =>
                    {
                        RuntimeData.Instance.Money += price * number;
                        RuntimeData.Instance.RemoveItem(tmp.Name, number);
                        AudioManager.PlayEffect(ResourceManager.Get("音效.装备"));
                        this.Show(shop);
                    }, itemCount);
                    win.Show();
                    e.Handled = true;
                };
                //ToolTipService.SetToolTip(c,info + "\n价格:" + price.ToString() + "两白银");
                RichTextBox rtb = item.GenerateTooltip();
                (rtb.Blocks[0] as Paragraph).Inlines.Add(new LineBreak());
                (rtb.Blocks[0] as Paragraph).Inlines.Add(new LineBreak());
                (rtb.Blocks[0] as Paragraph).Inlines.Add(new Run()
                {
                    Text = "价格:" + price.ToString() + "两白银", FontSize = 12, FontWeight = FontWeights.Bold
                });
                ToolTipService.SetToolTip(c, rtb);

                RootPanel.Children.Add(c);
                count++;
            }

            this.Visibility = System.Windows.Visibility.Visible;
        }