public void Attach(WeaponPartLocation partLocation, object partObj, object weaponObj)
        {
            var partGo   = partObj as GameObject;
            var weaponGo = weaponObj as GameObject;

#if !UnitTest
            if (Logger.IsDebugEnabled)
            {
                Logger.DebugFormat("attach {0} to {1} in {2}", partGo.name, weaponGo.name, partLocation);
            }
#endif

            if (partLocation != WeaponPartLocation.EndOfTheWorld)
            {
                _boneMount.MountWeaponAttachment(partGo, weaponGo, partLocation);
            }
            else
            {
#if !UnitTest
                Logger.ErrorFormat("Location is illegal with item location {0}", partLocation);
#endif
            }

            ShowWeapon(weaponGo);
        }
예제 #2
0
        public void MountWeaponAttachment(GameObject attachment, GameObject weapon, WeaponPartLocation location)
        {
            if (attachment != null && weapon != null)
            {
                if (weapon.GetComponent <TransformCache>() == null)
                {
                    BoneTool.CacheTransform(weapon);
                }
                if (attachment.GetComponent <TransformCache>() == null)
                {
                    BoneTool.CacheTransform(attachment);
                }

                if (_attachmentLocator.ContainsKey(location))
                {
                    var anchor = FindChildBoneFromCache(attachment, BoneName.AttachmentLocator, false);
                    var target = FindChildBoneFromCache(weapon, _attachmentLocator[location], false);
                    FixedObj2Bones(attachment, anchor, target);
                }
                else
                {
                    _logger.WarnFormat("Wrong Attachment Location: {0}", location);
                }
            }
        }
예제 #3
0
        public static void RefreshWeaponPartModels(ICharacterAppearance appearance, int weaponId,
                                                   WeaponPartsStruct oldParts, WeaponPartsStruct parts, EWeaponSlotType slot)
        {
            var weaponConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponId);

            if (null == weaponConfig)
            {
                return;
            }
            if (!((EWeaponType_Config)weaponConfig.Type).MayHasPart())
            {
                Logger.WarnFormat("weapon type {0} has no attachment by default ", weaponConfig.Type);
                return;
            }

            var pos = slot.ToWeaponInPackage();
            //  var oldArr = oldParts.ToAniLocation();
            var newArr = parts.ToAniLocation();

            for (WeaponPartLocation tmp = WeaponPartLocation.None + 1; tmp < WeaponPartLocation.EndOfTheWorld; tmp++)
            {
                if (newArr[(int)tmp] > 0)
                {
                    appearance.MountAttachment(pos, tmp, newArr[(int)tmp]);
                }
                else
                {
                    appearance.UnmountAttachment(pos, tmp);
                }
            }
        }
예제 #4
0
 protected AttachmentParamData(bool isFirstPersonClass, WeaponPartLocation attachmentType, WeaponInPackage weaponType)
 {
     _isFirstPersonClass = isFirstPersonClass;
     AttachmentType      = attachmentType;
     _weaponType         = weaponType;
     Init();
 }
예제 #5
0
 public void UnmountAttachment(WeaponInPackage pos, WeaponPartLocation location)
 {
     if ((int)pos <= (int)WeaponInPackage.EndOfTheWorld &&
         (int)location <= (int)WeaponPartLocation.EndOfTheWorld)
     {
         _weaponController.UnmountAttachment(pos, location);
     }
 }
예제 #6
0
 public void MountAttachment(WeaponInPackage pos, WeaponPartLocation location, int id)
 {
     if ((int)pos <= (int)WeaponInPackage.EndOfTheWorld &&
         (int)location <= (int)WeaponPartLocation.EndOfTheWorld)
     {
         WeaponControllerBaseImpl.MountAttachment(pos, location, id);
     }
 }
 public void UnmountAttachment(WeaponInPackage pos, WeaponPartLocation location)
 {
     if ((int)pos <= (int)WeaponInPackage.EndOfTheWorld &&
         (int)location <= (int)WeaponPartLocation.EndOfTheWorld)
     {
         WeaponDataBaseImpl.UnmountAttachment(pos, location);
     }
 }
예제 #8
0
 public void SetChangeAttachment(Action <WeaponInPackage, WeaponPartLocation, int> action,
                                 WeaponInPackage pos,
                                 WeaponPartLocation location,
                                 int id)
 {
     _changeWeaponAttachment = action;
     _weaponPosition         = pos;
     _attachmentLocation     = location;
     _attachment             = id;
 }
예제 #9
0
        public void LoadPart(AssetInfo asset, WeaponPartLocation location)
        {
#if !UnitTest
            if (Logger.IsDebugEnabled)
            {
                Logger.DebugFormat("LoadPart {0} in {1}", asset, location);
            }
#endif
            _partAssetDic[location] = asset;
            _weaponModelLoader.LoadAsset(asset);
        }
예제 #10
0
 private void OnPartLoaded(T go, WeaponPartLocation partType)
 {
     _partGoDic[partType] = go;
     if (null != _weaponGo)
     {
         Attach(partType, go, _weaponGo);
     }
     else
     {
         _waitPartGoDic[partType] = go;
     }
 }
        private void OnPartLoaded(T go, WeaponPartLocation partType)
        {
            BoneTool.CacheTransform(go as GameObject);
            _partGoDic[partType] = go;
            if (null != _weaponGo)
            {
                Attach(partType, go, _weaponGo);
            }
            else
            {
                _waitPartGoDic[partType] = go;
            }

            if (partType.Equals(WeaponPartLocation.Scope))
            {
                _weaponModelAssemblyController.RefreshRemovableAttachment(_weaponGo as GameObject, true);
            }
        }
예제 #12
0
        private void UpdateAttachmentType(WeaponInPackage pos, WeaponPartLocation location, int type)
        {
            if (WeaponInPackage.PrimaryWeaponOne != pos &&
                WeaponInPackage.PrimaryWeaponTwo != pos &&
                WeaponInPackage.SideArm != pos)
            {
                return;
            }

            AssertUtility.Assert(
                (int)WeaponPartLocation.EndOfTheWorld * 3 +
                (int)WeaponInPackage.EndOfTheWorld - 1 == _latestWeaponValue.Length - 1,
                "Add New WeaponPartLocation Or WeaponInPackage Enum");

            var index = GetIndexFromPos(pos) + (int)location + 1;

            if (index < 0 || index >= _latestWeaponValue.Length)
            {
                return;
            }
            _latestWeaponValue[index] = type;
        }
예제 #13
0
 protected void SetAttachmentIdByType(WeaponInPackage weaponType, WeaponPartLocation attachmentType, int attachmentId)
 {
     _weaponDataController.SetAttachmentIdByType(weaponType, attachmentType, attachmentId);
 }
예제 #14
0
 public void SetAttachmentIdByType(WeaponInPackage weaponType, WeaponPartLocation attachmentType, int id)
 {
     _attachmentIds[(int)weaponType, (int)attachmentType] = id;
 }
예제 #15
0
 private void UnmountAttachmentImpl(WeaponInPackage pos, WeaponPartLocation location, int type)
 {
     UpdateAttachmentType(pos, location, type);
 }
예제 #16
0
 public int GetAttachmentId(WeaponPartLocation attachmentType, WeaponInPackage weaponType)
 {
     return(_weapons[(int)weaponType].GetAttachmentId(attachmentType));
 }
예제 #17
0
 private void MountAttachmentImpl(WeaponInPackage pos, WeaponPartLocation location, int attachmentId)
 {
     UpdateAttachmentType(pos, location, attachmentId);
 }
예제 #18
0
 public int GetAttachmentId(WeaponPartLocation type)
 {
     return(Attachment.GetAttachmentIdByType(type));
 }
예제 #19
0
 public GameObject GetAttachmentObjByType(WeaponPartLocation type)
 {
     return(_attachments[(int)type].GetAttachmentObj());
 }
예제 #20
0
 public int GetAttachmentIdByType(WeaponPartLocation type)
 {
     return(_attachments[(int)type].GetAttachmentId());
 }
예제 #21
0
 public void Attach(WeaponPartLocation partLocation, T partGo, T weaponGo)
 {
     _weaponModelAssemblyController.Attach(partLocation, partGo, weaponGo);
 }
예제 #22
0
        public void MountAttachment(WeaponInPackage pos, WeaponPartLocation location, int id)
        {
            var cmd = GetAvailableCommand();

            cmd.SetChangeAttachment(MountAttachmentImpl, pos, location, id);
        }
예제 #23
0
 public AttachmentParam(bool isFirstPersonClass, WeaponPartLocation attachmentType, WeaponInPackage weaponType) :
     base(isFirstPersonClass, attachmentType, weaponType)
 {
     WeaponLoadAssetHandler = new WeaponLoadAssetHandler(AttachmentAssetLoadSuccess);
 }
예제 #24
0
        public void UnmountAttachment(WeaponInPackage pos, WeaponPartLocation location)
        {
            var cmd = GetAvailableCommand();

            cmd.SetChangeAttachment(UnmountAttachmentImpl, pos, location, UniversalConsts.InvalidIntId);
        }