Example #1
0
        public static void RightClickHandler(object arg1, GuiItem.MouseRightClickEvent arg2)
        {
            var theItem = (DragDropItem)arg1;
            var data    = theItem.Data as GoodItemData;

            if (data == null)
            {
                return;
            }
            var good = GoodsListManager.Get(data.Index);

            if (good == null)
            {
                return;
            }

            if (GuiManager.BuyInterface.IsShow)
            {
                if (good.Cost > 0)
                {
                    Globals.ThePlayer.AddMoneyValue(good.Cost / 2);
                    GuiManager.DeleteGood(good.FileName);
                    GuiManager.BuyInterface.AddGood(good);
                }
            }
            else
            {
                GoodsListManager.UsingGood(data.Index);
            }
        }
Example #2
0
        public void UpdateItem(int itemIndex)
        {
            if (itemIndex >= 0 && itemIndex < 3)//Goods
            {
                var  index = ToGoodsListIndex(itemIndex);
                var  info  = GoodsListManager.GetItemInfo(index);
                Good good  = null;
                var  text  = "";
                if (info != null)
                {
                    good = info.TheGood;
                    text = info.Count.ToString();
                }
                var icon = good == null ? null : good.Icon;
                SetItem(itemIndex, new Texture(icon), text);
            }

            if (itemIndex >= 3 && itemIndex < 8)//Magic
            {
                var index = ToMagicListIndex(itemIndex);
                var magic = MagicListManager.Get(index);
                var icon  = magic == null ? null : magic.Icon;
                SetItem(itemIndex, new Texture(icon));
            }
        }
Example #3
0
        public static bool ExchangeItem(object arg1, DragDropItem.DropEvent arg2,
                                        out int index, out int sourceIndex)
        {
            var item       = (DragDropItem)arg1;
            var sourceItem = arg2.Source;
            var data       = item.Data as GoodItemData;
            var sourceData = sourceItem.Data as GoodItemData;

            if (data != null && sourceData != null)
            {
                GoodsListManager.ExchangeListItemAndEquiping(data.Index, sourceData.Index);
                item.BaseTexture       = GoodsListManager.GetTexture(data.Index);
                sourceItem.BaseTexture = GoodsListManager.GetTexture(sourceData.Index);
                index       = data.Index;
                sourceIndex = sourceData.Index;
                var info       = GoodsListManager.GetItemInfo(index);
                var sourceInfo = GoodsListManager.GetItemInfo(sourceIndex);
                item.TopLeftText = info != null?info.Count.ToString() : "";

                sourceItem.TopLeftText = sourceInfo != null?sourceInfo.Count.ToString() : "";

                return(true);
            }
            index       = 0;
            sourceIndex = 0;
            return(false);
        }
Example #4
0
        public static void DropHandler(object arg1, DragDropItem.DropEvent arg2)
        {
            var item       = (DragDropItem)arg1;
            var sourceItem = arg2.Source;
            var data       = item.Data as GoodItemData;
            var sourceData = sourceItem.Data as GoodItemData;

            if (data != null && sourceData != null)
            {
                if (GoodsListManager.IsInEquipRange(sourceData.Index))
                {
                    var info       = GoodsListManager.GetItemInfo(data.Index);
                    var sourceGood = GoodsListManager.Get(sourceData.Index);
                    if (sourceGood == null ||
                        (info != null && info.TheGood == null) ||
                        (info != null && info.TheGood.Part != sourceGood.Part))
                    {
                        return;
                    }
                }
            }

            int index, sourceIndex;

            ExchangeItem(arg1, arg2, out index, out sourceIndex);
        }
Example #5
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!IsShow)
            {
                return;
            }

            base.Draw(spriteBatch);
            foreach (var dragDropItem in _items)
            {
                dragDropItem.Draw(spriteBatch);
            }

            for (var i = 0; i < 8; i++) //Magic
            {
                float remainColdMilliseconds = 0;
                var   item = _items[i];
                if (i >= 0 && i < 3)
                {
                    var data = (GoodsGui.GoodItemData)item.Data;
                    var info = GoodsListManager.GetItemInfo(data.Index);
                    if (info != null)
                    {
                        remainColdMilliseconds = info.RemainColdMilliseconds;
                    }
                }
                else
                {
                    var data = (MagicGui.MagicItemData)item.Data;
                    var info = MagicListManager.GetItemInfo(data.Index);
                    if (info != null)
                    {
                        remainColdMilliseconds = info.RemainColdMilliseconds;
                    }
                }

                if (remainColdMilliseconds > 0)
                {
                    if (_coldTimeBackground == null)
                    {
                        _coldTimeBackground = TextureGenerator.GetColorTexture(new Color(0, 0, 0, 180), item.Width,
                                                                               item.Height);
                    }

                    var timeTxt = (remainColdMilliseconds / 1000f).ToString("0.0");
                    var font    = Globals.FontSize10;

                    spriteBatch.Draw(
                        _coldTimeBackground,
                        item.ScreenPosition,
                        Color.White);

                    spriteBatch.DrawString(font,
                                           timeTxt,
                                           item.CenterScreenPosition - font.MeasureString(timeTxt) / 2,
                                           _colodTimeFontColor);
                }
            }
        }
Example #6
0
 public static void EquipGoods(int goodListIndex, Good.EquipPosition part)
 {
     if (!GoodsListManager.CanEquip(goodListIndex, part))
     {
         return;
     }
     EquipInterface.EquipGood(goodListIndex);
 }
Example #7
0
 public static void UpdateGoodItemView(int listIndex)
 {
     if (GoodsListManager.IsInStoreRange(listIndex))
     {
         GoodsInterface.UpdateListItem(listIndex);
     }
     else if (GoodsListManager.IsInBottomGoodsRange(listIndex))
     {
         BottomInterface.UpdateGoodItem(listIndex);
     }
 }
Example #8
0
        private bool CanDrop(DragDropItem.DropEvent arg2, Good.EquipPosition position)
        {
            var sourceItem = arg2.Source;
            var sourceData = sourceItem.Data as GoodsGui.GoodItemData;

            if (sourceData != null)
            {
                return(GoodsListManager.CanEquip(sourceData.Index, position));
            }
            return(false);
        }
Example #9
0
        public void UpdateListItem(int listIndex)
        {
            int itemIndex;

            if (IsItemShow(listIndex, out itemIndex))
            {
                _listView.SetListItemTexture(itemIndex,
                                             GoodsListManager.GetTexture(listIndex));
                var info = GoodsListManager.GetItemInfo(listIndex);
                _listView.SetItemTopLeftText(itemIndex, info != null ? info.Count.ToString() : "");
            }
        }
Example #10
0
        public static void MouseStayOverHandler(object arg1, GuiItem.MouseEvent arg2)
        {
            var item = (DragDropItem)arg1;
            var data = item.Data as GoodItemData;

            if (data != null)
            {
                var info = GoodsListManager.GetItemInfo(data.Index);
                if (info != null)
                {
                    GuiManager.ToolTipInterface.ShowGood(info.TheGood, GuiManager.BuyInterface.IsShow);
                }
            }
        }
Example #11
0
        /// <summary>
        /// Goods and magic list must load first.
        /// Player using goods list to apply equip special effect.
        /// Player using magic list to load current use magic.
        /// </summary>
        private static void LoadPlayer()
        {
            var path = StorageBase.PlayerFilePath;

            try
            {
                Globals.ThePlayer = new Player(path);
                Globals.TheCarmera.CenterPlayerInCamera();
                GoodsListManager.ApplyEquipSpecialEffectFromList(Globals.ThePlayer);
            }
            catch (Exception exception)
            {
                Log.LogFileLoadError("Player", path, exception);
            }
            GuiManager.StateInterface.Index = GuiManager.EquipInterface.Index = Globals.PlayerIndex;
        }
Example #12
0
 public void UpdateItems()
 {
     for (var i = 0; i < 9; i++)
     {
         var  index = _listView.ToListIndex(i) + GoodsListManager.StoreIndexBegin - 1;
         var  info  = GoodsListManager.GetItemInfo(index);
         Good good  = null;
         if (info != null)
         {
             good = info.TheGood;
         }
         var image = (good == null ? null : good.Image);
         _listView.SetListItem(i, new Texture(image), new GoodItemData(index));
         _listView.SetItemTopLeftText(i, info != null ? info.Count.ToString() : "");
     }
 }
Example #13
0
 public void UpdateItems()
 {
     foreach (var item in _items)
     {
         var index = ((GoodsGui.GoodItemData)item.Data).Index;
         item.BaseTexture = GoodsListManager.GetTexture(index);
         var info = GoodsListManager.GetItemInfo(index);
         if (info != null && info.Count > 0)
         {
             item.TopLeftText = info.Count.ToString();
         }
         else
         {
             item.TopLeftText = "";
         }
     }
 }
Example #14
0
        public void BuyGood(Good good)
        {
            if (good == null)
            {
                return;
            }
            var cost = good.Cost;

            if (Money >= cost)
            {
                Money -= cost;
                GoodsListManager.AddGoodToList(good.FileName);
                GuiManager.UpdateGoodsView();
            }
            else
            {
                GuiManager.ShowMessage("没有足够的钱!");
            }
        }
Example #15
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!IsShow)
            {
                return;
            }

            _listView.Draw(spriteBatch);
            _money.Draw(spriteBatch);

            for (var i = 0; i < 9; i++)
            {
                var index = _listView.ToListIndex(i) + GoodsListManager.StoreIndexBegin - 1;
                var info  = GoodsListManager.GetItemInfo(index);
                if (info != null && info.RemainColdMilliseconds > 0)
                {
                    var item = _listView.GetItem(i);
                    if (_coldTimeBackground == null)
                    {
                        _coldTimeBackground = TextureGenerator.GetColorTexture(new Color(0, 0, 0, 180), item.Width,
                                                                               item.Height);
                    }

                    var timeTxt = (info.RemainColdMilliseconds / 1000f).ToString("0.0");
                    var font    = Globals.FontSize10;

                    spriteBatch.Draw(
                        _coldTimeBackground,
                        item.ScreenPosition,
                        Color.White);

                    spriteBatch.DrawString(font,
                                           timeTxt,
                                           item.CenterScreenPosition - font.MeasureString(timeTxt) / 2,
                                           _colodTimeFontColor);
                }
            }
        }
Example #16
0
        private void InitializeItems()
        {
            var cfg      = GuiManager.Setttings.Sections["Bottom_Items"];
            var hasCount = GoodsListManager.Type != GoodsListManager.ListType.TypeByGoodItem;

            _items[0] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_1"]), int.Parse(cfg["Item_Top_1"])),
                                         int.Parse(cfg["Item_Width_1"]),
                                         int.Parse(cfg["Item_Height_1"]),
                                         null,
                                         new GoodsGui.GoodItemData(GoodsListManager.BottomIndexBegin),
                                         hasCount);
            _items[1] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_2"]), int.Parse(cfg["Item_Top_2"])),
                                         int.Parse(cfg["Item_Width_2"]),
                                         int.Parse(cfg["Item_Height_2"]),
                                         null,
                                         new GoodsGui.GoodItemData(GoodsListManager.BottomIndexBegin + 1),
                                         hasCount);
            _items[2] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_3"]), int.Parse(cfg["Item_Top_3"])),
                                         int.Parse(cfg["Item_Width_3"]),
                                         int.Parse(cfg["Item_Height_3"]),
                                         null,
                                         new GoodsGui.GoodItemData(GoodsListManager.BottomIndexBegin + 2),
                                         hasCount);
            _items[3] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_4"]), int.Parse(cfg["Item_Top_4"])),
                                         int.Parse(cfg["Item_Width_4"]),
                                         int.Parse(cfg["Item_Height_4"]),
                                         null,
                                         new MagicGui.MagicItemData(MagicListManager.BottomIndexBegin));
            _items[4] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_5"]), int.Parse(cfg["Item_Top_5"])),
                                         int.Parse(cfg["Item_Width_5"]),
                                         int.Parse(cfg["Item_Height_5"]),
                                         null,
                                         new MagicGui.MagicItemData(MagicListManager.BottomIndexBegin + 1));
            _items[5] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_6"]), int.Parse(cfg["Item_Top_6"])),
                                         int.Parse(cfg["Item_Width_6"]),
                                         int.Parse(cfg["Item_Height_6"]),
                                         null,
                                         new MagicGui.MagicItemData(MagicListManager.BottomIndexBegin + 2));
            _items[6] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_7"]), int.Parse(cfg["Item_Top_7"])),
                                         int.Parse(cfg["Item_Width_7"]),
                                         int.Parse(cfg["Item_Height_7"]),
                                         null,
                                         new MagicGui.MagicItemData(MagicListManager.BottomIndexBegin + 3));
            _items[7] = new DragDropItem(this,
                                         new Vector2(int.Parse(cfg["Item_Left_8"]), int.Parse(cfg["Item_Top_8"])),
                                         int.Parse(cfg["Item_Width_8"]),
                                         int.Parse(cfg["Item_Height_8"]),
                                         null,
                                         new MagicGui.MagicItemData(MagicListManager.BottomIndexBegin + 4));

            for (var i = 0; i < 3; i++)
            {
                _items[i].Drag += (arg1, arg2) =>
                {
                };
                _items[i].Drop          += GoodsGui.DropHandler;
                _items[i].RightClick    += GoodsGui.RightClickHandler;
                _items[i].MouseStayOver += GoodsGui.MouseStayOverHandler;
                _items[i].MouseLeave    += GoodsGui.MouseLeaveHandler;
                _items[i].OnUpdate      += (arg1, arg2) =>
                {
                    var data = (GoodsGui.GoodItemData)(((DragDropItem)arg1).Data);
                    var info = GoodsListManager.GetItemInfo(data.Index);
                    if (info != null)
                    {
                        var gameTime = (GameTime)arg2;
                        info.RemainColdMilliseconds -= (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    }
                };
            }

            for (var i = 3; i < 8; i++)
            {
                _items[i].Drag += (arg1, arg2) =>
                {
                };
                _items[i].Drop       += MagicGui.DropHandler;
                _items[i].RightClick += (arg1, arg2) =>
                {
                    var data = (MagicGui.MagicItemData)(((DragDropItem)arg1).Data);
                    var info = MagicListManager.GetItemInfo(data.Index);
                    if (info != null)
                    {
                        Globals.ThePlayer.CurrentMagicInUse = info;
                    }
                };
                _items[i].MouseStayOver += MagicGui.MouseStayOverHandler;
                _items[i].MouseLeave    += MagicGui.MouseLeaveHandler;
                _items[i].OnUpdate      += (arg1, arg2) =>
                {
                    var data = (MagicGui.MagicItemData)(((DragDropItem)arg1).Data);
                    var info = MagicListManager.GetItemInfo(data.Index);
                    if (info != null)
                    {
                        var gameTime = (GameTime)arg2;
                        info.RemainColdMilliseconds -= (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                    }
                };
            }
        }
Example #17
0
        public static void Starting()
        {
            IsShow = true;

            _dropSound     = Utils.GetSoundEffect("界-拖放.wav");
            _interfaceShow = Utils.GetSoundEffect("界-弹出菜单.wav");
            _interfaceMiss = Utils.GetSoundEffect("界-缩回菜单.wav");

            TitleInterface = new TitleGui();
            _allGuiItems.AddLast(TitleInterface);

            SaveLoadInterface = new SaveLoadGui();
            _allGuiItems.AddLast(SaveLoadInterface);

            SystemInterface = new SystemGui();
            _allGuiItems.AddLast(SystemInterface);
            _panels.AddLast(SystemInterface);

            TopInterface = new TopGui();
            _allGuiItems.AddLast(TopInterface);

            BottomInterface = new BottomGui();
            _allGuiItems.AddLast(BottomInterface);

            ColumnInterface = new ColumnGui();
            _allGuiItems.AddLast(ColumnInterface);

            MagicInterface = new MagicGui();
            _allGuiItems.AddLast(MagicInterface);
            _panels.AddLast(MagicInterface);

            XiuLianInterface = new XiuLianGui();
            _allGuiItems.AddLast(XiuLianInterface);
            _panels.AddLast(XiuLianInterface);

            GoodsInterface = new GoodsGui();
            _allGuiItems.AddLast(GoodsInterface);
            _panels.AddLast(GoodsInterface);

            BuyInterface = new BuyGui();
            _allGuiItems.AddLast(BuyInterface);
            _panels.AddLast(BuyInterface);

            TimerInterface = new TimerGui();
            _allGuiItems.AddLast(TimerInterface);

            LittleMapInterface = new LittleMapGui();
            _allGuiItems.AddLast(LittleMapInterface);

            MemoInterface = new MemoGui();
            _allGuiItems.AddLast(MemoInterface);
            _panels.AddLast(MemoInterface);

            StateInterface = new StateGui();
            _allGuiItems.AddLast(StateInterface);
            _panels.AddLast(StateInterface);

            EquipInterface = new EquipGui();
            _allGuiItems.AddLast(EquipInterface);
            _panels.AddLast(EquipInterface);

            ToolTipInterface = new ToolTipGui();
            _allGuiItems.AddLast(ToolTipInterface);
            _panels.AddLast(ToolTipInterface);

            MouseInterface = new MouseGui();

            MessageInterface = new MessageGui();
            _allGuiItems.AddLast(MessageInterface);
            _panels.AddLast(MessageInterface);

            DialogInterface = new DialogGui();
            _allGuiItems.AddLast(DialogInterface);

            LittleHeadInterface = new LittleHeadGui();
            _allGuiItems.AddLast(LittleHeadInterface);

            SelectionInterface = new SelectionGui();
            _allGuiItems.AddLast(SelectionInterface);

            MagicListManager.RenewList();
            GoodsListManager.RenewList();
        }
Example #18
0
        public static void Starting()
        {
            Setttings = new FileIniDataParser().ReadFile(@"Content\ui\UI_Settings.ini", Globals.LocalEncoding);

            GoodsListManager.InitIndex(Setttings);
            MagicListManager.InitIndex(Setttings);

            IsShow = true;

            _dropSound     = Utils.GetSoundEffect("界-拖放.wav");
            _interfaceShow = Utils.GetSoundEffect("界-弹出菜单.wav");
            _interfaceMiss = Utils.GetSoundEffect("界-缩回菜单.wav");

            TitleInterface = new TitleGui();
            _allGuiItems.AddLast(TitleInterface);

            SaveLoadInterface = new SaveLoadGui();
            _allGuiItems.AddLast(SaveLoadInterface);

            SystemInterface = new SystemGui();
            _allGuiItems.AddLast(SystemInterface);
            _panels.AddLast(SystemInterface);

            TopInterface = new TopGui();
            _allGuiItems.AddLast(TopInterface);

            BottomInterface = new BottomGui();
            _allGuiItems.AddLast(BottomInterface);

            ColumnInterface = new ColumnGui();
            _allGuiItems.AddLast(ColumnInterface);

            MagicInterface = new MagicGui();
            _allGuiItems.AddLast(MagicInterface);
            _panels.AddLast(MagicInterface);

            XiuLianInterface = new XiuLianGui();
            _allGuiItems.AddLast(XiuLianInterface);
            _panels.AddLast(XiuLianInterface);

            GoodsInterface = new GoodsGui();
            _allGuiItems.AddLast(GoodsInterface);
            _panels.AddLast(GoodsInterface);

            BuyInterface = new BuyGui();
            _allGuiItems.AddLast(BuyInterface);
            _panels.AddLast(BuyInterface);

            TimerInterface = new TimerGui();
            _allGuiItems.AddLast(TimerInterface);

            LittleMapInterface = new LittleMapGui();
            _allGuiItems.AddLast(LittleMapInterface);

            MemoInterface = new MemoGui();
            _allGuiItems.AddLast(MemoInterface);
            _panels.AddLast(MemoInterface);

            StateInterface = new StateGui();
            _allGuiItems.AddLast(StateInterface);
            _panels.AddLast(StateInterface);

            EquipInterface = new EquipGui();
            _allGuiItems.AddLast(EquipInterface);
            _panels.AddLast(EquipInterface);

            var toolTipUseType = int.Parse(Setttings.Sections["ToolTip_Use_Type"]["UseType"]);

            if (toolTipUseType == 1)
            {
                ToolTipInterface = new ToolTipGuiType1();
            }
            else
            {
                ToolTipInterface = new ToolTipGuiType2();
            }
            _allGuiItems.AddLast(ToolTipInterface);
            _panels.AddLast(ToolTipInterface);

            MouseInterface = new MouseGui();

            MessageInterface = new MessageGui();
            _allGuiItems.AddLast(MessageInterface);
            _panels.AddLast(MessageInterface);

            DialogInterface = new DialogGui();
            _allGuiItems.AddLast(DialogInterface);

            LittleHeadInterface = new LittleHeadGui();
            _allGuiItems.AddLast(LittleHeadInterface);

            SelectionInterface = new SelectionGui();
            _allGuiItems.AddLast(SelectionInterface);

            MagicListManager.RenewList();
            GoodsListManager.RenewList();
        }
Example #19
0
        public bool EquipGood(int goodListIndex)
        {
            if (GoodsListManager.IsInStoreRange(goodListIndex) ||
                GoodsListManager.IsInBottomGoodsRange(goodListIndex))
            {
                var info = GoodsListManager.GetItemInfo(goodListIndex);
                if (info == null)
                {
                    return(false);
                }
                var good = info.TheGood;
                if (good != null &&
                    good.Kind == Good.GoodKind.Equipment)
                {
                    DragDropItem item;
                    var          index = 0;
                    switch (good.Part)
                    {
                    case Good.EquipPosition.Body:
                        item  = _body;
                        index = ToGoodItemData(item.Data).Index;
                        break;

                    case Good.EquipPosition.Foot:
                        item  = _foot;
                        index = ToGoodItemData(item.Data).Index;
                        break;

                    case Good.EquipPosition.Head:
                        item  = _head;
                        index = ToGoodItemData(item.Data).Index;
                        break;

                    case Good.EquipPosition.Neck:
                        item  = _neck;
                        index = ToGoodItemData(item.Data).Index;
                        break;

                    case Good.EquipPosition.Back:
                        item  = _back;
                        index = ToGoodItemData(item.Data).Index;
                        break;

                    case Good.EquipPosition.Wrist:
                        item  = _wrist;
                        index = ToGoodItemData(item.Data).Index;
                        break;

                    case Good.EquipPosition.Hand:
                        item  = _hand;
                        index = ToGoodItemData(item.Data).Index;
                        break;

                    default:
                        return(false);
                    }
                    GoodsListManager.ExchangeListItemAndEquiping(goodListIndex, index);
                    item.BaseTexture = new Texture(good.Image);
                    item.TopLeftText = info.Count.ToString();
                    GuiManager.UpdateGoodItemView(goodListIndex);
                    return(true);
                }
            }
            return(false);
        }
Example #20
0
 public static void Save(string magicListPath, string goodsListPath, string memoListPath)
 {
     MagicListManager.SaveList(magicListPath);
     GoodsListManager.SaveList(goodsListPath);
     MemoListManager.SaveList(memoListPath);
 }
Example #21
0
 public static void Load(string magicListPath, string goodsListPath, string memoListPath)
 {
     MagicListManager.LoadList(magicListPath);
     GoodsListManager.LoadList(goodsListPath);
     MemoListManager.LoadList(memoListPath);
 }
Example #22
0
 private static void LoadMagicGoodList()
 {
     MagicListManager.LoadList(StorageBase.MagicListFilePath);
     GoodsListManager.LoadList(StorageBase.GoodsListFilePath);
 }
Example #23
0
 /// <summary>
 /// Use good at bottom gui.
 /// </summary>
 /// <param name="index">0-2</param>
 public static void UsingBottomGood(int index)
 {
     GoodsListManager.UsingGood(index + GoodsListManager.BottomGoodsIndexBegin);
 }
Example #24
0
 public static void DeleteGood(string fileName)
 {
     GoodsListManager.DeleteGood(fileName);
     UpdateGoodsView();
 }
Example #25
0
        private void RegisterEventHandler()
        {
            int index, sourceIndex;

            _head.Drop += (arg1, arg2) =>
            {
                if (CanDrop(arg2, Good.EquipPosition.Head))
                {
                    if (GoodsGui.ExchangeItem(arg1, arg2, out index, out sourceIndex))
                    {
                    }
                }
            };
            _neck.Drop += (arg1, arg2) =>
            {
                if (CanDrop(arg2, Good.EquipPosition.Neck))
                {
                    if (GoodsGui.ExchangeItem(arg1, arg2, out index, out sourceIndex))
                    {
                    }
                }
            };
            _body.Drop += (arg1, arg2) =>
            {
                if (CanDrop(arg2, Good.EquipPosition.Body))
                {
                    if (GoodsGui.ExchangeItem(arg1, arg2, out index, out sourceIndex))
                    {
                    }
                }
            };
            _back.Drop += (arg1, arg2) =>
            {
                if (CanDrop(arg2, Good.EquipPosition.Back))
                {
                    if (GoodsGui.ExchangeItem(arg1, arg2, out index, out sourceIndex))
                    {
                    }
                }
            };
            _hand.Drop += (arg1, arg2) =>
            {
                if (CanDrop(arg2, Good.EquipPosition.Hand))
                {
                    if (GoodsGui.ExchangeItem(arg1, arg2, out index, out sourceIndex))
                    {
                    }
                }
            };
            _wrist.Drop += (arg1, arg2) =>
            {
                if (CanDrop(arg2, Good.EquipPosition.Wrist))
                {
                    if (GoodsGui.ExchangeItem(arg1, arg2, out index, out sourceIndex))
                    {
                    }
                }
            };
            _foot.Drop += (arg1, arg2) =>
            {
                if (CanDrop(arg2, Good.EquipPosition.Foot))
                {
                    if (GoodsGui.ExchangeItem(arg1, arg2, out index, out sourceIndex))
                    {
                    }
                }
            };

            foreach (var item in _items)
            {
                item.RightClick += (arg1, arg2) =>
                {
                    var theItem = (DragDropItem)arg1;
                    var data    = theItem.Data as GoodsGui.GoodItemData;
                    if (data != null)
                    {
                        int newIndex;
                        if (GoodsListManager.PlayerUnEquiping(data.Index, out newIndex))
                        {
                            theItem.BaseTexture = null;
                            theItem.TopLeftText = "";
                            GuiManager.UpdateGoodItemView(newIndex);
                        }
                    }
                };
                item.MouseStayOver += GoodsGui.MouseStayOverHandler;
                item.MouseLeave    += GoodsGui.MouseLeaveHandler;
            }
        }
Example #26
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //Update mouse scroll state.
            MouseScrollHandler.Update();

            UpdateGameActiveState(gameTime);

            if (IsPaused || IsFocusLost)
            {
                base.Update(gameTime);
                SuppressDraw();
                return;
            }

            var mouseState    = Mouse.GetState();
            var keyboardState = Keyboard.GetState();

            //Fullscreen toggle
            if (!IsInEditMode &&
                (keyboardState.IsKeyDown(Keys.LeftAlt) || keyboardState.IsKeyDown(Keys.RightAlt)))
            {
                if (keyboardState.IsKeyDown(Keys.Enter) &&
                    LastKeyboardState.IsKeyUp(Keys.Enter))
                {
                    _graphics.ToggleFullScreen();
                    Globals.IsFullScreen = !Globals.IsFullScreen;
                }
            }

            //Map layer draw toggle
            if (IsInEditMode)
            {
                if (keyboardState.IsKeyDown(Keys.D1) && LastKeyboardState.IsKeyUp(Keys.D1))
                {
                    MapBase.SwitchLayerDraw(0);
                }
                if (keyboardState.IsKeyDown(Keys.D2) && LastKeyboardState.IsKeyUp(Keys.D2))
                {
                    MapBase.SwitchLayerDraw(1);
                }
                if (keyboardState.IsKeyDown(Keys.D3) && LastKeyboardState.IsKeyUp(Keys.D3))
                {
                    MapBase.SwitchLayerDraw(2);
                }
                if (keyboardState.IsKeyDown(Keys.D4) && LastKeyboardState.IsKeyUp(Keys.D4))
                {
                    MapBase.SwitchLayerDraw(3);
                }
                if (keyboardState.IsKeyDown(Keys.D5) && LastKeyboardState.IsKeyUp(Keys.D5))
                {
                    MapBase.SwitchLayerDraw(4);
                }
            }

            if (ScriptExecuter.IsInPlayingMovie)
            {
                //Stop movie when Esc key pressed
                if (keyboardState.IsKeyDown(Keys.Escape) &&
                    LastKeyboardState.IsKeyUp(Keys.Escape))
                {
                    ScriptExecuter.StopMovie();
                }
            }
            else
            {
                //Update GUI first, GUI will decide whether user input be intercepted or pass through
                GuiManager.Update(gameTime);

                switch (GameState.State)
                {
                case GameState.StateType.Start:
                    ScriptManager.RunScript(Utils.GetScriptParser("title.txt"));
                    GameState.State = GameState.StateType.Title;
                    break;

                case GameState.StateType.Title:
                    break;

                case GameState.StateType.Playing:
                    if (IsGamePlayPaused)
                    {
                        break;
                    }
                    UpdatePlaying(gameTime);
                    GoodsListManager.Update(gameTime);
                    break;

                case GameState.StateType.EndAds:
                    _elapsedSecondsAd += (float)gameTime.ElapsedGameTime.TotalSeconds;
                    if (_elapsedSecondsAd >= AdKeepSeconds ||
                        (keyboardState.IsKeyDown(Keys.Escape) &&
                         LastKeyboardState.IsKeyUp(Keys.Escape)))
                    {
                        Exit();
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            //Update script after GuiManager, because script executing rely GUI state.
            ScriptManager.Update(gameTime);

            LastKeyboardState = Keyboard.GetState();
            LastMouseState    = mouseState;

            base.Update(gameTime);
        }