Ejemplo n.º 1
0
        private static GameObject CreateGreanade(GrenadeProperties properties)
        {
            // Initialize gameobjects.
            GameObject grenade      = new GameObject(properties.GetModel());
            GameObject grenadeModel = GameObject.Instantiate(properties.GetGrenadeObject(), Vector3.zero, Quaternion.identity, grenade.transform);

            // Initialize components
            Grenade        grenadeComponent = UEditorInternal.AddComponent <Grenade>(grenade);
            Rigidbody      rigidbody        = UEditorInternal.AddComponent <Rigidbody>(grenade);
            SphereCollider sphereCollider   = UEditorInternal.AddComponent <SphereCollider>(grenade);
            AudioSource    audioSource      = UEditorInternal.AddComponent <AudioSource>(grenade);

            // Setup Grenade component.
            grenadeComponent.SetGrenadeObject(properties.GetGrenadeObject());
            grenadeComponent.SetRadius(properties.GetRadius());
            grenadeComponent.SetExplosionEffect(properties.GetExplosionEffect());
            grenadeComponent.SetExplosionSound(properties.GetExplosionSound());
            grenadeComponent.SetExplosionProperties(properties.GetExplosionProperties());
            grenadeComponent.SetDecalProperties(properties.GetDecalProperties());
            grenadeComponent.SetDelay(properties.GetDelay());

            // Setup SphereCollider component.
            Renderer renderer = grenadeModel.GetComponent <Renderer>();

            if (renderer != null)
            {
                sphereCollider.center = renderer.bounds.center;
                sphereCollider.radius = renderer.bounds.size.x;
            }

            // Apply components position.
            UEditorInternal.MoveComponentBottom <Grenade>(grenade.transform);
            UEditorInternal.MoveComponentBottom <Rigidbody>(grenade.transform);
            UEditorInternal.MoveComponentBottom <SphereCollider>(grenade.transform);
            UEditorInternal.MoveComponentBottom <AudioSource>(grenade.transform);

            return(grenade);
        }
Ejemplo n.º 2
0
 private static void CreateInstances()
 {
     rayBullet = ScriptableObject.CreateInstance <RayBullet>();
     physicsBulletProperties = new PhysicsBulletProperties();
     grenadeProperties       = new GrenadeProperties();
 }