コード例 #1
0
 protected override void AddRecycleObject(UnityObject obj)
 {
     Attachment.RemoveAllAttachment();
     WeaponAnimationBase.FinishedWeaponAnimation(obj.AsGameObject);
     ReplaceMaterialShaderBase.ResetShader(obj.AsGameObject);
     base.AddRecycleObject(obj);
 }
コード例 #2
0
        public void FromAvatarAnimToWeaponAnimProgress(IAdaptiveContainer <IFsmInputCommand> commands,
                                                       GameObject weaponP1,
                                                       GameObject weaponP3,
                                                       IWeaponAnimProgress progress)
        {
            progress.FirstPersonAnimName = string.Empty;
            progress.ThirdPersonAnimName = string.Empty;

            for (int i = 0; i < commands.Length; ++i)
            {
                var    cmd = commands[i];
                string animName;

                if (MonitoredWeaponAnimP3.TryGetValue(cmd.Type, out animName) &&
                    weaponP3 != null && WeaponAnimationBase.IsAnimationExist(weaponP3, animName))
                {
                    progress.ThirdPersonAnimName     = animName;
                    progress.ThirdPersonAnimProgress = cmd.AdditioanlValue;
                }

                if (MonitoredWeaponAnimP1.TryGetValue(cmd.Type, out animName) &&
                    weaponP1 != null && WeaponAnimationBase.IsAnimationExist(weaponP1, animName))
                {
                    progress.FirstPersonAnimName     = animName;
                    progress.FirstPersonAnimProgress = cmd.AdditioanlValue;
                }
            }
        }
コード例 #3
0
        public void FromWeaponAnimProgressToWeaponAnim(GameObject weaponP1,
                                                       GameObject weaponP3,
                                                       IWeaponAnimProgress progress)
        {
            if (weaponP1 != null)
            {
                WeaponAnimationBase.FinishedWeaponAnimation(weaponP1);
                WeaponAnimationBase.SetNormalizedTime(weaponP1, progress.FirstPersonAnimName, progress.FirstPersonAnimProgress);
            }

            if (weaponP3 != null)
            {
                WeaponAnimationBase.FinishedWeaponAnimation(weaponP3);
                WeaponAnimationBase.SetNormalizedTime(weaponP3, progress.ThirdPersonAnimName, progress.ThirdPersonAnimProgress);
            }
        }
コード例 #4
0
 public void WeaponAnimFinishedUpdate(IAdaptiveContainer <IFsmInputCommand> commands,
                                      GameObject weaponP1,
                                      GameObject weaponP3,
                                      IWeaponAnimProgress progress)
 {
     for (int i = 0; i < commands.Length; ++i)
     {
         var cmd = commands[i];
         if (MonitoredWeaponAnimFinish.ContainsKey(cmd.Type))
         {
             WeaponAnimationBase.FinishedWeaponAnimation(weaponP1);
             WeaponAnimationBase.FinishedWeaponAnimation(weaponP3);
             progress.FirstPersonAnimProgress = 0;
             progress.ThirdPersonAnimProgress = 0;
             return;
         }
     }
 }
コード例 #5
0
        public static RayCastTarget Assemble(GameObject model, SceneObjectEntity entity)
        {
            model.transform.localRotation = Quaternion.Euler(0, 0, 0);
            model.transform.position      = Vector3.zero;

            var         child = model.transform.Find(SceneObjectConstant.NormalColliderName);
            BoxCollider boxCollider;

            if (null == child)
            {
                child                 = new GameObject(SceneObjectConstant.NormalColliderName).transform;
                child.parent          = model.transform;
                boxCollider           = child.gameObject.AddComponent <BoxCollider>();
                boxCollider.isTrigger = true;
            }
            else
            {
                boxCollider = child.gameObject.GetComponent <BoxCollider>();
            }
            boxCollider.center     = Vector3.zero;
            boxCollider.enabled    = true;
            child.gameObject.layer = UnityLayerManager.GetLayerIndex(EUnityLayerName.UserInputRaycast);

            if (entity.hasWeaponObject && SingletonManager.Get <WeaponResourceConfigManager>().IsC4(entity.weaponObject.ConfigId))
            {
                WeaponAnimationBase.FinishedWeaponAnimation(model);
            }

            Bounds bounds = CalculateBounds(model);

            boxCollider.size = bounds.size; // * model.transform.worldToLocalMatrix;

            /*if (entity.hasWeaponObject)
             * {
             *  var config = SingletonManager.Get<WeaponResourceConfigManager>().GetConfigById(entity.weaponObject.ConfigId);
             *  if (config != null && ((EWeaponType_Config) config.Type).CanAutoPick())
             *  {
             *      if (SingletonManager.Get<WeaponResourceConfigManager>().IsC4(entity.weaponObject.ConfigId))
             *      {
             *          boxCollider.size = new Vector3(bounds.size.x, 0.4f, bounds.size.z);
             *      }
             *      else
             *      {
             *          boxCollider.size = new Vector3(0.4f, bounds.size.y, bounds.size.z);
             *      }
             *  }
             * }*/
            entity.position.Bounds = bounds;

            child.localEulerAngles = Vector3.zero;
            child.localPosition    = bounds.center - model.transform.position;
            child.localScale       = Vector3.one;

            if (entity.hasSize)
            {
                model.transform.localScale = Vector3.one * Mathf.Max(1f, entity.size.Value);
            }
            else
            {
                model.transform.localScale = Vector3.one;
            }

            if ((entity.hasWeaponObject && !SingletonManager.Get <WeaponResourceConfigManager>().IsC4(entity.weaponObject.ConfigId) &&
                 !SingletonManager.Get <WeaponResourceConfigManager>().IsArmors(entity.weaponObject.ConfigId)) ||
                (entity.hasSimpleItem && entity.simpleItem.Category == (int)ECategory.WeaponPart))
            {
                model.transform.localRotation = Quaternion.Euler(0, 0, -90);
                entity.position.ModelRotate   = true;
            }
            else
            {
                entity.position.ModelRotate = false;
            }


            var target = RayCastTargetUtil.AddRayCastTarget(child.gameObject);

            return(target);
        }