public void UpdateItem() { var info = MagicListManager.GetItemInfo(ItemIndex); if (info != null) { _levelText.Text = info.Level + "/10"; _expText.Text = info.Exp + "/" + info.TheMagic.LevelupExp; _nameText.Text = info.TheMagic == null ? "无" : info.TheMagic.Name; _introText.Text = info.TheMagic == null ? "无" : info.TheMagic.Intro; if (_isItemChange || _infoItem.BaseTexture == null) { //Change texture only item changed or base texture is null. //Because this method is called in Update() if change base texture every update, //texture won't update it's frame index and will always stay at frame 0. _isItemChange = false; _infoItem.BaseTexture = MagicListManager.GetTexture(ItemIndex); } } else { _levelText.Text = "1/10"; _expText.Text = "0/0"; _nameText.Text = ""; _introText.Text = ""; _infoItem.BaseTexture = null; } }
public static void MouseRightClickdHandler(object arg1, MouseEvent arg2) { var item = (DragDropItem)arg1; var data = item.Data as MagicItemData; if (data != null) { var info = MagicListManager.GetItemInfo(data.Index); if (info != null) { for (var i = MagicListManager.BottomMagicIndexStart; i <= MagicListManager.BottomMagicIndexEnd; i++) { var binfo = MagicListManager.GetItemInfo(i); if (binfo == null) { MagicListManager.ExchangeListItem(data.Index, i); GuiManager.UpdateMagicView(); break; } } } } }
/// <summary> /// Load game from "save/game" directory /// GuiManager must started first /// </summary> public static void LoadGame(bool isInitlizeGame) { if (isInitlizeGame) { //Clear ScriptManager.Clear(); ScriptExecuter.Init(); MagicManager.Clear(); NpcManager.ClearAllNpc(); ObjManager.ClearAllObjAndFileName(); Globals.TheMap.Free(); GuiManager.CloseTimeLimit(); GuiManager.EndDialog(); BackgroundMusic.Stop(); Globals.IsInputDisabled = false; } LoadGameFile(); LoadMagicGoodMemoList(); LoadPlayer(); //Apply xiulian magic to player Globals.ThePlayer.XiuLianMagic = MagicListManager.GetItemInfo( MagicListManager.XiuLianIndex); LoadPartner(); LoadTraps(); LoadTrapIgnoreList(); Globals.TheCarmera.CenterPlayerInCamera(); GameState.State = GameState.StateType.Playing; Globals.TheGame.IsGamePlayPaused = false; GuiManager.ShowAllPanels(false); }
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); } } }
private void InitializeItems() { _items[0] = new DragDropItem(this, new Vector2(7, 20), 30, 40, null, new GoodsGui.GoodItemData(221)); _items[1] = new DragDropItem(this, new Vector2(44, 20), 30, 40, null, new GoodsGui.GoodItemData(222)); _items[2] = new DragDropItem(this, new Vector2(82, 20), 30, 40, null, new GoodsGui.GoodItemData(223)); _items[3] = new DragDropItem(this, new Vector2(199, 20), 30, 40, null, new MagicGui.MagicItemData(40)); _items[4] = new DragDropItem(this, new Vector2(238, 20), 30, 40, null, new MagicGui.MagicItemData(41)); _items[5] = new DragDropItem(this, new Vector2(277, 20), 30, 40, null, new MagicGui.MagicItemData(42)); _items[6] = new DragDropItem(this, new Vector2(316, 20), 30, 40, null, new MagicGui.MagicItemData(43)); _items[7] = new DragDropItem(this, new Vector2(354, 20), 30, 40, null, new MagicGui.MagicItemData(44)); 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; } 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; } }; } }
public static void MouseStayOverHandler(object arg1, GuiItem.MouseEvent arg2) { var item = (DragDropItem)arg1; var data = item.Data as MagicItemData; if (data != null) { var info = MagicListManager.GetItemInfo(data.Index); if (info != null) { GuiManager.ToolTipInterface.ShowMagic(info.TheMagic); } } }
private void _reloadCurrentMagicMenuItem_Click(object sender, EventArgs e) { if (Globals.ThePlayer == null) { return; } var index = Globals.ThePlayer.CurrentUseMagicIndex; MagicListManager.SaveList(StorageBase.MagicListFilePath); MagicListManager.LoadList(StorageBase.MagicListFilePath); Globals.ThePlayer.CurrentUseMagicIndex = index; Globals.ThePlayer.XiuLianMagic = MagicListManager.GetItemInfo( MagicListManager.XiuLianIndex); }
/// <summary> /// Get magic item info at bottom gui. /// </summary> /// <param name="index">0-4</param> /// <returns>Magic item info.Return null if not found.</returns> public static MagicListManager.MagicItemInfo GetBottomMagicItemInfo(int index) { return(MagicListManager.GetItemInfo(index + MagicListManager.BottomMagicIndexStart)); }
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; } }; } }