Beispiel #1
0
        private void InitializeBullet(BulletSpawnDefinition bulletSpawnDefinition)
        {
            Quaternion currentRotation = transform.rotation;
            Quaternion addedRotation = Quaternion.AngleAxis(-bulletSpawnDefinition.Angle, new Vector3(0.0f, 0.0f, 1.0f));
            Quaternion totalRotation = currentRotation * addedRotation;

            //FIX super dirty, try to use templates!
            PoolableObject obj = m_BulletPool.ActivateAvailableObject(transform.position, totalRotation);

            if (m_BulletPool.IsPoolType<Bullet>())
            {
                Bullet bullet = (Bullet)obj;
                bullet.Speed = bulletSpawnDefinition.BulletDefinition.Speed;
                bullet.Damage = bulletSpawnDefinition.BulletDefinition.Damage;
                bullet.MovePattern = bulletSpawnDefinition.MovePattern;
                bullet.Frequency = bulletSpawnDefinition.Frequency;
                bullet.Amplitude = bulletSpawnDefinition.Amplitude;

                if (bulletSpawnDefinition.BulletDefinition.Sprite != null)
                    bullet.Sprite = bulletSpawnDefinition.BulletDefinition.Sprite;

                //Set the tag
                bullet.gameObject.tag = gameObject.tag;
            }

            if (m_FireEffectPool)
            {
                PoolableObject poolableObject = m_FireEffectPool.ActivateAvailableObject(transform.position, transform.rotation);
                poolableObject.transform.parent = this.transform;
            }
        }
Beispiel #2
0
        private void InitializeBullet(BulletSpawnDefinition bulletSpawnDefinition)
        {
            Quaternion currentRotation = transform.rotation;
            Quaternion addedRotation   = Quaternion.AngleAxis(-bulletSpawnDefinition.Angle, new Vector3(0.0f, 0.0f, 1.0f));
            Quaternion totalRotation   = currentRotation * addedRotation;

            //FIX super dirty, try to use templates!
            PoolableObject obj = m_BulletPool.ActivateAvailableObject(transform.position, totalRotation);

            if (m_BulletPool.IsPoolType <Bullet>())
            {
                Bullet bullet = (Bullet)obj;
                bullet.Speed       = bulletSpawnDefinition.BulletDefinition.Speed;
                bullet.Damage      = bulletSpawnDefinition.BulletDefinition.Damage;
                bullet.MovePattern = bulletSpawnDefinition.MovePattern;
                bullet.Frequency   = bulletSpawnDefinition.Frequency;
                bullet.Amplitude   = bulletSpawnDefinition.Amplitude;

                if (bulletSpawnDefinition.BulletDefinition.Sprite != null)
                {
                    bullet.Sprite = bulletSpawnDefinition.BulletDefinition.Sprite;
                }

                //Set the tag
                bullet.gameObject.tag = gameObject.tag;
            }

            if (m_FireEffectPool)
            {
                PoolableObject poolableObject = m_FireEffectPool.ActivateAvailableObject(transform.position, transform.rotation);
                poolableObject.transform.parent = this.transform;
            }
        }