示例#1
0
        public void SetGameobjectLootData(GameObjectLootItemParsing[] gameobjectLootItemDatas, GameObjectLootCurrencyParsing[] gameobjectLootCurrencyDatas)
        {
            GameObjectLootParsing[] gameobjectLootDatas = new GameObjectLootParsing[gameobjectLootItemDatas.Length + gameobjectLootCurrencyDatas.Length];
            Array.Copy(gameobjectLootItemDatas, gameobjectLootDatas, gameobjectLootItemDatas.Length);
            Array.Copy(gameobjectLootCurrencyDatas, 0, gameobjectLootDatas, gameobjectLootItemDatas.Length, gameobjectLootCurrencyDatas.Length);

            List <String> modes = new List <String>()
            {
                "1", "2", "4", "33554432"
            };

            for (uint i = 0; i < gameobjectLootDatas.Length; ++i)
            {
                float count   = 0.0f;
                float outof   = 0.0f;
                float percent = 0.0f;

                foreach (String mode in modes)
                {
                    try
                    {
                        count   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes[mode]["count"]);
                        outof   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes[mode]["outof"]);
                        percent = count * 100 / outof;
                    }
                    catch (Exception) { }
                }

                GameObjectLootItemParsing currentItemParsing = null;
                try
                {
                    currentItemParsing = (GameObjectLootItemParsing)gameobjectLootDatas[i];
                }
                catch (Exception) { }

                gameobjectLootDatas[i].questRequired = currentItemParsing != null && currentItemParsing.classs == 12 ? "1": "0";

                // Normalize
                if (percent > 99.0f)
                {
                    percent = 100.0f;
                }

                gameobjectLootDatas[i].percent = Tools.NormalizeFloat(percent);
            }

            m_gameobjectLootDatas = gameobjectLootDatas;
        }
        public void SetGameobjectLootData(GameObjectLootItemParsing[] gameobjectLootItemDatas, GameObjectLootCurrencyParsing[] gameobjectLootCurrencyDatas)
        {
            GameObjectLootParsing[] gameobjectLootDatas = new GameObjectLootParsing[gameobjectLootItemDatas.Length + gameobjectLootCurrencyDatas.Length];
            Array.Copy(gameobjectLootItemDatas, gameobjectLootDatas, gameobjectLootItemDatas.Length);
            Array.Copy(gameobjectLootCurrencyDatas, 0, gameobjectLootDatas, gameobjectLootItemDatas.Length, gameobjectLootCurrencyDatas.Length);

            for (uint i = 0; i < gameobjectLootDatas.Length; ++i)
            {
                float count   = 0.0f;
                float outof   = 0.0f;
                float percent = 0.0f;

                try
                {
                    count   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["1"]["count"]);
                    outof   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["1"]["outof"]);
                    percent = count * 100 / outof;
                }
                catch (Exception)
                {
                    try
                    {
                        count   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["4"]["count"]);
                        outof   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["4"]["outof"]);
                        percent = count * 100 / outof;
                    }
                    catch (Exception)
                    {
                        try
                        {
                            count   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["2"]["count"]);
                            outof   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["2"]["outof"]);
                            percent = count * 100 / outof;
                        }
                        catch (Exception)
                        {
                            try
                            {
                                count   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["33554432"]["count"]);
                                outof   = (float)Convert.ToDouble(gameobjectLootDatas[i].modes["33554432"]["outof"]);
                                percent = count * 100 / outof;
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                            }
                        }
                    }
                }

                GameObjectLootItemParsing currentItemParsing = null;
                try
                {
                    currentItemParsing = (GameObjectLootItemParsing)gameobjectLootDatas[i];
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Erreur : " + ex);
                }

                gameobjectLootDatas[i].questRequired = currentItemParsing != null && currentItemParsing.classs == 12 ? "1": "0";

                // Normalize
                if (percent > 99.0f)
                {
                    percent = 100.0f;
                }

                gameobjectLootDatas[i].percent = Tools.NormalizeFloat(percent);
            }

            m_gameobjectLootDatas = gameobjectLootDatas;
        }