Beispiel #1
0
    public void Drop(MeteorUnit player)
    {
        //player.Attr;
        //List<GameObject> obj = new List<GameObject>();
        //一定爆出角色主武器,有Flag爆出Flag,并且这个Flag,会持续一定时间,若无人拾取,则会重置Flag归位.
        int mainWeapon = player.Attr.Weapon;

        ItemDatas.ItemDatas     ib = Main.Ins.DataMgr.GetData <ItemDatas.ItemDatas>(mainWeapon);
        WeaponDatas.WeaponDatas wb = U3D.GetWeaponProperty(ib.UnitId);
        GameObject trigget         = CreateTriggerObj(wb.WeaponR, player.transform, -player.transform.forward);

        //obj.Add(trigget);
        //ExplosionObject01.iTweenExplosion01(1, ref obj, player.transform.position);
        ExplosionObject01.DropItem(trigget, player.transform.position, -player.transform.forward);
        //如果角色拥有第二武器,那么第一武器扔掉时,切换到第二武器
        player.DropAndChangeWeapon();

        //扔掉Flag道具
        if (player.GetFlag)
        {
            trigget = CreateObj(player.GetFlagItem.model, player.transform, -player.transform.forward);
            ExplosionObject01.DropItem(trigget, player.transform.position, Quaternion.AngleAxis(30, Vector3.up) * -player.transform.forward);
            player.SetFlag(null, 0);
        }
    }
    public void OnPickup(MeteorUnit unit)
    {
        if (unit != null && !unit.Dead)
        {
            //满武器,不能捡
            if (unit.Attr.Weapon != 0 && unit.Attr.Weapon2 != 0)
            {
                return;
            }
            //相同武器,不能捡
            ItemDatas.ItemDatas     ib0 = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon);
            WeaponDatas.WeaponDatas wb0 = U3D.GetWeaponProperty(ib0.UnitId);
            if (wb0 != null && wb0.WeaponR == model)
            {
                return;
            }

            if (unit.Attr.Weapon2 != 0)
            {
                ItemDatas.ItemDatas     ib1 = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon2);
                WeaponDatas.WeaponDatas wb1 = U3D.GetWeaponProperty(ib1.UnitId);
                if (wb1 != null && wb1.WeaponR == model)
                {
                    return;
                }
            }

            //同类武器不能捡
            int weaponPickup       = Main.Ins.GameStateMgr.GetWeaponCode(model);
            ItemDatas.ItemDatas wb = Main.Ins.GameStateMgr.FindItemByIdx(weaponPickup);
            if (wb == null)
            {
                return;
            }

            ItemDatas.ItemDatas wbl = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon);
            if (wbl == null)
            {
                return;
            }

            ItemDatas.ItemDatas wbr = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon2);
            if (wb.SubType == wbl.SubType)
            {
                return;
            }

            if (wbr != null && wb.SubType == wbr.SubType)
            {
                return;
            }
            //可以捡取
            unit.Attr.Weapon2 = weaponPickup;
            Main.Ins.SFXLoader.PlayEffect(672, unit.gameObject, true);
            Destroy(gameObject);
        }
    }
Beispiel #3
0
    public void DropWeapon2(int weaponId)
    {
        MeteorUnit player = Main.Ins.LocalPlayer;

        WeaponDatas.WeaponDatas wb = U3D.GetWeaponProperty(weaponId);
        string     des             = wb.WeaponR;
        GameObject trigget         = CreateTriggerObj(des, player.transform, -player.transform.forward);

        ExplosionObject01.DropItem(trigget, player.transform.position, -player.transform.forward);
    }
Beispiel #4
0
    public void DropWeapon(MeteorUnit player)
    {
        int mainWeapon = player.Attr.Weapon2;

        if (mainWeapon == 0)
        {
            return;
        }
        ItemDatas.ItemDatas     ib = Main.Ins.DataMgr.GetData <ItemDatas.ItemDatas>(mainWeapon);
        WeaponDatas.WeaponDatas wb = U3D.GetWeaponProperty(ib.UnitId);
        GameObject trigget         = CreateTriggerObj(wb.WeaponR, player.transform, -player.transform.forward);

        //obj.Add(trigget);
        //ExplosionObject01.iTweenExplosion01(1, ref obj, player.transform.position);
        player.Attr.Weapon2 = 0;
        ExplosionObject01.DropItem(trigget, player.transform.position, -player.transform.forward);
    }
    void Init()
    {
        RectTransform rectTran = WndObject.GetComponent <RectTransform>();

        if (rectTran != null)
        {
            rectTran.anchoredPosition = new Vector2((1920f - rectTran.sizeDelta.x) / 2.0f, -(1080f - rectTran.sizeDelta.y) / 2.0f);
        }
        GameObject      obj       = NodeHelper.Find("3DParent", WndObject);
        GameObject      objPlayer = GameObject.Instantiate(Resources.Load("3DUIPlayer")) as GameObject;
        MeteorUnitDebug d         = objPlayer.GetComponent <MeteorUnitDebug>();

        objPlayer.transform.position   = Vector3.zero;
        objPlayer.transform.rotation   = Quaternion.identity;
        objPlayer.transform.localScale = Vector3.one;
        d.gameObject.layer             = obj.gameObject.layer;
        d.Init(Main.Ins.LocalPlayer.UnitId, LayerMask.NameToLayer("3DUIPlayer"));
        WeaponDatas.WeaponDatas weaponProperty = U3D.GetWeaponProperty(Main.Ins.LocalPlayer.weaponLoader.GetCurrentWeapon().Info().UnitId);
        d.weaponLoader.StrWeaponR = weaponProperty.WeaponR;
        d.weaponLoader.StrWeaponL = weaponProperty.WeaponL;
        //d.weaponLoader.EquipWeapon();
        d.transform.SetParent(obj.transform);
        d.transform.localScale    = 8 * Vector3.one;
        d.transform.localPosition = new Vector3(0, 0, -300);
        d.transform.localRotation = Quaternion.identity;
        NodeHelper.Find("Close Button", WndObject).GetComponent <Button>().onClick.AddListener(OnBackPress);

        SetStat("Stat Label 1", Main.Ins.LocalPlayer.Attr.hpCur + "/" + Main.Ins.LocalPlayer.Attr.HpMax);
        SetStat("Stat Label 2", Main.Ins.LocalPlayer.AngryValue.ToString());
        SetStat("Stat Label 3", Main.Ins.LocalPlayer.CalcDamage().ToString());
        SetStat("Stat Label 4", Main.Ins.LocalPlayer.CalcDef().ToString());
        SetStat("Stat Label 5", Main.Ins.LocalPlayer.MoveSpeed.ToString());
        SetStat("Stat Label 6", string.Format("{0:f2}", Main.Ins.LocalPlayer.MoveSpeed / 1000.0f));

        //处理背包的点击
        UIItemSlot[] slots = NodeHelper.Find("Slots Grid", WndObject).GetComponentsInChildren <UIItemSlot>();
        for (int i = 0; i < slots.Length; i++)
        {
            slots[i].onClick.AddListener(OnClickItem);
        }
    }
    public void LoadWeapon()
    {
        InventoryItem item = Weapon;

        if (item.Info().MainType == (int)EquipType.Weapon)
        {
            float scale = 1.0f;
            WeaponDatas.WeaponDatas weaponProperty = U3D.GetWeaponProperty(item.Info().UnitId);
            string weaponR = "";
            weaponR = weaponProperty.WeaponR;

            if (!string.IsNullOrEmpty(weaponR))
            {
                GameObject weaponPrefab = Resources.Load <GameObject>(weaponR);
                if (weaponPrefab == null)
                {
                    GMCFile fGmcL = Main.Ins.GMCLoader.Load(weaponR);
                    DesFile fDesL = Main.Ins.DesLoader.Load(weaponR);

                    if (fGmcL != null && fDesL != null)
                    {
                        GenerateWeaponModel(weaponR, fGmcL, fDesL, scale, weaponProperty.TextureL);
                    }
                    else if (fGmcL == null && fDesL != null)
                    {
                        GMBFile fGmbL = Main.Ins.GMBLoader.Load(weaponR);
                        GenerateWeaponModel(weaponR, fGmbL, fDesL, scale, weaponProperty.TextureL);
                    }
                }
                else
                {
                    if (R != null)
                    {
                        DestroyImmediate(R);
                    }
                    GameObject objWeapon = GameObject.Instantiate(weaponPrefab);
                    objWeapon.layer = LayerMask.NameToLayer("Flight");
                    R = objWeapon.transform;
                    //L = new GameObject().transform;
                    R.SetParent(WeaponRoot);
                    R.localPosition = Vector3.zero;
                    //这种导入来的模型,需要Y轴旋转180,与原系统的物件坐标系存在一些问题
                    R.localRotation = new Quaternion(0, 1, 0, 0);
                    R.name          = weaponR;
                    R.localScale    = Vector3.one;

                    //每个武器只能有一个碰撞盒
                    BoxCollider box = R.GetComponentInChildren <BoxCollider>();
                    if (box != null)
                    {
                        box.enabled = false;
                        //box.gameObject.tag = "Flight";
                        box.gameObject.layer = LayerMask.NameToLayer("Flight");
                        //weaponDamage.Add(box);
                    }
                    else
                    {
                        Debug.LogError("新增武器上找不到碰撞盒[除了暗器火枪飞轮外都应该有碰撞盒]");
                    }
                }
            }
        }
    }
    //把背包里的物品,装备到身上.
    public void EquipWeapon(InventoryItem item, bool ModelLayer = false)
    {
        if (Weapon == null && item != null)
        {
            if (item.Info().MainType == (int)EquipType.Weapon)
            {
                float scale = 1.0f;
                if (item.Info().Size != 0)//size为0的时候
                {
                    scale = (item.extra == null ? item.Info().Size : item.Info().Size *(1 + item.extra.SizePercent / 100.0f));
                }
                else
                {
                    scale = (item.extra == null ? 1 : (1 + item.extra.SizePercent / 100.0f));
                }
                WeaponDatas.WeaponDatas weaponProperty = U3D.GetWeaponProperty(item.Info().UnitId);


                string weaponL = "";
                string weaponR = "";
                PoseType = item.WeaponPos;
                if (item.WeaponPos == 0)
                {
                    weaponL = weaponProperty.WeaponL;
                    weaponR = weaponProperty.WeaponR;
                }
                else if (item.WeaponPos == 1)
                {
                    weaponL = weaponProperty.PosAWL;
                    weaponR = weaponProperty.PosAWR;
                }
                else if (item.WeaponPos == 2)
                {
                    weaponL = weaponProperty.PosBWL;
                    weaponR = weaponProperty.PosBWR;
                }

                //Debug.Log("加载武器:" + " 左手:" + weaponL + "右手:" + weaponR);
                if (!string.IsNullOrEmpty(weaponL))
                {
                    GameObject weaponPrefab = Resources.Load <GameObject>(weaponL);
                    if (weaponPrefab == null)
                    {
                        GMCFile fGmcL = Main.Ins.GMCLoader.Load(weaponL);
                        DesFile fDesL = Main.Ins.DesLoader.Load(weaponL);

                        if (fGmcL != null && fDesL != null)
                        {
                            GenerateWeaponModel(weaponL, fGmcL, fDesL, false, scale, weaponProperty.TextureL, ModelLayer);
                        }
                        else if (fGmcL == null && fDesL != null)
                        {
                            GMBFile fGmbL = Main.Ins.GMBLoader.Load(weaponL);
                            GenerateWeaponModel(weaponL, fGmbL, fDesL, false, scale, weaponProperty.TextureL, ModelLayer);
                        }
                    }
                    else
                    {
                        if (L != null)
                        {
                            DestroyImmediate(L);
                        }
                        GameObject objWeapon = GameObject.Instantiate(weaponPrefab);
                        objWeapon.layer = ModelLayer ? LayerMask.NameToLayer("RenderModel") : LayerMask.NameToLayer("Weapon");
                        L = objWeapon.transform;
                        //L = new GameObject().transform;
                        L.SetParent(LP);
                        L.localPosition = Vector3.zero;
                        //这种导入来的模型,需要Y轴旋转180,与原系统的物件坐标系存在一些问题
                        L.localRotation = new Quaternion(0, 1, 0, 0);
                        L.name          = weaponL;
                        L.localScale    = Vector3.one;
                        //WE = L;
                        //武器挂点必须在缩放正确后才能到指定的位置
                        WeaponTrail wt = L.gameObject.AddComponent <WeaponTrail>();
                        //右手
                        //GameObject ctrlRs = Global.ldaControlX("d_wpnRS", L.gameObject);
                        //if (ctrlRs != null)
                        //    wt.AddTransform(ctrlRs.transform);
                        //GameObject ctrlRe = Global.ldaControlX("d_wpnRE", L.gameObject);
                        //if (ctrlRe != null)
                        //    wt.AddTransform(ctrlRe.transform);
                        //左手
                        GameObject ctrlLs = NodeHelper.Find("d_wpnLS", L.gameObject);
                        if (ctrlLs != null)
                        {
                            wt.AddTransform(ctrlLs.transform);
                        }
                        GameObject ctrlLe = NodeHelper.Find("d_wpnLE", L.gameObject);
                        if (ctrlLe != null)
                        {
                            wt.AddTransform(ctrlLe.transform);
                        }

                        //每个武器只能有一个碰撞盒
                        BoxCollider box = L.GetComponentInChildren <BoxCollider>();
                        if (box != null)
                        {
                            box.enabled          = false;
                            box.gameObject.layer = ModelLayer ? LayerMask.NameToLayer("RenderModel") : LayerMask.NameToLayer("Weapon");
                            weaponDamage.Add(box);
                        }
                        else
                        {
                            Debug.LogError("新增武器上找不到碰撞盒[除了暗器火枪飞轮外都应该有碰撞盒]");
                        }
                        if (owner != null)
                        {
                            wt.Init(owner);
                            trail.Add(wt);
                        }
                        else
                        {
                            GameObject.Destroy(wt);
                            wt = null;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(weaponR))
                {
                    GameObject weaponPrefab = Resources.Load <GameObject>(weaponR);
                    if (weaponPrefab == null)
                    {
                        GMCFile fGmcR = Main.Ins.GMCLoader.Load(weaponR);
                        DesFile fDesR = Main.Ins.DesLoader.Load(weaponR);
                        if (fGmcR != null && fDesR != null)
                        {
                            GenerateWeaponModel(weaponR, fGmcR, fDesR, true, scale, weaponProperty.TextureR, ModelLayer);
                        }
                        else if (fGmcR == null && fDesR != null)
                        {
                            GMBFile fGmbR = Main.Ins.GMBLoader.Load(weaponProperty.WeaponR);
                            GenerateWeaponModel(weaponR, fGmbR, fDesR, true, scale, weaponProperty.TextureR, ModelLayer);
                        }
                    }
                    else
                    {
                        if (R != null)
                        {
                            DestroyImmediate(R);
                        }
                        GameObject objWeapon = GameObject.Instantiate(weaponPrefab);
                        objWeapon.layer = ModelLayer ? LayerMask.NameToLayer("RenderModel") : LayerMask.NameToLayer("Weapon");
                        R = objWeapon.transform;
                        R.SetParent(RP);
                        R.localPosition = Vector3.zero;
                        R.localRotation = new Quaternion(0, 1, 0, 0);
                        R.name          = weaponR;
                        R.localScale    = Vector3.one;

                        //武器挂点必须在缩放正确后才能到指定的位置
                        WeaponTrail wt = R.gameObject.AddComponent <WeaponTrail>();
                        //右手
                        GameObject ctrlRs = NodeHelper.Find("d_wpnRS", R.gameObject);
                        if (ctrlRs != null)
                        {
                            wt.AddTransform(ctrlRs.transform);
                        }
                        GameObject ctrlRe = NodeHelper.Find("d_wpnRE", R.gameObject);
                        if (ctrlRe != null)
                        {
                            wt.AddTransform(ctrlRe.transform);
                        }
                        BoxCollider box = R.GetComponentInChildren <BoxCollider>();
                        if (box != null)
                        {
                            box.enabled          = false;
                            box.gameObject.layer = ModelLayer ? LayerMask.NameToLayer("RenderModel") : LayerMask.NameToLayer("Weapon");
                            weaponDamage.Add(box);
                        }
                        else
                        {
                            Debug.LogError("新增武器上找不到碰撞盒[除了暗器火枪飞轮外都应该有碰撞盒]");
                        }

                        if (owner != null)
                        {
                            wt.Init(owner);
                            trail.Add(wt);
                        }
                        else
                        {
                            GameObject.Destroy(wt);
                        }
                    }
                }
            }
            Weapon = item;
        }
        else
        {
            Debug.LogError("if you want equip you must call unequip first if the weapon exist");
        }

        if (owner != null && owner.Stealth)
        {
            MeshRenderer[] mrl = LP.gameObject.GetComponentsInChildren <MeshRenderer>();
            for (int i = 0; i < mrl.Length; i++)
            {
                if (!mrl[i].enabled)
                {
                    continue;
                }
                for (int j = 0; j < mrl[i].materials.Length; j++)
                {
                    mrl[i].materials[j].SetFloat("_Alpha", 0.2f);
                }
            }

            MeshRenderer[] mrr = RP.gameObject.GetComponentsInChildren <MeshRenderer>();
            for (int i = 0; i < mrr.Length; i++)
            {
                if (!mrr[i].enabled)
                {
                    continue;
                }
                for (int j = 0; j < mrr[i].materials.Length; j++)
                {
                    mrr[i].materials[j].SetFloat("_Alpha", 0.2f);
                }
            }
        }
    }
    public void Load(string file)
    {
        string s = file;

        if (!string.IsNullOrEmpty(file))
        {
            //查看此物体属于什么,A:武器 B:道具 C:镖物
            if (ItemInfo == null)
            {
                for (int i = 0; i < Main.Ins.MenuResLoader.Info.Count; i++)
                {
                    if (Main.Ins.MenuResLoader.Info[i].model != "0" && 0 == string.Compare(Main.Ins.MenuResLoader.Info[i].model, s, true))
                    {
                        ApplyPrev(Main.Ins.MenuResLoader.Info[i]);
                        break;
                    }
                    string rh  = s.ToUpper();
                    string rh2 = Main.Ins.MenuResLoader.Info[i].model.ToUpper();
                    if (rh2.StartsWith(rh))
                    {
                        s = Main.Ins.MenuResLoader.Info[i].model;
                        ApplyPrev(Main.Ins.MenuResLoader.Info[i]);
                        break;
                    }
                }
                //不是一个Meteor.res里的物件
                if (ItemInfo == null)
                {
                    List <ItemDatas.ItemDatas> its = Main.Ins.DataMgr.GetDatasArray <ItemDatas.ItemDatas>();
                    for (int i = 0; i < its.Count; i++)
                    {
                        if (its[i].MainType == 1)
                        {
                            WeaponDatas.WeaponDatas weapon = U3D.GetWeaponProperty(its[i].UnitId);
                            if (weapon.WeaponR == s)
                            {
                                ItemInfoEx = its[i];
                                break;
                            }
                        }
                    }
                }
            }

            //证明此物品不是可拾取物品
            gameObject.layer      = (ItemInfo != null || ItemInfoEx != null) ?  LayerMask.NameToLayer("Trigger") : LayerMask.NameToLayer("Scene");
            root.gameObject.layer = gameObject.layer;
            //箱子椅子桌子酒坛都不允许为场景物品.
            WsGlobal.ShowMeteorObject(s, root);
            DesFile fIns = Main.Ins.DesLoader.Load(s);
            //把子物件的属性刷到一起.
            for (int i = 0; i < fIns.SceneItems.Count; i++)
            {
                LoadCustom(fIns.SceneItems[i].name, fIns.SceneItems[i].custom);
            }

            //雪人不能合并材质,不然没法动画
            if (Main.Ins.CombatData.GLevelItem.Scene != "Meteor_21")
            {
                if (name.StartsWith("D_Item") || name.StartsWith("D_RJug") || name.StartsWith("D_itRJug") || name.StartsWith("D_BBox") ||
                    name.StartsWith("D_BBBox") || name.StartsWith("D_Box"))
                {
                    if (root != null)
                    {
                        CombineChildren combine = root.gameObject.AddComponent <CombineChildren>();
                        combine.generateTriangleStrips = false;
                    }
                    else
                    {
                        CombineChildren combine = gameObject.AddComponent <CombineChildren>();
                        combine.generateTriangleStrips = false;
                    }
                }
            }

            FMCFile f = Main.Ins.FMCLoader.Load(s);
            if (f != null)
            {
                player = GetComponent <FMCPlayer>();
                if (player == null)
                {
                    player = gameObject.AddComponent <FMCPlayer>();
                }
                player.Init(s, f);
            }
            else
            {
                player = GetComponent <FMCPlayer>();
                if (player != null)
                {
                    DestroyObject(player);
                    player = null;
                }
            }
        }
    }
    public void OnPickUped(MeteorUnit unit)
    {
        //场景上的模型物件捡取
        if (unit.Dead)
        {
            return;
        }
        if (ItemInfo != null && ItemInfo.Type != 0 && root != null)
        {
            if (ItemInfo.IsWeapon())
            {
                //满武器,不能捡
                if (unit.Attr.Weapon != 0 && unit.Attr.Weapon2 != 0)
                {
                    return;
                }
                //相同武器,不能捡
                ItemDatas.ItemDatas     ib0 = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon);
                WeaponDatas.WeaponDatas wb0 = U3D.GetWeaponProperty(ib0.UnitId);
                if (wb0 != null && wb0.WeaponR == ItemInfo.model)
                {
                    return;
                }

                if (unit.Attr.Weapon2 != 0)
                {
                    ItemDatas.ItemDatas     ib1 = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon2);
                    WeaponDatas.WeaponDatas wb1 = U3D.GetWeaponProperty(ib1.UnitId);
                    if (wb1 != null && wb1.WeaponR == ItemInfo.model)
                    {
                        return;
                    }
                }

                //同类武器不能捡
                int weaponPickup       = Main.Ins.GameStateMgr.GetWeaponCode(ItemInfo.model);
                ItemDatas.ItemDatas wb = Main.Ins.GameStateMgr.FindItemByIdx(weaponPickup);
                if (wb == null)
                {
                    return;
                }

                ItemDatas.ItemDatas wbl = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon);
                if (wbl == null)
                {
                    return;
                }

                ItemDatas.ItemDatas wbr = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon2);
                if (wb.SubType == wbl.SubType)
                {
                    return;
                }

                if (wbr != null && wb.SubType == wbr.SubType)
                {
                    return;
                }
                //可以捡取
                unit.Attr.Weapon2 = weaponPickup;
                Main.Ins.SFXLoader.PlayEffect(672, unit.gameObject, true);
                refresh_tick = ItemInfo.first[1].flag[1];
                if (asDrop)
                {
                    GameObject.Destroy(gameObject);
                }
                else
                {
                    if (refresh_tick > 0)
                    {
                        Refresh = true;
                    }
                    GameObject.Destroy(root.gameObject);
                    root = null;
                }
            }
            else if (ItemInfo.IsItem())
            {
                //表明此为Buff,会叠加某个属性,且挂上一个持续的特效。
                unit.GetItem(ItemInfo);
                refresh_tick = ItemInfo.first[1].flag[1];
                if (refresh_tick > 0)
                {
                    Refresh = true;
                }
                GameObject.Destroy(root.gameObject);
                root = null;
            }
            else if (ItemInfo.IsFlag())
            {
                GameObject.Destroy(root.gameObject);
                root = null;
                if (ItemInfo.first[1].flag[1] != 0)
                {
                    Main.Ins.SFXLoader.PlayEffect(ItemInfo.first[1].flag[1], unit.gameObject, true);
                }
                U3D.InsertSystemMsg(unit.name + " 夺得镖物");
                unit.SetFlag(ItemInfo, ItemInfo.first[2].flag[1]);
            }

            if (OnPickUp != null)
            {
                OnPickUp.Invoke(Main.Ins.CombatData.GScript, null);
            }
        }
        else if (ItemInfoEx != null)
        {
            if (ItemInfoEx.MainType == 1)
            {
                string weaponModel         = "";
                WeaponDatas.WeaponDatas wp = U3D.GetWeaponProperty(ItemInfoEx.UnitId);
                if (wp != null)
                {
                    weaponModel = wp.WeaponR;
                }
                //满武器,不能捡
                if (unit.Attr.Weapon != 0 && unit.Attr.Weapon2 != 0)
                {
                    return;
                }
                //相同武器,不能捡
                ItemDatas.ItemDatas     ib0 = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon);
                WeaponDatas.WeaponDatas wb0 = U3D.GetWeaponProperty(ib0.UnitId);
                if (wb0 != null && wb0.WeaponR == weaponModel)
                {
                    return;
                }

                if (unit.Attr.Weapon2 != 0)
                {
                    ItemDatas.ItemDatas     ib1 = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon2);
                    WeaponDatas.WeaponDatas wb1 = U3D.GetWeaponProperty(ib1.UnitId);
                    if (wb1 != null && wb1.WeaponR == weaponModel)
                    {
                        return;
                    }
                }

                //同类武器不能捡
                int weaponPickup       = Main.Ins.GameStateMgr.GetWeaponCode(weaponModel);
                ItemDatas.ItemDatas wb = Main.Ins.GameStateMgr.FindItemByIdx(weaponPickup);
                if (wb == null)
                {
                    return;
                }

                ItemDatas.ItemDatas wbl = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon);
                if (wbl == null)
                {
                    return;
                }

                ItemDatas.ItemDatas wbr = Main.Ins.GameStateMgr.FindItemByIdx(unit.Attr.Weapon2);
                if (wb.SubType == wbl.SubType)
                {
                    return;
                }

                if (wbr != null && wb.SubType == wbr.SubType)
                {
                    return;
                }
                //可以捡取
                unit.Attr.Weapon2 = weaponPickup;
                Main.Ins.SFXLoader.PlayEffect(672, unit.gameObject, true);

                if (asDrop)
                {
                    GameObject.Destroy(gameObject);
                }
            }
        }
        else
        {
            if (OnTouch != null)
            {
                OnTouch.Invoke(Main.Ins.CombatData.GScript, new object[] { 0, unit.InstanceId });
            }
            else if (OnPickUp != null)
            {
                OnPickUp.Invoke(Main.Ins.CombatData.GScript, null);
            }
        }
    }