public static void SetWeaponCompAttachment(WeaponComponent weaponComp, EWeaponPartType type, int id)
        {
            switch (type)
            {
            case EWeaponPartType.LowerRail:
                weaponComp.LowerRail = id;
                break;

            case EWeaponPartType.UpperRail:
                weaponComp.UpperRail = id;
                break;

            case EWeaponPartType.Muzzle:
                weaponComp.Muzzle = id;
                break;

            case EWeaponPartType.Magazine:
                weaponComp.Magazine = id;
                break;

            case EWeaponPartType.Stock:
                weaponComp.Stock = id;
                break;
            }
        }
        public static WeaponPartLocation GetLocationByPartType(EWeaponPartType partType)
        {
            switch (partType)
            {
            case EWeaponPartType.Magazine:
                return(WeaponPartLocation.Magazine);

            case EWeaponPartType.LowerRail:
                return(WeaponPartLocation.LowRail);

            case EWeaponPartType.Muzzle:
                return(WeaponPartLocation.Muzzle);

            case EWeaponPartType.SideRail:
                return(WeaponPartLocation.EndOfTheWorld);

            case EWeaponPartType.Stock:
                return(WeaponPartLocation.Buttstock);

            case EWeaponPartType.UpperRail:
                return(WeaponPartLocation.Scope);

            default:
                return(WeaponPartLocation.EndOfTheWorld);
            }
        }
        public static WeaponInfo SetWeaponInfoAttachment(WeaponInfo weaponInfo, EWeaponPartType type, int id)
        {
            switch (type)
            {
            case EWeaponPartType.LowerRail:
                weaponInfo.LowerRail = id;
                break;

            case EWeaponPartType.UpperRail:
                weaponInfo.UpperRail = id;
                break;

            case EWeaponPartType.Muzzle:
                weaponInfo.Muzzle = id;
                break;

            case EWeaponPartType.Magazine:
                weaponInfo.Magazine = id;
                break;

            case EWeaponPartType.Stock:
                weaponInfo.Stock = id;
                break;
            }

            return(weaponInfo);
        }
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name                          ="slot"></param>
        /// <param name                          ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.BaseComponent.CreateParts();
            var parts = WeaponPartUtil.ModifyPartItem(
                agent.BaseComponent.CreateParts(), partType,
                UniversalConsts.InvalidIntId);

            agent.BaseComponent.ApplyParts(parts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, UniversalConsts.InvalidIntId);

            WeaponPartUtil.CombineDefaultParts(ref newParts, agent.BaseComponent.ConfigId);
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
        }
Beispiel #5
0
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType part)
        {
            if (slot == EWeaponSlotType.None)
            {
                return;
            }
            var weaponComp = GetWeaponComponentBySlot(slot);

            if (null == weaponComp)
            {
                Logger.ErrorFormat("error : weaponcompent in slot {0} is null", slot);
                return;
            }
            var weapon    = GetWeaponComponentBySlot(slot);
            var lastParts = weapon.GetParts();

            if (null != weaponComp)
            {
                var parts = WeaponPartsUtil.ModifyParts(
                    weaponComp.GetParts(),
                    part,
                    UniversalConsts.InvalidIntId);
                weaponComp.ApplyParts(parts);
            }

            if (slot == CurWeaponSlot)
            {
                RefreshCurrentWeaponAttachmentLogic();
            }

            var newParts = WeaponPartsUtil.ModifyParts(lastParts, part, UniversalConsts.InvalidIntId);

            newParts = newParts.ApplyDefaultParts(weapon.Id);
            RefreshWeaponPartsModel(weapon.Id, slot, lastParts, newParts);
        }
Beispiel #6
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name ="slot"></param>
        /// <param name ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, 0);

            agent.BaseComponent.ApplyParts(newParts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
            DebugUtil.MyLog("Delete Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
        }
Beispiel #7
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="part"></param>
        public void DeleteSlotWeaponPart(EWeaponSlotType slot, EWeaponPartType part)
        {
            if (slot == EWeaponSlotType.None)
            {
                return;
            }
            WeaponEntity entity = GetWeaponAgent(slot).Entity;

            if (entity == null)
            {
                throw new ExWeaponNotFoundException("{0} slot weapon not found", slot);
                return;
            }

            WeaponPartsStruct lastParts = entity.weaponBasicData.GetParts();
            var parts = WeaponPartsUtil.ModifyParts(
                entity.weaponBasicData.GetParts(), part,
                UniversalConsts.InvalidIntId);

            entity.weaponBasicData.ApplyParts(parts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            var newParts = WeaponPartsUtil.ModifyParts(lastParts, part, UniversalConsts.InvalidIntId);

            newParts = newParts.ApplyDefaultParts(entity.weaponBasicData.ConfigId);
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = entity.ToWeaponScan();
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
        }
Beispiel #8
0
        /// <summary>
        /// 根据PartType修改配件信息
        /// </summary>
        /// <param name="attach"></param>
        /// <param name="type"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static WeaponPartsStruct ModifyPartItem(WeaponPartsStruct attach, EWeaponPartType type, int id)
        {
            switch (type)
            {
            case EWeaponPartType.LowerRail:
                attach.LowerRail = id;
                break;

            case EWeaponPartType.UpperRail:
                attach.UpperRail = id;
                break;

            case EWeaponPartType.Muzzle:
                attach.Muzzle = id;
                break;

            case EWeaponPartType.Magazine:
                attach.Magazine = id;
                break;

            case EWeaponPartType.Stock:
                attach.Stock = id;
                break;
            }

            return(attach);
        }
Beispiel #9
0
        public string GetTypeStrById(int id)
        {
            string          result = "";
            EWeaponPartType type   = EWeaponPartType.None;
            var             cfg    = GetConfigById(id);

            if (null != cfg)
            {
                type = (EWeaponPartType)cfg.Type;
                switch (type)
                {
                case EWeaponPartType.Magazine:
                    result = "弹匣";
                    break;

                case EWeaponPartType.Muzzle:
                    result = "枪口";
                    break;

                case EWeaponPartType.UpperRail:
                    result = "导轨";
                    break;

                case EWeaponPartType.SideRail:
                    result = "侧导轨";
                    break;

                case EWeaponPartType.LowerRail:
                    result = "握把";
                    break;

                case EWeaponPartType.Stock:
                    result = "枪托";
                    break;

                case EWeaponPartType.Bore:
                    result = "枪膛";
                    break;

                case EWeaponPartType.Feed:
                    result = "供弹";
                    break;

                case EWeaponPartType.Trigger:
                    result = "击发";
                    break;

                case EWeaponPartType.Interlock:
                    result = "闭锁";
                    break;

                case EWeaponPartType.Brake:
                    result = "制退";
                    break;
                }
            }

            return(result);
        }
Beispiel #10
0
        public static int GetWeaponPart(EWeaponPartType partType)
        {
            for (int i = 1; i <= 5; i++)
            {
                if (partTypes[i] == partType)
                {
                    return(i);
                }
            }

            return(0);
        }
Beispiel #11
0
        /// <summary>
        /// 根据PartType修改配件信息
        /// </summary>
        /// <param name="attach"></param>
        /// <param name="type"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static WeaponPartsStruct ModifyPartItem(WeaponPartsStruct attach, EWeaponPartType type, int id)
        {
            switch (type)
            {
            case EWeaponPartType.LowerRail:
                attach.LowerRail = id;
                break;

            case EWeaponPartType.UpperRail:
                attach.UpperRail = id;
                break;

            case EWeaponPartType.Muzzle:
                attach.Muzzle = id;
                break;

            case EWeaponPartType.Magazine:
                attach.Magazine = id;
                break;

            case EWeaponPartType.Stock:
                attach.Stock = id;
                break;

            case EWeaponPartType.SideRail:
                attach.SideRail = id;
                break;

            case EWeaponPartType.Bore:
                attach.Bore = id;
                break;

            case EWeaponPartType.Feed:
                attach.Feed = id;
                break;

            case EWeaponPartType.Trigger:
                attach.Trigger = id;
                break;

            case EWeaponPartType.Interlock:
                attach.Interlock = id;
                break;

            case EWeaponPartType.Brake:
                attach.Brake = id;
                break;
            }

            return(attach);
        }
Beispiel #12
0
        private void UpdateWeaponPart(int index, EWeaponPartType type, int cat, int id, bool isShow = true)
        {
            switch (type)
            {
            case EWeaponPartType.Muzzle: UpdateMuzzle(index, cat, id, isShow); break;

            case EWeaponPartType.LowerRail: UpdateLowerRail(index, cat, id, isShow); break;

            case EWeaponPartType.Stock: UpdateStock(index, cat, id, isShow); break;

            case EWeaponPartType.UpperRail: UpdateUpperRail(index, cat, id, isShow); break;

            case EWeaponPartType.Magazine: UpdateMagazine(index, cat, id, isShow); break;
            }
        }
        public int GetIdByWeaponPartType(EWeaponPartType weaponPartType)
        {
            switch (weaponPartType)
            {
            case EWeaponPartType.LowerRail:
                return(_playerWeaponData.LowerRail);

            case EWeaponPartType.UpperRail:
                return(_playerWeaponData.UpperRail);

            case EWeaponPartType.Stock:
                return(_playerWeaponData.Stock);

            case EWeaponPartType.Magazine:
                return(_playerWeaponData.Magazine);

            case EWeaponPartType.Muzzle:
                return(_playerWeaponData.Muzzle);
            }
            return(0);
        }
Beispiel #14
0
        public AssetInfo GetWeaponPartInfoByWeaponPartType(EWeaponPartType weaponPartType)
        {
            switch (weaponPartType)
            {
            case EWeaponPartType.LowerRail:
                return(_lowerAsset);

            case EWeaponPartType.UpperRail:
                return(_upperAsset);

            case EWeaponPartType.Stock:
                return(_stockAsset);

            case EWeaponPartType.Magazine:
                return(_magazineAsset);

            case EWeaponPartType.Muzzle:
                return(_muzzleAsset);
            }
            return(new AssetInfo());
        }
Beispiel #15
0
        internal static string GetWeaponPartTypeName(EWeaponPartType type)
        {
            if (WeaponPartTypeName == null)
            {
                WeaponPartTypeName = new Dictionary <EWeaponPartType, string>(CommonIntEnumEqualityComparer <EWeaponPartType> .Instance);
                WeaponPartTypeName[EWeaponPartType.None]      = ScriptLocalization.hall.word437;
                WeaponPartTypeName[EWeaponPartType.Magazine]  = ScriptLocalization.hall.word453;
                WeaponPartTypeName[EWeaponPartType.Muzzle]    = ScriptLocalization.hall.word454;
                WeaponPartTypeName[EWeaponPartType.UpperRail] = ScriptLocalization.hall.word455;
                WeaponPartTypeName[EWeaponPartType.SideRail]  = ScriptLocalization.hall.word456;
                WeaponPartTypeName[EWeaponPartType.LowerRail] = ScriptLocalization.hall.word457;
                WeaponPartTypeName[EWeaponPartType.Stock]     = ScriptLocalization.hall.word458;
                WeaponPartTypeName[EWeaponPartType.Bore]      = "枪膛";
                WeaponPartTypeName[EWeaponPartType.Feed]      = "供弹";
                WeaponPartTypeName[EWeaponPartType.Trigger]   = "击发";
                WeaponPartTypeName[EWeaponPartType.Interlock] = "闭锁";
                WeaponPartTypeName[EWeaponPartType.Brake]     = "制退";
            }

            var res = string.Empty;

            WeaponPartTypeName.TryGetValue(type, out res);
            return(res);
        }
Beispiel #16
0
        public int GetWeaponPartIdBySlotIndexAndWeaponPartType(int index, EWeaponPartType type)
        {
            var list = _contexts.ui.uI.WeaponPartList;

            return(list[index, (int)type]);
        }
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name ="slot"></param>
        /// <param name ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            var defaultParts            = agent.WeaponConfigAssy.DefaultParts;
            int newPart = 0; //移除配件后装备默认配件

            switch (partType)
            {
            case EWeaponPartType.LowerRail:
                newPart = defaultParts.LowerRail;
                break;

            case EWeaponPartType.UpperRail:
                newPart = defaultParts.UpperRail;
                break;

            case EWeaponPartType.Muzzle:
                newPart = defaultParts.Muzzle;
                break;

            case EWeaponPartType.Magazine:
                newPart = defaultParts.Magazine;
                break;

            case EWeaponPartType.Stock:
                newPart = defaultParts.Stock;
                break;

            case EWeaponPartType.SideRail:
                newPart = defaultParts.SideRail;
                break;

            case EWeaponPartType.Bore:
                newPart = defaultParts.Bore;
                break;

            case EWeaponPartType.Interlock:
                newPart = defaultParts.Interlock;
                break;

            case EWeaponPartType.Feed:
                newPart = defaultParts.Feed;
                break;

            case EWeaponPartType.Brake:
                newPart = defaultParts.Brake;
                break;

            case EWeaponPartType.Trigger:
                newPart = defaultParts.Trigger;
                break;

            default:
                break;
            }
            if (newPart <= 0)
            {
                newPart = 0;
            }
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, newPart);

            agent.BaseComponent.ApplyParts(newParts);
            if (slot == HeldSlotType)
            {
                if (processHelper.FilterRefreshWeapon())
                {
                    ApperanceRefreshABreath(HeldWeaponAgent.BreathFactor);
                }
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshWeaponModelAndParts(refreshData);
            DebugUtil.MyLog("Delete Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
        }