예제 #1
0
        //Called when ability is used
        protected override void Activate(params object[] args)
        {
            //Create barrier collider
            _barrierCollider = new HitColliderBehaviour(abilityData.GetCustomStatValue("Damage"), abilityData.GetCustomStatValue("KnockBackScale"),
                                                        abilityData.GetCustomStatValue("HitAngle"), true, abilityData.timeActive, owner, true, false, true, abilityData.GetCustomStatValue("HitStun"));
            //Allow canceling on hit
            _barrierCollider.onHit += arguments => { abilityData.canCancelActive = true; abilityData.canCancelRecover = true; EndAbility(); };

            //Set the position of the barrier in relation to the character
            Vector3 offset = new Vector3(abilityData.GetCustomStatValue("XOffset") * owner.transform.forward.x, abilityData.GetCustomStatValue("YOffset"), 0);

            //Create barrier
            _visualPrefabInstance = MonoBehaviour.Instantiate(abilityData.visualPrefab, owner.transform.position + offset, new Quaternion());

            //Attach hit box to barrier
            HitColliderBehaviour instanceBehaviour = _visualPrefabInstance.AddComponent <HitColliderBehaviour>();

            HitColliderBehaviour.Copy(_barrierCollider, instanceBehaviour);

            //Store barrier collider
            _prefabeInstanceCollider = _visualPrefabInstance.GetComponent <BoxCollider>();

            //Give the player invinicibility while using the barrier to prevent easy over-head hits
            _ownerHealth.SetInvincibilityByCondition(condition => !InUse || CurrentAbilityPhase == AbilityPhase.RECOVER);
        }
예제 #2
0
        /// <summary>
        /// Spawns a new box collider
        /// </summary>
        /// <param name="position">The world position of this collider</param>
        /// <param name="size">The dimension of this collider</param>
        /// <param name="hitCollider">The hit collider this collider will copy its values from</param>
        /// <returns></returns>
        public static HitColliderBehaviour SpawnBoxCollider(Vector3 position, Vector3 size, HitColliderBehaviour hitCollider)
        {
            GameObject hitObject = new GameObject();

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

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

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

            HitColliderBehaviour.Copy(hitCollider, hitScript);

            return(hitScript);
        }
예제 #3
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="hitCollider">The hit collider this collider will copy its values from</param>
        /// <returns></returns>
        public static HitColliderBehaviour SpawnSphereCollider(Transform parent, float radius, HitColliderBehaviour hitCollider)
        {
            GameObject hitObject = new GameObject();

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

            hitObject.transform.parent        = parent;
            hitObject.transform.localPosition = Vector3.zero;
            collider.isTrigger = true;
            collider.radius    = radius;

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

            HitColliderBehaviour.Copy(hitCollider, hitScript);

            return(hitScript);
        }
예제 #4
0
        /// <summary>
        /// Activates the hitboxes along the path
        /// </summary>
        private void ActivateStunPath()
        {
            //Creates a new collider for the attackLinks in the path to use
            _stunCollider = new HitColliderBehaviour(abilityData.GetCustomStatValue("Damage"), abilityData.GetCustomStatValue("KnockBackScale"),
                                                     abilityData.GetCustomStatValue("HitAngle"), true, abilityData.GetCustomStatValue("Lifetime"), owner);

            //When the attackLinks in the path collide with an something else, try to stun it
            _stunCollider.onHit += StunEntity;

            //Gets a path from the first link to the second link
            List <PanelBehaviour> panels = AI.AIUtilities.Instance.GetPath(_linkMoveScripts[0].CurrentPanel, _linkMoveScripts[1].CurrentPanel, true);

            //Spawns attackLinks on each panel in the path
            for (int i = 0; i < panels.Count; i++)
            {
                GameObject           attackLink = MonoBehaviour.Instantiate(_attackLinkVisual, panels[i].transform.position + new Vector3(0, .5f, 0), _attackLinkVisual.transform.rotation);
                HitColliderBehaviour collider   = attackLink.AddComponent <HitColliderBehaviour>();
                HitColliderBehaviour.Copy(_stunCollider, collider);
            }
        }
        /// <summary>
        /// Fires a projectile
        /// </summary>
        /// <param name="force">The amount of force to apply to the projectile</param>
        /// <param name="hitCollider">The hit collider to attach to the projectile</param>
        /// <returns></returns>
        public GameObject FireProjectile(Vector3 force, HitColliderBehaviour hitCollider)
        {
            if (!projectile)
            {
                return(null);
            }

            GameObject temp = Instantiate(projectile, transform.position, new Quaternion(), null);

            HitColliderBehaviour collider = (temp.AddComponent <HitColliderBehaviour>());

            HitColliderBehaviour.Copy(hitCollider, collider);

            Rigidbody rigidbody = temp.GetComponent <Rigidbody>();

            if (rigidbody)
            {
                rigidbody.AddForce(force, ForceMode.Impulse);
            }

            return(temp);
        }