Beispiel #1
0
        /// <summary>
        /// Shooting using RayCast.
        /// </summary>
        protected virtual void RayBulletShootingProcess()
        {
            RaycastHit raycastHit;

            for (int i = 0; i < rayBullet.GetNumberBullet(); i++)
            {
                if (rayBullet.GetNumberBullet() > 1)
                {
                    firePoint.localRotation = SpreadProperties.GetSpreadRotation(-rayBullet.GetVariance(), rayBullet.GetVariance());
                }
                if (Physics.Raycast(firePoint.position, firePoint.forward, out raycastHit, fireRange))
                {
                    Debug.DrawLine(firePoint.position, firePoint.forward, Color.red);
                    Transform hitTransform = raycastHit.transform;
                    SendDamage(hitTransform, rayBullet.GetDamage());
                    if (rayBullet.GetDecalProperties() != null)
                    {
                        DecalProperty decalProperty    = DecalHelper.GetDecalPropertyBySurface(rayBullet.GetDecalProperties(), raycastHit);
                        GameObject    decal            = decalProperty.GetRandomDecal();
                        AudioClip     decalSoundEffect = decalProperty.GetRandomSound();
                        if (decal != null)
                        {
                            PoolManager.Instantiate(decal, raycastHit.point, Quaternion.LookRotation(raycastHit.normal));
                        }
                        if (decalSoundEffect != null)
                        {
                            audioSource.PlayOneShot(decalSoundEffect);
                        }
                    }
                    AddImpulse(transform, raycastHit.point);
                }
            }
        }
Beispiel #2
0
 public void CreateDecal(RaycastHit raycastHit)
 {
     if (bullet.GetDecalProperties() != null)
     {
         DecalProperty decalProperty    = DecalHelper.GetDecalPropertyBySurface(bullet.GetDecalProperties(), raycastHit);
         GameObject    decal            = decalProperty.GetRandomDecal();
         AudioClip     decalSoundEffect = decalProperty.GetRandomSound();
         if (decal != null)
         {
             PoolManager.Instantiate(decal, raycastHit.point, Quaternion.LookRotation(raycastHit.normal));
         }
         if (decalSoundEffect != null)
         {
             audioSource.PlayOneShot(decalSoundEffect);
         }
     }
 }
Beispiel #3
0
        private static void RayBulletGUI()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Space(5);
            GUILayout.Label(ContentProperties.BaseOptions, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            rayBullet.SetModel(EditorGUILayout.TextField(ContentProperties.Model, rayBullet.GetModel()));
            rayBullet.SetDamage(EditorGUILayout.IntField(ContentProperties.Damage, rayBullet.GetDamage()));
            rayBullet.SetVariance(EditorGUILayout.FloatField(ContentProperties.Variance, rayBullet.GetVariance()));
            rayBullet.SetNumberBullet(EditorGUILayout.IntField(ContentProperties.NumberBullet, rayBullet.GetNumberBullet()));
            rayBullet.SetDecalProperties(UEditor.ObjectField <DecalProperties>(ContentProperties.DecalProperties, rayBullet.GetDecalProperties(), false));

            GUILayout.Space(5);
            UEditor.HorizontalLine();
            GUILayout.Space(5);

            EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(rayBullet.GetModel()));
            if (UEditor.Button("Create", "Right", GUILayout.Width(70)))
            {
                string path = EditorUtility.SaveFilePanelInProject("Create new RayBullet", rayBullet.GetModel(), "", "");
                if (!string.IsNullOrEmpty(path))
                {
                    string name = System.IO.Path.GetFileName(path);
                    path = path.Replace(name, "");
                    ScriptableObjectUtility.CreateAsset(rayBullet, path, name);
                    CreateInstances();
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(5);
            GUILayout.EndVertical();
        }