コード例 #1
0
        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
            private void AssembleWeapon(SceneObjectEntity entity)
            {
                var weaponGo = entity.multiUnityObject.FirstAsset;

                if (entity.hasWeaponAttachment)
                {
                    var dic = entity.weaponAttachment.AttachmentDic;
                    foreach (var pair in dic)
                    {
                        var attachGo = entity.multiUnityObject.LoadedAssets[pair.Key];
                        var location = WeaponPartLocation.EndOfTheWorld;
                        location = WeaponTypeConvertUtil.GetLocationByPartType((EWeaponPartType)pair.Value);
                        if (location != WeaponPartLocation.EndOfTheWorld)
                        {
                            _boneMount.MountWeaponAttachment(attachGo, weaponGo, location);
                        }
                        else
                        {
                            Logger.ErrorFormat("Location is illegal with item type {0}", pair.Value);
                        }
                    }

                    var effectDic = entity.weaponAttachment.EffectDic;
                    if (effectDic.Count > 0)
                    {
                        foreach (var effect in effectDic)
                        {
                            var attachGo = entity.multiUnityObject.LoadedAssets[effect];
                            attachGo.AsGameObject.transform.position = entity.position.Value;
                        }
                    }
                }
            }
コード例 #3
0
        private void AssembleWeapon(SceneObjectEntity entity)
        {
            var weaponGo      = entity.multiUnityObject.FirstAsset;
            var partAssetDict = entity.weaponAttachment.PartAssetDict;

            //var attachResList = entity.weaponAttachment.AttachResList;
            // if (attachResList.Count > 0 && attachResList[0] is Material)
            // {
            //     Material newMat = GameObject.Instantiate(attachResList[0] as Material);
            //     var renderAssy = weaponGo.GetComponentsInChildren<MeshRenderer>();
            //     foreach (var render in renderAssy)
            //     {
            //         render.sharedMaterial = newMat;
            //         render.enabled = true;
            //     }
            // }
            foreach (var keyPartAssetData in partAssetDict)
            {
                if (keyPartAssetData.Value.UnityObject && keyPartAssetData.Value.PartLocation != WeaponPartLocation.EndOfTheWorld)
                {
                    boneMountUtil.MountWeaponAttachment(keyPartAssetData.Value.UnityObject,
                                                        weaponGo, keyPartAssetData.Value.PartLocation);
                }
                else
                {
                    SceneObjectLoadSystem.Logger.ErrorFormat("Location is illegal with item type {0}", keyPartAssetData.Value);
                }
                // entity.weaponAttachment.EffectAssetList.ForEach(
                //     effectGo =>
                //     {
                //         if (effectGo != null && effectGo.AsGameObject)
                //             effectGo.AsGameObject.transform.position = entity.position.Value;
                //     });
            }
        }