Exemplo n.º 1
0
        public static void InsertGameShopItem(GameShopItem gameShopItem)
        {
            try
            {
                conn.Open();
                cmd = new MySqlCommand("InsertGameShopItem", conn)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("ItemIndex", gameShopItem.ItemIndex);
                cmd.Parameters.AddWithValue("GIndex", gameShopItem.GIndex);
                cmd.Parameters.AddWithValue("GoldPrice", gameShopItem.GoldPrice);
                cmd.Parameters.AddWithValue("CreditPrice", gameShopItem.CreditPrice);
                cmd.Parameters.AddWithValue("ItemCount", gameShopItem.Count);
                cmd.Parameters.AddWithValue("Class", gameShopItem.Class);
                cmd.Parameters.AddWithValue("Category", gameShopItem.Category);
                cmd.Parameters.AddWithValue("Stock", gameShopItem.Stock);
                cmd.Parameters.AddWithValue("iStock", gameShopItem.iStock ? 1 : 0);
                cmd.Parameters.AddWithValue("Deal", gameShopItem.Deal ? 1 : 0);
                cmd.Parameters.AddWithValue("TopItem", gameShopItem.TopItem ? 1 : 0);
                cmd.Parameters.AddWithValue("ItemDate", gameShopItem.Date);

                cmd.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            { }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 2
0
        private void REGameShopToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int u = 0;


            foreach (var NewItem in EditEnvir.GameShopList)
            {
                var OldItem = Envir.GameShopList.Find(x => x.GIndex == NewItem.GIndex);
                if (OldItem != null)
                {
                    OldItem.UpdateItem(NewItem);
                }
                else
                {
                    var CloneItem = GameShopItem.CloneItem(NewItem);
                    Envir.GameShopList.Add(CloneItem);
                    u++;
                }
            }

            SMain.Enqueue("[Gameshop DataBase] total items :" + Envir.GameShopList.Count.ToString());
            SMain.Enqueue("[Gameshop DataBase] " + (Envir.GameShopList.Count - u).ToString() + " has been updated");
            SMain.Enqueue("[Gameshop DataBase] " + u.ToString() + " has been added");

            foreach (var p in Envir.Players)// update all info on players items
            {
                if (p.Info == null)
                {
                    continue;
                }

                p.GetGameShop();
            }
        }
Exemplo n.º 3
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            Item = null;
            GameScene.HoverItem = null;
            ShowItem            = null;
        }
Exemplo n.º 4
0
 public override void Init(int width, int height)
 {
     base.Init(width, height);
     itemControls = new GameShopItem[9];
     for (int i = 0; i < 9; i++)
     {
         itemControls[i] = new GameShopItem(this, 11 + (i % 3) * 170, 61 + (i / 3) * 101, 170, 101);
         itemControls[i].Init();
     }
     virtualRegion_RegionClick(1, 0, 0, MouseButtons.Left);
 }
Exemplo n.º 5
0
 public bool BindGameShop(GameShopItem item, bool editEnvir = true)
 {
     for (var i = 0; i < ItemInfoList.Count; i++)
     {
         var info = ItemInfoList[i];
         if (info.ItemIndex != item.ItemIndex)
         {
             continue;
         }
         item.Info = info;
         return(true);
     }
     return(false);
 }
Exemplo n.º 6
0
        public void UpdateGameShop(GameShopItem info)
        {
            GameShopListBox.Items.Clear();
            for (int i = 0; i < GameShopInfoList.Count; i++)
            {
                GameShopListBox.Items.Add(GameShopInfoList[i]);
            }

            GameShopListBox.SelectedIndex = GameShopListBox.Items.Count - 1;
            UpdateInterface();
            if (MotherParent != null)
            {
                MotherParent.NeedSave = true;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Add a new Item to the GameShop
        /// </summary>
        /// <param name="info">The Item to add to the Game Shop</param>
        public void AddGameShopItem(ItemInfo info)
        {
            GameShopPanel.GameShopInfoList.Add(new GameShopItem {
                GIndex = ++GameShopIndex, ItemIndex = info.Index, Info = info
            });
            GameShopItem item   = GameShopPanel.GameShopInfoList[GameShopPanel.GameShopInfoList.Count - 1];
            DialogResult result = MessageBox.Show("Would you like to edit the Item in the GameShop now?", "Switch to GameShop Tool?", MessageBoxButtons.YesNo);

            GameShopPanel._SelectedItems.Clear();
            GameShopPanel._SelectedItems.Add(item);
            GameShopPanel.UpdateGameShop(item);
            if (result == DialogResult.Yes)
            {
                tabControl1.SelectedTab = tabGameShopTool;
            }
        }
Exemplo n.º 8
0
        public void ItemGSBought(string source, GameShopItem item, uint amount, uint CreditCost, uint GoldCost)
        {
            string type = string.Empty;
            string task = string.Empty;

            if (item != null)
            {
                task = string.Format("Purchased {1} x{0} for {2} Credits and {3} Gold.", item.Info.FriendlyName, amount, CreditCost, GoldCost);
            }

            Action action = new Action {
                Source = source, Task = task
            };

            RecordAction(action);
        }
Exemplo n.º 9
0
 public void UpdateGameShop(List <GameShopItem> info)
 {
     GameShopListBox.Items.Clear();
     for (int i = 0; i < GameShopInfoList.Count; i++)
     {
         GameShopListBox.Items.Add(GameShopInfoList[i]);
     }
     for (int i = 0; i < GameShopListBox.Items.Count; i++)
     {
         GameShopItem tmp = (GameShopItem)GameShopListBox.Items[i];
         for (int x = 0; x < _SelectedItems.Count; x++)
         {
             if (tmp == _SelectedItems[x])
             {
                 GameShopListBox.SetSelected(i, true);
             }
         }
     }
     UpdateInterface();
     if (MotherParent != null)
     {
         MotherParent.NeedSave = true;
     }
 }
Exemplo n.º 10
0
        public void ItemGSBought(GameShopItem item, uint amount, uint CreditCost, uint GoldCost, [CallerMemberName] string source = "")
        {
            string message = $"Purchased {item.Info.FriendlyName} x{amount} for {CreditCost} Credits and {GoldCost} Gold.";

            LogMessage(message, source);
        }
Exemplo n.º 11
0
        public void LoadDB()
        {
            lock (LoadLock)
            {
                if (!File.Exists(DatabasePath))
                    SaveDB();

                using (FileStream stream = File.OpenRead(DatabasePath))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    LoadVersion = reader.ReadInt32();
                    if (LoadVersion > 57)
                        LoadCustomVersion = reader.ReadInt32();
                    MapIndex = reader.ReadInt32();
                    ItemIndex = reader.ReadInt32();
                    MonsterIndex = reader.ReadInt32();
                    if (LoadVersion > 33)
                    {
                        NPCIndex = reader.ReadInt32();
                        QuestIndex = reader.ReadInt32();
                    }
                    if (LoadVersion >= 63)
                    {
                        GameshopIndex = reader.ReadInt32();
                    }

                    int count = reader.ReadInt32();
                    MapInfoList.Clear();
                    for (int i = 0; i < count; i++)
                        MapInfoList.Add(new MapInfo(reader));

                    count = reader.ReadInt32();
                    ItemInfoList.Clear();
                    for (int i = 0; i < count; i++)
                    {
                        ItemInfoList.Add(new ItemInfo(reader, LoadVersion, LoadCustomVersion));
                        if ((ItemInfoList[i] != null) && (ItemInfoList[i].RandomStatsId < Settings.RandomItemStatsList.Count))
                        {
                            ItemInfoList[i].RandomStats = Settings.RandomItemStatsList[ItemInfoList[i].RandomStatsId];
                        }
                    }
                    count = reader.ReadInt32();
                    MonsterInfoList.Clear();
                    for (int i = 0; i < count; i++)
                        MonsterInfoList.Add(new MonsterInfo(reader));

                    if (LoadVersion > 33)
                    {
                        count = reader.ReadInt32();
                        NPCInfoList.Clear();
                        for (int i = 0; i < count; i++)
                            NPCInfoList.Add(new NPCInfo(reader));

                        count = reader.ReadInt32();
                        QuestInfoList.Clear();
                        for (int i = 0; i < count; i++)
                            QuestInfoList.Add(new QuestInfo(reader));
                    }

                    if (LoadVersion >= 11) DragonInfo = new DragonInfo(reader);
                    else DragonInfo = new DragonInfo();
                    if (LoadVersion >= 58)
                    {
                        count = reader.ReadInt32();
                        for (int i = 0; i < count; i++)
                            MagicInfoList.Add(new MagicInfo(reader));
                    }
                    FillMagicInfoList();

                    if (LoadVersion >= 63)
                    {
                        count = reader.ReadInt32();
                        GameShopList.Clear();
                        for (int i = 0; i < count; i++)
                        {
                            GameShopItem item = new GameShopItem(reader, LoadVersion, LoadCustomVersion);
                            if (SMain.Envir.BindGameShop(item))
                            {
                                GameShopList.Add(item);
                            }
                        }
                    }
                }
                Settings.LinkGuildCreationItems(ItemInfoList);
            }
        }
Exemplo n.º 12
0
        // 从原始的文件数据库中读取数据
        public void loadFromFile(string path)
        {
            using (var stream = File.OpenRead(path))
                using (var reader = new BinaryReader(stream))
                {
                    LoadVersion = reader.ReadInt32();
                    if (LoadVersion > 57)
                    {
                        LoadCustomVersion = reader.ReadInt32();
                    }
                    MapIndex     = reader.ReadInt32();
                    ItemIndex    = reader.ReadInt32();
                    MonsterIndex = reader.ReadInt32();

                    if (LoadVersion > 33)
                    {
                        NPCIndex   = reader.ReadInt32();
                        QuestIndex = reader.ReadInt32();
                    }
                    if (LoadVersion >= 63)
                    {
                        GameshopIndex = reader.ReadInt32();
                    }

                    if (LoadVersion >= 66)
                    {
                        ConquestIndex = reader.ReadInt32();
                    }

                    if (LoadVersion >= 68)
                    {
                        RespawnIndex = reader.ReadInt32();
                    }

                    var count = reader.ReadInt32();
                    MapInfoList.Clear();
                    for (var i = 0; i < count; i++)
                    {
                        MapInfoList.Add(new MapInfo(reader, this));
                    }

                    count = reader.ReadInt32();
                    ItemInfoList.Clear();
                    for (var i = 0; i < count; i++)
                    {
                        ItemInfoList.Add(new ItemInfo(reader, LoadVersion, LoadCustomVersion));
                        // TODO
                        // 这部分是从 Setting 里面加, 以后改成数据库
                        // if (ItemInfoList[i] != null && ItemInfoList[i].RandomStatsId < Settings.RandomItemStatsList.Count)
                        // {
                        //     ItemInfoList[i].RandomStats = Settings.RandomItemStatsList[ItemInfoList[i].RandomStatsId];
                        // }
                    }
                    count = reader.ReadInt32();
                    MonsterInfoList.Clear();
                    for (var i = 0; i < count; i++)
                    {
                        MonsterInfoList.Add(new MonsterInfo(reader, this));
                    }

                    if (LoadVersion > 33)
                    {
                        count = reader.ReadInt32();
                        NPCInfoList.Clear();
                        for (var i = 0; i < count; i++)
                        {
                            NPCInfoList.Add(new NPCInfo(reader, this));
                        }

                        count = reader.ReadInt32();
                        QuestInfoList.Clear();
                        for (var i = 0; i < count; i++)
                        {
                            QuestInfoList.Add(new QuestInfo(reader, this));
                        }
                    }

                    DragonInfo = LoadVersion >= 11 ? new DragonInfo(reader) : new DragonInfo();

                    if (LoadVersion >= 58)
                    {
                        count = reader.ReadInt32();
                        for (var i = 0; i < count; i++)
                        {
                            var m = new MagicInfo(reader, LoadVersion, LoadCustomVersion);
                            if (!MagicExists(m.Spell))
                            {
                                MagicInfoList.Add(m);
                            }
                        }
                    }

                    FillMagicInfoList();
                    if (LoadVersion <= 70)
                    {
                        UpdateMagicInfo();
                    }

                    if (LoadVersion >= 63)
                    {
                        count = reader.ReadInt32();
                        GameShopItemList.Clear();
                        for (var i = 0; i < count; i++)
                        {
                            var item = new GameShopItem(reader, LoadVersion, LoadCustomVersion);
                            if (BindGameShop(item))
                            {
                                GameShopItemList.Add(item);
                            }
                        }
                    }

                    if (LoadVersion >= 66)
                    {
                        ConquestInfos.Clear();
                        count = reader.ReadInt32();
                        for (var i = 0; i < count; i++)
                        {
                            ConquestInfos.Add(new ConquestInfo(reader, this));
                        }
                    }

                    if (LoadVersion > 67)
                    {
                        RespawnTick = new RespawnTimer(reader, this);
                    }
                }
        }
Exemplo n.º 13
0
        public void Remove(GameShopItem info)
        {
            GameShopList.Remove(info);

            if (GameShopList.Count == 0)
            {
                GameshopIndex = 0;
            }

            //Desync all objects\
        }
Exemplo n.º 14
0
        public bool BindGameShop(GameShopItem item, bool EditEnvir = true)
        {
            for (int i = 0; i < SMain.EditEnvir.ItemInfoList.Count; i++)
            {
                ItemInfo info = SMain.EditEnvir.ItemInfoList[i];
                if (info.Index != item.ItemIndex) continue;
                item.Info = info;

                return true;
            }
            return false;
        }
Exemplo n.º 15
0
        public void ItemGSBought(string source, GameShopItem item, uint amount, uint CreditCost, uint GoldCost)
        {
            string type = string.Empty;
            string task = string.Empty;

            if (item != null)
            {
                task = string.Format("Purchased {1} x {0} for {2} Credits and {3} Gold.", item.Info.FriendlyName, amount, CreditCost, GoldCost );
            }

            Action action = new Action { Source = source, Task = task };

            RecordAction(action);
        }
Exemplo n.º 16
0
 protected override void ReadPacket(BinaryReader reader)
 {
     Item = new GameShopItem(reader, true);
     StockLevel = reader.ReadInt32();
 }
Exemplo n.º 17
0
        public void GetGameShop()
        {
            int purchased;
            GameShopItem item = new GameShopItem();
            int StockLevel;

            for (int i = 0; i < Envir.GameShopList.Count; i++)
            {
                item = Envir.GameShopList[i];

                if (item.Stock != 0)
                {
                    if (item.iStock) //Individual Stock
                    {
                        Info.GSpurchases.TryGetValue(item.Info.Index, out purchased);
                    }
                    else //Server Stock
                    {
                        Envir.GameshopLog.TryGetValue(item.Info.Index, out purchased);
                    }

                    if (item.Stock - purchased >= 0)
                    {
                        StockLevel = item.Stock - purchased;
                        Enqueue(new S.GameShopInfo { Item = item, StockLevel = StockLevel });
                    }
                }
                else
                {
                    Enqueue(new S.GameShopInfo { Item = item, StockLevel = item.Stock });
                }  
            }
        }
Exemplo n.º 18
0
        public void GameShopStock(GameShopItem item)
        {
            int purchased;
            int StockLevel;

            if (item.iStock) //Invididual Stock
            {
                Info.GSpurchases.TryGetValue(item.Info.Index, out purchased);
            }
            else //Server Stock
            {
                Envir.GameshopLog.TryGetValue(item.Info.Index, out purchased);
            }

            if (item.Stock - purchased >= 0)
            {
                StockLevel = item.Stock - purchased;
                Enqueue(new S.GameShopStock { GIndex = item.Info.Index, StockLevel = StockLevel });
            }
              
        }
Exemplo n.º 19
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            Item = null;
            GameScene.HoverItem = null;
            ShowItem = null;
        }