예제 #1
0
    /// <summary>
    /// 从背包中移除指定的model
    /// </summary>
    /// <param name="model"></param>
    public void RemoveBagProp(PropBaseModel model, int _num = 1)
    {
        if (model == null || !dic_bagProp.ContainsValue(model))
        {
            return;
        }
        bool isDiscard = true;

        switch (model.prop.type)
        {
        case PropType.bomb:
            isDiscard = RemoveAddedProp(bombs, _num);
            break;

        case PropType.pistol:
        case PropType.rifle:
            break;

        case PropType.bullet:
            isDiscard = RemoveAddedProp(bulletList, _num);
            break;

        case PropType.other:
            break;
        }
        if (isDiscard)
        {
            dic_bagProp.Remove(model.prop.propID);
            model.Discard();
        }
        aSongUI_Controller.Instance.RefreshPlayerData();
    }
예제 #2
0
    /// <summary>
    /// 背包list中的装备配件功能
    /// </summary>
    /// <param name="_prop"></param>
    void PutOnParts(aSong_PlayerData.Prop _prop)
    {
        aSongUI_BackpackWeapon curentBackpackWeapon = GetCurrent_aSongUI_BackpackWeapon();

        if (!curentBackpackWeapon)
        {
            return;
        }
        //当前没拿武器
        if (!curentBackpackWeapon.CanPartsOn())
        {
            curentBackpackWeapon.Reset();
            return;
        }
        //先从数据中背包List删除
        //再将道具引用放到aSongUI_BackpackWeapon对应的槽中
        //aSongUI_Contact.m_instance

        PropBaseModel _model = aSongUI_Controller.Instance.playerData.GetBagProp(_prop.propID);

        Debug.Log("装配件_model = " + _model.prop.name);
        aSongUI_Controller.Instance.RemovePropFromBag(_model);
        _model = curentBackpackWeapon.PutOnParts(_model);
        if (_model)
        {
            Debug.Log("卸下来的道具 = " + _model.prop.name);
            aSongUI_Controller.Instance.AddPropToBag(_model);
        }
        HideBtnItem();
    }
예제 #3
0
 /// <summary>
 /// 有数量叠加的道具加入背包
 /// </summary>
 /// <param name="model"></param>
 /// <param name="list"></param>
 /// <returns></returns>
 bool AddPropToBackpack(PropBaseModel model, List <PropBaseModel> list)
 {
     if (list.Count >= 1)
     {
         PropBaseModel lastModel = list[list.Count - 1];
         lastModel.prop.num += model.prop.num;
         if (lastModel.prop.num > model.prop.maxNum)
         {
             lastModel.prop.num = model.prop.maxNum;
             list.Add(model);
             model.prop.num = lastModel.prop.num - model.prop.maxNum;
             return(true);
         }
         else
         {
             model.Discard();
             model.gameObject.SetActive(false);
             //没有被加入背包的model,应该被缓存池回收
         }
     }
     else
     {
         list.Add(model);
         return(true);
     }
     return(false);
 }
예제 #4
0
    /// <summary>
    /// 丢掉背包里的
    /// </summary>
    /// <param name="_propID"></param>
    public void Discard(int _propID, int _num = 1)
    {
        PropBaseModel model = playerData.dic_bagProp[_propID];

        RemovePropFromBag(model, _num);
        //model.Discard();
    }
예제 #5
0
 /// <summary>
 /// 移除指定的model
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool RemoveListProp(PropBaseModel model)
 {
     if (model == null || !dic_listProp.ContainsValue(model))
     {
         return(false);
     }
     dic_listProp.Remove(model.prop.propID);
     return(true);
 }
예제 #6
0
    //在武器范围内,添加需要拾取的武器到List中并刷新
    public void AddPropToList(PropBaseModel _model)
    {
        if (!playerData.AddListProp(_model))
        {
            return;
        }

        RefreshPropList();
    }
예제 #7
0
 /// <summary>
 /// 将指定的model加入到list中
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddListProp(PropBaseModel model)
 {
     if (model == null || dic_listProp.ContainsValue(model))
     {
         return(false);
     }
     dic_listProp.Add(model.prop.propID, model);
     return(true);
 }
예제 #8
0
 /// <summary>
 /// 按顺序放入
 /// </summary>
 /// <param name="model"></param>
 void PutWeaponIn(PropBaseModel model)
 {
     for (int i = 0; i < guns.Count; i++)
     {
         if (guns[i] == null)
         {
             guns[i] = model;
             break;
         }
     }
 }
 /// <summary>
 /// 将指定道具放入背包.(若放入的是当前拿取的道具,则停止动画)
 /// </summary>
 /// <param name="model"></param>
 public void PutPropInBackpack(PropBaseModel model)
 {
     if (model == null)
     {
         return;
     }
     if (currentProp == model)
     {
         currentProp = null;
         StopGrabAnimation();
     }
     PutPropInBag(model);
     model.PickupBy(gameObject);
 }
예제 #10
0
    public void OnTriggerEnter(Collider c)
    {
        PropBaseModel model = c.GetComponentInParent <PropBaseModel>();

        if (model == null)
        {
            return;
        }
        if (!dic_propModel.ContainsKey(model.prop.propID))
        {
            dic_propModel.Add(model.prop.propID, model);
        }
        aSongUI_Controller.Instance.AddPropToList(model);
    }
예제 #11
0
    public void OnTriggerExit(Collider c)
    {
        PropBaseModel model = c.GetComponentInParent <PropBaseModel>();

        if (model == null)
        {
            return;
        }
        if (dic_propModel.ContainsKey(model.prop.propID))
        {
            dic_propModel.Remove(model.prop.propID);
        }
        aSongUI_Controller.Instance.RemovePropFromList(model);
    }
예제 #12
0
 public void RemovePropFromList(PropBaseModel _model)
 {
     if (!playerData.RemoveListProp(_model))
     {
         return;
     }
     if (playerData.dic_listProp.Count <= 0)
     {
         TTUIPage.ClosePage <aSong_UIPropList>();
     }
     else
     {
         RefreshPropList();
     }
 }
    void StartGrabAnimation(PropBaseModel model)
    {
        InteractionObject _obj = model.mInteractionObject;

        interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, _obj, false);
        interactionSystem.StartInteraction(FullBodyBipedEffector.LeftHand, _obj, false);
        if (model.prop.name == PropName.M416)
        {
            animator.SetLayerWeight(1, 1);
        }
        else
        {
            animator.SetLayerWeight(1, 0);
        }
    }
예제 #14
0
    /// <summary>
    /// 获取指定id的model
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public PropBaseModel GetBagProp(int id)
    {
        if (!PropInBag(id))
        {
            return(null);
        }
        PropBaseModel model = null;

        if (dic_bagProp.ContainsKey(id))
        {
            model = dic_bagProp[id];
        }
        else
        {
            model = GetWeaponFromBackpack(id);
        }
        return(model);
    }
예제 #15
0
 public void PutOnWeapon(PropBaseModel _model)
 {
     if (!_model)
     {
         //卸下武器,清空配件
         Reset();
         return;
     }
     if ((mModels[0] && _model != mModels[0]))
     {
         //Debug.Log("aSongUI_BackpackWeapon::PutOnWeapon  换武器了,清空配件");
         Reset();
     }
     mModels[0] = _model;
     //清空凹槽,刷新重新显示
     nameText.text = mModels[0].prop.name.ToString();
     Refresh();
     //根据prop类型,显示对应需求的配件(另外写一个不同武器对应的配件需求的文档,便于管理,不要杂糅在一个文档里)
 }
예제 #16
0
    //道具放入背包.有丢掉判断
    public void AddBagProp(PropBaseModel model)
    {
        if (model == null || dic_bagProp.ContainsValue(model))
        {
            Debug.LogError("aSong_PlayerData::AddBagProp 天哪,为神马加入不进来 model = " + model.prop.name);
            return;
        }
        bool b_addToBackpack = true;

        switch (model.prop.type)
        {
        case PropType.bomb:
            b_addToBackpack = AddPropToBackpack(model, bombs);
            break;

        case PropType.pistol:
        case PropType.rifle:
            PutWeaponInBackpack(model);
            b_addToBackpack = false;
            if (currentModel == null)
            {
                currentModel = model;
            }
            break;

        case PropType.bullet:
            b_addToBackpack = AddPropToBackpack(model, bulletList);
            break;

        case PropType.other:

            break;
        }

        if (b_addToBackpack)
        {
            dic_bagProp.Add(model.prop.propID, model);
        }
        //只要有加入背包的举动,就必须更新背包
        aSongUI_Controller.Instance.RefreshPlayerData();

        return;
    }
예제 #17
0
 /// <summary>
 /// 移除指定类型的prop从指定的list中
 /// </summary>
 /// <param name="list">道具list</param>
 /// <param name="_num">丢掉的数量</param>
 /// <returns>是否可以丢完</returns>
 bool RemoveAddedProp(List <PropBaseModel> list, int _num)
 {
     if (_num <= 0)
     {
         return(false);
     }
     if (list.Count >= 1)
     {
         PropBaseModel lastModel = list[list.Count - 1];
         if (lastModel.prop.num > _num)
         {
             lastModel.prop.num -= _num;
             return(false);
         }
         else
         {
             //lastModel.prop.num = 0;
             list.Remove(lastModel);
             return(true);
         }
     }
     return(false);
 }
예제 #18
0
    /// <summary>
    /// 装上道具,返回卸下来的
    /// </summary>
    /// <param name="_model"></param>
    /// <returns></returns>
    public PropBaseModel PutOnParts(PropBaseModel _model)
    {
        Debug.Log("配件name = " + _model.prop.name);
        PropBaseModel tmp = null;

        switch (_model.prop.type)
        {
        case PropType.telescope:
            tmp        = mModels[1];
            mModels[1] = _model;
            break;

        case PropType.muzzle:
            tmp        = mModels[2];
            mModels[2] = _model;
            break;

        case PropType.gunHandle:
            tmp        = mModels[3];
            mModels[3] = _model;
            break;

        case PropType.cartridgeClip:
            tmp        = mModels[4];
            mModels[4] = _model;
            break;

        case PropType.gunstock:
            tmp        = mModels[5];
            mModels[5] = _model;
            break;
        }
        Refresh();

        return(tmp);
    }
예제 #19
0
    /// <summary>
    /// 将武器放入背包的检查逻辑
    /// </summary>
    /// <param name="model"></param>
    void PutWeaponInBackpack(PropBaseModel model)
    {
        if (currentModel)
        {
            Debug.Log("current = " + currentModel.name);
        }
        if (model)
        {
            Debug.Log("model = " + model.name);
        }

        int count_rifle  = 0;
        int index_pistol = -1;

        for (int i = 0; i < guns.Count; i++)
        {
            if (guns[i] == null)
            {
                continue;
            }
            if (guns[i].prop.type == PropType.rifle)
            {
                count_rifle++;
            }
            if (guns[i].prop.type == PropType.pistol)
            {
                index_pistol = i;
            }
        }

        if (model.prop.type == PropType.pistol)
        {
            //已经有手枪了
            if (index_pistol >= 0)
            {
                //RemoveBagProp(guns[index_pistol].prop.propID);
                guns[index_pistol].Discard();
                guns[index_pistol] = model;
                if (currentModel != null && currentModel.prop.type == model.prop.type)
                {
                    //手上拿的也是枪
                    currentModel = model;
                }
            }
            else //没有手枪,直接按顺序放入背包
            {
                PutWeaponIn(model);
            }
        }
        if (model.prop.type == PropType.rifle)
        {
            //有手枪,然后背包里还有一把步枪.那么手枪要挪到第三格去
            if (index_pistol >= 0 && count_rifle >= 1 && index_pistol != 2)
            {
                guns[2]            = guns[index_pistol];
                guns[index_pistol] = model;
            }
            if (count_rifle == 2)
            {
                //枪满了,手上拿的也刚好是步枪,丢掉手上的,拾取地上的
                if (currentModel != null && currentModel.prop.type == PropType.rifle)
                {
                    //手上拿的是步枪,移除手上的
                    //RemoveBagProp(currentModel.prop.propID);
                    currentModel.Discard();
                    for (int i = 0; i < guns.Count; i++)
                    {
                        if (guns[i] == currentModel)
                        {
                            guns[i] = model;
                        }
                    }
                    currentModel = model;
                }
                else
                {
                    //手上拿的不是步枪
                    //RemoveBagProp(guns[0].prop.propID);
                    guns[0].Discard();
                    guns[0] = model;
                }
            }
            else
            {
                //枪格子没满的时候,不用管手上拿的是啥,都直接放入背包
                PutWeaponIn(model);
            }
        }
    }
예제 #20
0
 public void AddPropToBag(PropBaseModel _model)
 {
     playerData.AddBagProp(_model);
 }
예제 #21
0
 public void RemovePropFromBag(PropBaseModel _model, int _num = 1)
 {
     playerData.RemoveBagProp(_model, _num);
 }
 void PutPropInBag(PropBaseModel prop)
 {
     prop.transform.parent           = weaponPoint[0];
     prop.transform.localPosition    = Vector3.zero;
     prop.transform.localEulerAngles = Vector3.zero;
 }
 /// <summary>
 /// 抓取指定道具到手上
 /// </summary>
 /// <param name="model"></param>
 public void PickupProp(PropBaseModel model)
 {
     currentProp = model;
     model.PickupBy(gameObject);
     StartGrabAnimation(model);
 }