示例#1
0
    private void DropOneReward(DropGroup dropGroup, Vector3 postion)
    {
        float dropDice     = Random.value;
        float _currentRate = 0.0f;

        Item       item       = null;
        GameObject itemPrefab = null;

        foreach (DropItem dropItem in dropGroup.Drops)
        {
            _currentRate += dropItem.ItemDropRate;
            if (_currentRate >= dropDice)
            {
                item       = dropItem.Item;
                itemPrefab = dropItem.Item.Prefab;
                break;
            }
        }

        float      randAngle       = Random.value * Mathf.PI * 2;
        GameObject collectibleItem = GameObject.Instantiate(itemPrefab,
                                                            postion + itemPrefab.transform.localPosition +
                                                            _dropRewardConfig.ScatteringDistance * (Mathf.Cos(randAngle) * Vector3.forward + Mathf.Sin(randAngle) * Vector3.right),
                                                            Quaternion.identity);

        collectibleItem.GetComponent <CollectibleItem>().SetItem(item);
    }
        private void fillGroupClientDropDown()
        {
            try
            {
                DropGroup.Items.Clear();
                string q = "select distinct profile_class_id, group_name from innodis_ean_cusgroup";

                myConn.Open();
                OracleCommand cmd = new OracleCommand(q, myConn);

                DataTable ClientDataGroup = new DataTable();
                ClientDataGroup.Columns.Add("profile_class_id", typeof(int));
                ClientDataGroup.Columns.Add("group_name", typeof(string));
                ClientDataGroup.Columns.Add("ConcatenatedField", typeof(string), "profile_class_id + ' | ' +group_name");
                OracleDataAdapter sda = new OracleDataAdapter();
                sda.SelectCommand = cmd;
                sda.Fill(ClientDataGroup);

                DropGroup.DataSource     = ClientDataGroup;
                DropGroup.DataTextField  = "ConcatenatedField";
                DropGroup.DataValueField = "profile_class_id";
                DropGroup.DataBind();

                myConn.Close();
            }
            catch (OracleException ex)
            {
                if (myConn.State == ConnectionState.Open)
                {
                    myConn.Close();
                }
            }
        }
示例#3
0
        public void ParseRow(string[] rowData)
        {
            DropIds         = new CacheList <DropGroup>();
            CleanOutDropIds = new CacheList <DropGroup>();
            int index = 0;

            index++;
            Id = int.Parse(rowData[index++]);
            index++;
            Name                    = rowData[index++];
            Description             = rowData[index++];
            RequestDescription0     = rowData[index++];
            RequestDescription1     = rowData[index++];
            RequestDescription2     = rowData[index++];
            PrerequisiteInstanceId  = int.Parse(rowData[index++]);
            PrerequisitePlayerLevel = int.Parse(rowData[index++]);
            InstanceGroupId         = int.Parse(rowData[index++]);
            index++; // Skip recommend level
            PlayerExp = int.Parse(rowData[index++]);
            HeroExp   = int.Parse(rowData[index++]);
            Coin      = int.Parse(rowData[index++]);
            string drops = rowData[index++].Trim('"');

            foreach (string drop in drops.Split(';'))
            {
                DropGroup dropGroup = new DropGroup(drop);
                DropIds.Add(dropGroup);
            }
            string cleanOutDrops = rowData[index++].Trim('"');

            foreach (string drop in cleanOutDrops.Split(';'))
            {
                DropGroup dropGroup = new DropGroup(drop);
                CleanOutDropIds.Add(dropGroup);
            }
            SceneId       = rowData[index++];
            TimerType     = int.Parse(rowData[index++]);
            TimerDuration = int.Parse(rowData[index++]);
            TimerAlert    = int.Parse(rowData[index++]);
            //AIBehavior = rowData[index++];
            index           += 4;
            InstanceNpcs     = rowData[index++];
            SpawnPointX      = float.Parse(rowData[index++]);
            SpawnPointY      = float.Parse(rowData[index++]);
            SpawnAngle       = float.Parse(rowData[index++]);
            index           += 37;
            InInstanceChests = new CacheList <int>();
            while (index < rowData.Length)
            {
                int chestId = int.Parse(rowData[index++]);
                if (chestId < 0)
                {
                    break;
                }
                InInstanceChests.Add(chestId);
            }
            DTInstanceCache.AddOrUpdate(Id.ToString(), this);
        }
示例#4
0
            public void Serialize(EB.BitStream bs)
            {
                bs.Serialize(ref _locationIndex);
                bs.Serialize(ref _characterId);
                bs.Serialize(ref _xp);

                if (bs.isReading)
                {
                    DropGroup = new DropGroupData();
                }
                DropGroup.Serialize(bs);
            }
示例#5
0
 protected void DropState_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (DropGroup.SelectedItem.Value == "-1")
     {
         DropGroup.Items.Clear();
         DropGroup.Items.Insert(0, new ListItem("请选择", "-1"));
     }
     else
     {
         string sql = "select * from ML_ImageClass where nID=" + DropGroup.SelectedItem.Value;
         DropGroup.DataSource     = her.ExecuteDataTable(sql);
         DropGroup.DataValueField = "nID";
         DropGroup.DataTextField  = "tClassName";
         DropGroup.DataBind();
         DropGroup.Items.Insert(0, new ListItem("请选择", "-1"));
     }
 }
示例#6
0
    private void DropAllRewards(Vector3 position)
    {
        DropGroup specialDropItem = _dropRewardConfig.DropSpecialItem();

        if (specialDropItem != null)         // drops a special item if any
        {
            DropOneReward(specialDropItem, position);
        }
        // Drop items
        foreach (DropGroup dropGroup in _dropRewardConfig.DropGroups)
        {
            float randValue = Random.value;
            if (dropGroup.DropRate >= randValue)
            {
                DropOneReward(dropGroup, position);
            }
            else
            {
                break;
            }
        }
    }
示例#7
0
        protected override List <ItemDropMetadata> Parse()
        {
            Dictionary <int, List <DropGroup> > itemGroups = new Dictionary <int, List <DropGroup> >();
            List <ItemDropMetadata>             drops      = new List <ItemDropMetadata>();

            foreach (PackFileEntry entry in Resources.XmlReader.Files)
            {
                if (!entry.Name.StartsWith("table/individualitemdrop") && !entry.Name.StartsWith("table/na/individualitemdrop"))
                {
                    continue;
                }

                XmlDocument document           = Resources.XmlReader.GetXmlDocument(entry);
                XmlNodeList individualBoxItems = document.SelectNodes($"/ms2/individualDropBox");
                foreach (XmlNode node in individualBoxItems)
                {
                    string locale = string.IsNullOrEmpty(node.Attributes["locale"]?.Value) ? "" : node.Attributes["locale"].Value;

                    if (locale != "NA" && locale != "")
                    {
                        continue;
                    }

                    int boxId       = int.Parse(node.Attributes["individualDropBoxID"].Value);
                    int dropGroupId = int.Parse(node.Attributes["dropGroup"].Value);

                    DropGroupContent contents = new DropGroupContent();

                    List <int> itemIds = new List <int>
                    {
                        int.Parse(node.Attributes["item"].Value)
                    };
                    if (node.Attributes["item2"] != null)
                    {
                        itemIds.Add(int.Parse(node.Attributes["item2"].Value));
                    }

                    if (node.Attributes["smartDropRate"] != null)
                    {
                        contents.SmartDropRate = int.Parse(node.Attributes["smartDropRate"].Value);
                    }

                    if (node.Attributes["enchantLevel"] != null)
                    {
                        contents.EnchantLevel = byte.Parse(node.Attributes["enchantLevel"].Value);
                    }

                    if (node.Attributes["isApplySmartGenderDrop"] != null)
                    {
                        contents.SmartGender = node.Attributes["isApplySmartGenderDrop"].Value.ToLower() == "true";
                    }

                    contents.MinAmount = float.Parse(node.Attributes["minCount"].Value);
                    contents.MaxAmount = float.Parse(node.Attributes["maxCount"].Value);
                    contents.Rarity    = 1;
                    if (node.Attributes["PackageUIShowGrade"] != null)
                    {
                        contents.Rarity = (byte)(string.IsNullOrEmpty(node.Attributes["PackageUIShowGrade"]?.Value) ? 1 : byte.Parse(node.Attributes["PackageUIShowGrade"].Value));
                    }

                    contents.ItemIds.AddRange(itemIds);

                    if (itemGroups.ContainsKey(boxId))
                    {
                        if (itemGroups[boxId].FirstOrDefault(x => x.Id == dropGroupId) != default)
                        {
                            DropGroup group = itemGroups[boxId].FirstOrDefault(x => x.Id == dropGroupId);
                            group.Contents.Add(contents);
                            continue;
                        }

                        DropGroup newGroup = new DropGroup();
                        newGroup.Id = dropGroupId;
                        newGroup.Contents.Add(contents);
                        itemGroups[boxId].Add(newGroup);
                        continue;
                    }
                    else
                    {
                        itemGroups[boxId] = new List <DropGroup>();
                        DropGroup newGroup = new DropGroup();
                        newGroup.Id = dropGroupId;
                        newGroup.Contents.Add(contents);
                        itemGroups[boxId].Add(newGroup);
                    }
                }

                foreach (KeyValuePair <int, List <DropGroup> > kvp in itemGroups)
                {
                    ItemDropMetadata metadata = new ItemDropMetadata();
                    metadata.Id         = kvp.Key;
                    metadata.DropGroups = kvp.Value;
                    drops.Add(metadata);
                }
            }
            return(drops);
        }
示例#8
0
 //Method yang dieksekusi ketika user merubah pola
 protected void DropPola_SelectedIndexChanged(object sender, EventArgs e)
 {
     DropGroup.DataBind();
 }
示例#9
0
    // 初始化
    public void InitDataStruct()
    {
        mDropGroups = new Dictionary <int, DropGroup>();
        System.Type           grouptype = typeof(DropGroupTableItem);
        IDictionaryEnumerator itr       = DataManager.DropGroupTable.GetEnumerator();

        while (itr.MoveNext())
        {
            DropGroupTableItem res       = itr.Value as DropGroupTableItem;
            DropGroup          dropgroup = new DropGroup();
            dropgroup.items = new ArrayList();
            dropgroup.id    = res.id;

            for (int i = 0; i < DropGroupTableItem.MAX_ITEM_NUM; ++i)
            {
                System.Reflection.FieldInfo fieldid = grouptype.GetField("dropBoxId" + i.ToString());
                int dropboxid = (int)fieldid.GetValue(res);

                System.Reflection.FieldInfo fieldweight = grouptype.GetField("dropBoxWeight" + i.ToString());
                int dropboxweight = (int)fieldweight.GetValue(res);

                if (dropboxid < 0 || dropboxweight < 1)
                {
                    break;
                }

                DropGroupItem item = new DropGroupItem();
                item.dropboxid     = dropboxid;
                item.dropboxweight = dropboxweight;

                dropgroup.items.Add(item);
            }

            mDropGroups.Add(res.id, dropgroup);
        }
//      foreach (DropGroupTableItem res in DataManager.DropGroupTable.Values)
//      {
//          DropGroup dropgroup = new DropGroup();
//          dropgroup.items = new ArrayList();
//          dropgroup.id = res.id;
//
//          for (int i = 0; i < DropGroupTableItem.MAX_ITEM_NUM; ++i)
//          {
//              System.Reflection.FieldInfo fieldid = grouptype.GetField("dropBoxId" + i.ToString());
//              int dropboxid = (int)fieldid.GetValue(res);
//
//              System.Reflection.FieldInfo fieldweight = grouptype.GetField("dropBoxWeight" + i.ToString());
//              int dropboxweight = (int)fieldweight.GetValue(res);
//
//              if (dropboxid < 0 || dropboxweight < 1)
//              {
//                  break;
//              }
//
//              DropGroupItem item = new DropGroupItem();
//              item.dropboxid = dropboxid;
//              item.dropboxweight = dropboxweight;
//
//              dropgroup.items.Add(item);
//          }
//
//          mDropGroups.Add(res.id, dropgroup);
//      }

        mDropBoxes = new Dictionary <int, DropBox>();

        System.Type type = typeof(DropBoxTableItem);
        itr = DataManager.DropBoxTable.GetEnumerator();
        while (itr.MoveNext())
        {
            DropBoxTableItem res     = itr.Value as DropBoxTableItem;
            DropBox          dropbox = new DropBox();
            dropbox.items = new ArrayList();
            dropbox.id    = res.id;
            dropbox.desc  = res.desc;

            for (int i = 0; i < DropBoxTableItem.MAX_ITEM_NUM; ++i)
            {
                System.Reflection.FieldInfo fieldid = type.GetField("itemid" + i.ToString());
                int itemid = (int)fieldid.GetValue(res);

                System.Reflection.FieldInfo fieldnum = type.GetField("itemnum" + i.ToString());
                int itemnum = (int)fieldnum.GetValue(res);

                System.Reflection.FieldInfo fieldweight = type.GetField("itemweight" + i.ToString());
                int itemweight = (int)fieldweight.GetValue(res);

                if (itemid < 0 || itemnum < 1 || itemweight < 1)
                {
                    break;
                }

                DropBoxItem item = new DropBoxItem();
                item.itemid            = itemid;
                item.itemnum           = itemnum;
                item.itemweight        = itemweight;
                item.isItemOrCondition = res.isItemId > 0;

                dropbox.items.Add(item);
            }

            mDropBoxes.Add(res.id, dropbox);
        }
//      foreach(DropBoxTableItem res in DataManager.DropBoxTable.Values)
//      {
//
//      }
    }
示例#10
0
    /// <summary>
    /// 随机生成掉落道具ID。从dropgroup开始随机
    /// </summary>
    /// <param name="dropgroupId">dropgroup.txt的Id</param>
    /// <param name="droplist">输出生成的DropItem列表</param>
    /// <param name="dropnum">需要生成几个道具,-1表示不限制个数,按表规则掉落</param>
    /// <returns></returns>
    public bool GenerateDropGroup(int dropgroupId, out ArrayList droplist, int dropnum = -1)
    {
        droplist = null;

        if (!mDropGroups.ContainsKey(dropgroupId) || !DataManager.DropGroupTable.ContainsKey(dropgroupId))
        {
            return(false);
        }

        DropGroupTableItem res = DataManager.DropGroupTable[dropgroupId] as DropGroupTableItem;

        DropGroup group = mDropGroups[dropgroupId] as DropGroup;

        if (group == null)
        {
            return(false);
        }

        droplist = new ArrayList();
        ArrayList dropboxlist = new ArrayList();

        if (dropnum > 0)
        {        // 在dropnum次随机中 不允许重复掉落 在掉落组中整体随机
            while (dropboxlist.Count < dropnum)
            {
                int rand   = Random.Range(0, MAX_WEIGHT);
                int weight = 0;
                for (int i = 0; i < group.items.Count; ++i)
                {
                    DropGroupItem item = group.items[i] as DropGroupItem;

                    if ((item.dropboxweight + weight) > rand)
                    {
                        if (!dropboxlist.Contains(item))
                        {
                            dropboxlist.Add(item);
                        }

                        break;
                    }

                    weight += item.dropboxweight;
                }
            }
        }
        else
        {        // 未指定掉落个数 不允许重复掉落 每个道具单独随机
            int maxnum = res.maxnum;
            if (maxnum > group.items.Count)
            {
                maxnum = group.items.Count;
            }

            for (int i = 0; i < group.items.Count; ++i)
            {
                int           rand = Random.Range(0, MAX_WEIGHT);
                DropGroupItem item = group.items[i] as DropGroupItem;
                if ((item.dropboxweight) > rand)
                {
                    if (!dropboxlist.Contains(item))
                    {
                        dropboxlist.Add(item);
                    }
                }

                if (dropboxlist.Count >= maxnum)
                {
                    break;
                }
            }
        }

        ArrayList genlist = new ArrayList();

        foreach (DropGroupItem groupres in dropboxlist)
        {
            genlist.Clear();
            if (!GenerateDropBox(groupres.dropboxid, out genlist))
            {
                continue;
            }

            foreach (DropBoxItem item in genlist)
            {
                droplist.Add(item);
            }
        }

        return(true);
    }