/// <summary>
 /// Copies the values in collider 1 to collider 2
 /// </summary>
 /// <param name="collider1"></param>
 /// <param name="collider2"></param>
 public static void Copy(HitColliderBehaviour collider1, HitColliderBehaviour collider2)
 {
     collider2.Init(collider1._damage, collider1._knockBackScale, collider1._hitAngle, collider1.DespawnsAfterTimeLimit, collider1.TimeActive, collider1.Owner, collider1.DestroyOnHit, collider1.IsMultiHit, collider1._adjustAngleBasedOnCollision, collider1._hitStunTime);
     collider2.onHit           = collider1.onHit;
     collider2.IgnoreColliders = collider1.IgnoreColliders;
     collider2.Priority        = collider1.Priority;
     collider2.LayersToIgnore  = collider1.LayersToIgnore;
 }
Esempio n. 2
0
        /// <summary>
        /// Spawns a new sphere collider
        /// </summary>
        /// <param name="parent">The game object this collider will be attached to</param>
        /// <param name="radius">The size of the sphere colliders radius</param>
        /// <param name="damage">The amount of damage this collider will do</param>
        /// <param name="knockBackScale">How far this object will knock others back</param>
        /// <param name="hitAngle">THe angle that objects hit by this collider will be launched at</param>
        /// <param name="despawnAfterTimeLimit">Whether or not this collider should despawn after a given time</param>
        /// <param name="timeActive">The amount of time this actor can be active for</param>
        /// <param name="owner">The owner of this collider. Collision with owner are ignored</param>
        /// <returns></returns>
        public static HitColliderBehaviour SpawnSphereCollider(Transform parent, float radius, float damage,
                                                               float knockBackScale, float hitAngle, bool despawnAfterTimeLimit, float timeActive = 0,
                                                               GameObject owner = null)
        {
            GameObject hitObject = new GameObject();

            hitObject.name = owner.name + " SphereCollider";
            SphereCollider collider = hitObject.AddComponent <SphereCollider>();

            hitObject.transform.parent = parent;
            collider.isTrigger         = true;
            collider.radius            = radius;

            HitColliderBehaviour hitScript = hitObject.AddComponent <HitColliderBehaviour>();

            hitScript.Init(damage, knockBackScale, hitAngle, despawnAfterTimeLimit, timeActive,
                           owner, false, false, true);

            return(hitScript);
        }
Esempio n. 3
0
        /// <summary>
        /// Spawns a new
        /// </summary>
        /// <param name="position"></param>
        /// <param name="size"></param>
        /// <param name="damage"></param>
        /// <param name="knockBackScale"></param>
        /// <param name="hitAngle"></param>
        /// <param name="despawnAfterTimeLimit"></param>
        /// <param name="timeActive"></param>
        /// <param name="owner"></param>
        /// <returns></returns>
        public static HitColliderBehaviour SpawnBoxCollider(Vector3 position, Vector3 size, float damage,
                                                            float knockBackScale, float hitAngle, bool despawnAfterTimeLimit,
                                                            float timeActive = 0, GameObject owner = null)
        {
            GameObject hitObject = new GameObject();

            hitObject.name = owner.name + "BoxCollider";
            BoxCollider collider = hitObject.AddComponent <BoxCollider>();

            hitObject.transform.position = position;
            collider.isTrigger           = true;
            collider.size = size;

            HitColliderBehaviour hitScript = hitObject.AddComponent <HitColliderBehaviour>();

            hitScript.Init(damage, knockBackScale, hitAngle, despawnAfterTimeLimit, timeActive,
                           owner, false, false, true);

            return(hitScript);
        }
Esempio n. 4
0
        /// <summary>
        /// Spawns a new capsule collider
        /// </summary>
        /// <param name="position">The world position of this collider</param>
        /// <param name="radius">The length of the radius of this collider</param>
        /// <param name="height">How tall this collider is</param>
        /// <param name="damage">The amount of damage this collider will do to objects</param>
        /// <param name="knockBackScale">How far will objects hit by this collider will travel</param>
        /// <param name="hitAngle">The angle objects hit by this collider are launched</param>
        /// <param name="rotation">The orientation of this collider</param>
        /// <param name="despawnAfterTimeLimit">Whether or not this collider will despawn after a given time</param>
        /// <param name="timeActive">The amount of time this collider is going to be active for</param>
        /// <param name="owner">The game object that owns this collider. Collision with this object will be ignored</param>
        /// <returns></returns>
        public static HitColliderBehaviour SpawnCapsuleCollider(Vector3 position, float radius, float height,
                                                                float damage, float knockBackScale, float hitAngle,
                                                                Quaternion rotation, bool despawnAfterTimeLimit, float timeActive = 0,
                                                                GameObject owner = null)
        {
            GameObject hitObject = new GameObject();

            hitObject.name = owner.name + "CapsuleCollider";
            CapsuleCollider collider = hitObject.AddComponent <CapsuleCollider>();

            hitObject.transform.position = position;
            collider.isTrigger           = true;
            collider.radius = radius;
            collider.height = height;
            hitObject.transform.rotation = rotation;

            HitColliderBehaviour hitScript = hitObject.AddComponent <HitColliderBehaviour>();

            hitScript.Init(damage, knockBackScale, hitAngle, despawnAfterTimeLimit, timeActive,
                           owner, false, false, true);

            return(hitScript);
        }