示例#1
0
    public bool CanPick(Pick.PickType type, int content)
    {
        if (type == Pick.PickType.SUPER_WEAPON && !CanChangeWeapon())
        {
            return(false);
        }

        return(true);
    }
示例#2
0
    // 生成掉落物
    public static bool CreatePickInitParam(Pick.PickType picktype, int resid, int content, Vector3 pos, float dir, out List <PickInitParam> paramList, bool randomPos = false, Pick.FlyType flytype = Pick.FlyType.FLY_OUT, bool isDropBoxId = true)
    {
        paramList = new List <PickInitParam>();

        if (content < 0)
        {
            return(false);
        }

        if (picktype <= Pick.PickType.INVALID || picktype >= Pick.PickType.TYPE_COUNT)
        {
            return(false);
        }

        if (isDropBoxId)
        {
            ArrayList buffList = new ArrayList();
            if (DropManager.Instance.GenerateDropBox(content, out buffList))
            {
                foreach (DropBoxItem item in buffList)
                {
                    int pickres_id = item.itemid;

                    if (picktype == Pick.PickType.ITEM)
                    {
                        ItemTableItem itemres = ItemManager.GetItemRes(item.itemid);
                        if (itemres == null)
                        {
                            continue;
                        }

                        pickres_id = itemres.pickId;
                    }

                    for (int i = 0; i < item.itemnum; ++i)
                    {
                        PickInitParam initParam = new PickInitParam();
                        initParam.pick_type   = picktype;
                        initParam.pick_res_id = pickres_id;
                        initParam.init_dir    = dir;
                        initParam.init_pos    = pos;
                        initParam.random_pos  = randomPos;
                        initParam.fly_type    = flytype;

                        paramList.Add(initParam);
                    }
                }
            }
        }
        else
        {
            int pickres_id = resid;

            if (picktype == Pick.PickType.MONEY)
            {
                if (content < 1)
                {
                    return(false);
                }
            }
            else if (picktype == Pick.PickType.SUPER_WEAPON)
            {
                if (!DataManager.SuperWeaponTable.ContainsKey(content))
                {
                    GameDebug.LogError("没找到超级武器 id = " + content.ToString());
                    return(false);
                }
            }
            else if (picktype == Pick.PickType.ITEM)
            {
                ItemTableItem itemres = ItemManager.GetItemRes(content);
                if (itemres == null)
                {
                    return(false);
                }

                pickres_id = itemres.pickId;
            }

            PickInitParam initParam = new PickInitParam();
            initParam.pick_type   = picktype;
            initParam.pick_res_id = pickres_id;
            initParam.content     = content;
            initParam.init_dir    = dir;
            initParam.init_pos    = pos;
            initParam.random_pos  = randomPos;
            initParam.fly_type    = flytype;

            paramList.Add(initParam);
        }

        return(true);
    }