Exemplo n.º 1
0
        /// <summary>
        /// Reflect the bullet by turning the degree.
        /// </summary>
        /// <param name="bullet"> bullet reflecting. </param>
        private void ReflectBullet(JCS_Bullet bullet)
        {
            // if object cannot be reflected, end function call
            if (!bullet.Reflectable)
            {
                return;
            }

            float randDegree = JCS_Random.Range(-mRandomReflectDegree, mRandomReflectDegree);

            Vector3 rotation = bullet.transform.eulerAngles;

            rotation.z += (180 + randDegree);      // plus 180 so it goes other direction.
            bullet.transform.eulerAngles = rotation;

            // apply the force.
            bullet.MoveSpeed += mReflectForce;

            // play sound from sound pool
            mSoundPoolAction.PlayRandomSound();

            // do random teleport effect
            RandomPosEffect(bullet);

            // apply position offset
            bullet.transform.position += mPosOffset;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shoot a bullet.
        /// </summary>
        /// <param name="bulletSpeed"></param>
        /// <param name="pos"></param>
        /// <param name="direction"></param>
        /// <param name="hit"></param>
        /// <param name="index"></param>
        /// <param name="inSequence"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public JCS_Bullet Shoot(float bulletSpeed, Vector3 pos, bool direction, int hit, int index = 0, bool inSequence = false, Transform target = null)
        {
            if (mPlayer != null)
            {
                if (mPlayer.CharacterState != JCS_2DCharacterState.NORMAL)
                {
                    return(null);
                }
            }

            Vector3 spawnPos = pos + mSpanwPointOffset;

            spawnPos = RandTransform(spawnPos);

            JCS_Bullet bullet = (JCS_Bullet)JCS_Utility.SpawnGameObject(mBullet, spawnPos, mSpawnPoint.rotation);

            // no object spawns
            if (bullet == null)
            {
                return(null);
            }

            // set the attacker.
            SetAttackerInfo(bullet);

            float tempBulletSpeed = bulletSpeed;

            // default: facing left
            if (!direction)
            {
                tempBulletSpeed = -tempBulletSpeed;
            }

            // set bullet speed
            bullet.MoveSpeed = tempBulletSpeed;

            // Do devication Effect
            DeviationEffect(bullet.transform);

            if (bullet is JCS_2DBullet)
            {
                bullet.GetComponent <JCS_3DGoStraightAction>().MoveSpeed = bulletSpeed;
            }


            if (mTrackSoot &&
                target != null)
            {
                JCS_2DTrackAction ta = bullet.GetComponent <JCS_2DTrackAction>();
                if (ta != null)
                {
                    ta.TargetTransform = target;

                    // set to center
                    float newIndex = index - (hit / 2.0f);

                    // apply effect
                    ta.Index = newIndex;

                    ta.OrderIndex = index;
                }
            }

            if (mAbilityFormat != null)
            {
                JCS_ApplyDamageTextToLiveObjectAction adta = bullet.GetComponent <JCS_ApplyDamageTextToLiveObjectAction>();
                if (adta != null)
                {
                    // set the Ability Format
                    adta.AbilityFormat = mAbilityFormat;
                    adta.Hit           = hit;

                    // if hit equal to 0,
                    // meaning this bullet is in the sequence
                    if (inSequence)
                    {
                        adta.InSequence = true;
                    }

                    adta.TargetTransform = target;
                }
            }

            // part of the SFX
            mRandomMultiSoundAction.PlayRandomSound();

            return(bullet);
        }