Ejemplo n.º 1
0
        partial void DamageParticles(float deltaTime, Vector2 worldPosition)
        {
            particleEmitter?.Emit(deltaTime, worldPosition);

            if (sound != null)
            {
                SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, ignoreMuffling: sound.IgnoreMuffling);
            }
        }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
        //Checking if the device supports accelerometer of keyboard
        if ((Input.acceleration.x * horizontalTopSpeed > 0 || Input.acceleration.x * horizontalTopSpeed < -0) && Input.touchCount >= 0)
        {
            //verticalSpeed = Mathf.SmoothDamp (verticalSpeed, verticalTopSpeed * Input.acceleration.z, ref verticalSpeedV, verticalSpeedChange);
            horizontalSpeed = Mathf.SmoothDamp(horizontalSpeed, horizontalTopSpeed * Input.acceleration.x, ref horizontalSpeedV, horizontalSpeedChange);
        }
        // if device doesnt support accelerometer
        else
        {
            verticalSpeed   = Mathf.SmoothDamp(verticalSpeed, verticalTopSpeed * Input.GetAxis("Vertical"), ref verticalSpeedV, verticalSpeedChange);
            horizontalSpeed = Mathf.SmoothDamp(horizontalSpeed, horizontalTopSpeed * Input.GetAxis("Horizontal"), ref horizontalSpeedV, horizontalSpeedChange);
        }
        transform.position = new Vector3(Mathf.Clamp(transform.position.x + horizontalSpeed,
                                                     -maxHorizontalPos, maxHorizontalPos), transform.position.y,
                                         Mathf.Clamp(transform.position.z +
                                                     verticalSpeed * Time.deltaTime, minVerticalPos, maxVerticalPos));


        //Tap of press space to fire the bullet
        if ((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetButtonDown("Jump"))
        {
            energyHealth -= playerBulletDec;             //decrementing the energy

            //availability of the bullet
            if (energyHealth > 1)
            {
                Instantiate(mainBullet, transform.position + new Vector3(0f, 0f, 1.2f), transform.rotation);
                audio.Play();
            }
            else
            {
                energyHealth = 0f;
            }
        }
        //player smoke particle activation
        if (health <= HEALTH_THREASOLD)
        {
            myParticle.Emit();
        }
        //game over
        if (health <= 0)
        {
            //Save your settings here...
            gameOver();
            Application.LoadLevel(2);
        }
    }
Ejemplo n.º 3
0
        partial void DamageParticles(float deltaTime, Vector2 worldPosition)
        {
            if (particleEmitter != null)
            {
                particleEmitter.Emit(deltaTime, worldPosition);
            }

            if (sound != null)
            {
                sound.Play(1.0f, 500.0f, worldPosition);
            }
        }
Ejemplo n.º 4
0
    private IEnumerator MuzzleControl()
    {
        if (Random.value < 0.8f)
        {
            muzzleFlash.Emit();
        }

        muzzleLight.GetComponent <Light>().enabled = true;
        yield return(null);

        muzzleLight.GetComponent <Light>().enabled = false;
    }
Ejemplo n.º 5
0
    public override void OSCMessageReceiver(OscMessage message)
    {
        float x = System.Convert.ToInt32(message.Values[2]) / 127.0f;

        x *= 25;
        if (x > 0)
        {
            pe.maxSize = x;
            pe.minSize = x;
            pe.Emit();
        }
    }
Ejemplo n.º 6
0
 public override void Fire2(int ammoId, int launcher, Vector3 pos, Vector3 rot)
 {
     if (Launcher != LAUNCHER.NONE && dic != null)
     {
         if (dic.ContainsKey(ammoId) && misObj != null)
         {
             Object.Instantiate((Object)GetExplosionEffByLauncher(), misObj.transform.position, Quaternion.Euler(rot));
             if (misSmokeEff != null)
             {
                 Object.DestroyImmediate(misSmokeEff);
                 misSmokeEff = null;
             }
             Object.DestroyImmediate(misObj);
             misObj = null;
             dic.Remove(ammoId);
         }
         Launcher = (LAUNCHER)launcher;
         Quaternion localRotation = Quaternion.FromToRotation(Vector3.forward, rot);
         if (muzzleFxInstance2 == null)
         {
             GameObject gameObject = muzzleFxInstance2 = (Object.Instantiate((Object)GetMuzzleFireEffByLauncher()) as GameObject);
         }
         muzzleFxInstance2.transform.position      = pos;
         muzzleFxInstance2.transform.localRotation = localRotation;
         ParticleEmitter particleEmitter = null;
         int             childCount      = muzzleFxInstance2.transform.childCount;
         for (int i = 0; i < childCount; i++)
         {
             Transform child = muzzleFxInstance2.transform.GetChild(i);
             particleEmitter = child.GetComponent <ParticleEmitter>();
             if ((bool)particleEmitter)
             {
                 particleEmitter.Emit();
             }
         }
         misObj = (Object.Instantiate((Object)GetMissileByLauncher()) as GameObject);
         misObj.transform.position = pos;
         misObj.transform.rotation = Quaternion.FromToRotation(Vector3.forward, rot);
         if (IsCrossbowType())
         {
             misSmokeEff = null;
         }
         else
         {
             misSmokeEff = (Object.Instantiate((Object)GlobalVars.Instance.missileSmokeEff) as GameObject);
             misSmokeEff.transform.position = pos;
             misSmokeEff.transform.parent   = misObj.transform;
         }
         dic.Add(ammoId, new ProjectileWrap(misObj));
         base.animation.Play("bigfire");
         base.animation["bigfire"].wrapMode = WrapMode.Once;
     }
 }
Ejemplo n.º 7
0
        partial void DamageParticles(float deltaTime, Vector2 worldPosition)
        {
            if (particleEmitter != null)
            {
                particleEmitter.Emit(deltaTime, worldPosition);
            }

            if (sound != null)
            {
                SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range);
            }
        }
        public void RenderTest()
        {
            string          path    = "../../res/particles/";
            ParticleEmitter emitter = new ParticleEmitter(10, new Sprite(Image.FromFile(path + "shield_particle.png"), new Vector2(6, 5), new Vector2(100, 100)),
                                                          new ParticleProperties(new Range(1f, 2f), new Range(1f, 2f), new Range(1f, 2f), new Range(1f, 2f), new Range(1f, 2f), 5f));
            Bitmap map = new Bitmap(path + "shield_particle.png");

            emitter.IsEmitting = false;
            emitter.Render(Graphics.FromImage(map));
            emitter.Emit();
            Assert.IsTrue(emitter.IsEmitting);
        }
Ejemplo n.º 9
0
    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        string hitName = hit.gameObject.name;
        bool   item    = false;
        bool   plant   = false;

        switch (hitName)
        {
        case "Cube(Clone)":
            item = true;
            break;

        case "Bull(Clone)":
            item = true;
            break;

        case "Tablet(Clone)":
            item = true;
            break;

        case "Cylinder(Clone)":
            item = true;
            break;

        case "plantGrowth(Clone)":
            plant = true;
            break;
        }

        if (item)
        {
            speedSound.Play();
            Destroy(hit.gameObject);
            score++;
            animation.Play("feed");
            heart.enabled = true;
            heart.Emit();
            boost            = true;
            movePlayer.speed = Mathf.Min(movePlayer.refSpeed + BOOST, movePlayer.speed + BOOST);
            timeBoost        = 0;
        }
        else if (plant)
        {
            thudSound.Play();
            Destroy(hit.gameObject);
            leaf.enabled = true;
            leaf.Emit();
            slow             = true;
            movePlayer.speed = Mathf.Max(movePlayer.refSpeed - SLOW, movePlayer.speed - SLOW);
            timeSlow         = 0;
        }
    }
Ejemplo n.º 10
0
 public void Emit(Vector3 point, Vector3 normal, ParticleEmitter[] ParticleEmitters)
 {
     for (int i = 0; i < ParticleEmitters.Length; i++)
     {
         ParticleEmitter b = ParticleEmitters[i];
         if (i == 0)
         {
             b.transform.position = point;
             b.transform.up       = normal + Random.insideUnitSphere * .1f;
         }
         b.Emit();
     }
 }
Ejemplo n.º 11
0
    public void Emit(Vector3 heading, float swipeVelocity)
    {
        // orient our emitter towards the swipe direction
        emitter.transform.rotation = Quaternion.LookRotation(heading);

        Vector3 localEmitVelocity = emitter.localVelocity;

        localEmitVelocity.z   = baseSpeed * swipeVelocityScale * swipeVelocity;
        emitter.localVelocity = localEmitVelocity;

        // fire away!
        emitter.Emit();
    }
Ejemplo n.º 12
0
        public void FireProjectile()
        {
            Vector3    direction = SprayDirection();
            Quaternion convert   = Quaternion.LookRotation(direction + new Vector3(0, 0.04f, 0));

            Rigidbody instantiatedProjectile;

            instantiatedProjectile          = ((GameObject)Instantiate(projectile, pos.position, convert)).GetComponent <Rigidbody>();
            instantiatedProjectile.velocity = instantiatedProjectile.transform.TransformDirection(new Vector3(0, 0, initialSpeed));
            Physics.IgnoreCollision(instantiatedProjectile.GetComponent <Collider>(), transform.root.GetComponent <Collider>());
            emitter.Emit();
            transform.root.GetComponent <Rigidbody>().AddRelativeForce(new Vector3(0, 0, -backForce), ForceMode.Impulse);
        }
    void Start()
    {
        if (particle == null)
        {
            particle = GetComponent <ParticleEmitter>();
        }

        particles = new Particle[image.maxparticles];

        if (image)
        {
            particle.Emit(image.maxparticles);
        }
    }
Ejemplo n.º 14
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);
            if (Input.MouseButtonDown)
            {
                Vector2 mousePosition = Input.MousePosition;

                explosion.transform.SetPosition(mousePosition);
                explosion.Emit();

                explosionClone.transform.SetPosition(mousePosition + Vector2.left * 300f);
                explosionClone.Emit();
            }
        }
Ejemplo n.º 15
0
 void ApplyDamage(float damage)
 {
     hitPoints -= damage;
     if (hitPoints <= 0 && !broken)
     {
         breakParticles.Emit();                                                     //emit broken object particles
         audio.pitch = Random.Range(0.95f * Time.timeScale, 1.0f * Time.timeScale); //add slight random value to breaking sound pitch for variety
         audio.Play();                                                              //play break sound
         //disable mesh and collider of glass object untill object is deleted after sound effect finishes playing
         myTransform.GetComponent <MeshRenderer>().enabled = false;
         myTransform.GetComponent <BoxCollider>().enabled  = false;          //can use other collider types if needed
         broken = true;
     }
 }
Ejemplo n.º 16
0
        public void Update(GameTime gameTime)
        {
            if (Input.GetKeyState(Keys.Space))
            {
                scale  += 0.01f;
                scale2 -= 0.5f;
            }
            if (Input.GetKeyRelease(Keys.Space))
            {
                scale  = 0.01f;
                scale2 = 500;
            }
            vector = new Vector2(scale);

            sound.PlayBGM("VoLoN BGM");
            num2 += 1 / 60f;//角煮用
            if (Input.GetKeyState(Keys.Space))
            {
                num++;
            }
            if (Input.GetKeyRelease(Keys.Space) && num <= 10)
            {
                isEndFlag = true;
            }
            if (Input.GetKeyState(Keys.Space) && num >= 100)
            {
                nextScene = SceneName.Tutorial;
                isEndFlag = true;
                return;
            }
            else if (Input.GetKeyRelease(Keys.Space))
            {
                num = 0;
            }

            float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (Input.GetKeyTrigger(Keys.A))
            {
                float scale      = 0.5f;
                float shrinkRote = 0.3f;
                int   speed      = 200;
                emitter.Emit("Player", new Vector2(60, 60),
                             new Vector2(500, 300),
                             scale, shrinkRote, 1f, 1, speed, Color.Blue);
            }

            emitter.Update(delta);
        }
Ejemplo n.º 17
0
        public void MuzzleFlash_(bool temp)
        {
            BroadcastMessage("Activate", SendMessageOptions.DontRequireReceiver);
            if (temp != isPrimary)
            {
                return;
            }
            var emitters = this.GetComponentsInChildren <ParticleEmitter>();

            for (int i = 0; i < emitters.Length; i++)
            {
                ParticleEmitter p = emitters[i] as ParticleEmitter;
                p.Emit();
            }
        }
Ejemplo n.º 18
0
    void OnCollisionEnter(Collision collision)
    {
        // 충돌한 객체의 태그가 "Bullet"일 경우
        if (collision.transform.tag == "Bullet")
        {
            return;
        }

        // 파티클을 생성합니다.
        CloneSpark.transform.position = transform.position;
        Emitter.Emit();

        // 현재 게임 객체를 제거합니다.
        Destroy(transform.gameObject);
    }
Ejemplo n.º 19
0
    static int Emit(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            ParticleEmitter obj = LuaScriptMgr.GetNetObject <ParticleEmitter>(L, 1);
            obj.Emit();
            return(0);
        }
        else if (count == 2)
        {
            ParticleEmitter obj  = LuaScriptMgr.GetNetObject <ParticleEmitter>(L, 1);
            int             arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
            obj.Emit(arg0);
            return(0);
        }
        else if (count == 6)
        {
            ParticleEmitter obj  = LuaScriptMgr.GetNetObject <ParticleEmitter>(L, 1);
            Vector3         arg0 = LuaScriptMgr.GetVector3(L, 2);
            Vector3         arg1 = LuaScriptMgr.GetVector3(L, 3);
            float           arg2 = (float)LuaScriptMgr.GetNumber(L, 4);
            float           arg3 = (float)LuaScriptMgr.GetNumber(L, 5);
            Color           arg4 = LuaScriptMgr.GetColor(L, 6);
            obj.Emit(arg0, arg1, arg2, arg3, arg4);
            return(0);
        }
        else if (count == 8)
        {
            ParticleEmitter obj  = LuaScriptMgr.GetNetObject <ParticleEmitter>(L, 1);
            Vector3         arg0 = LuaScriptMgr.GetVector3(L, 2);
            Vector3         arg1 = LuaScriptMgr.GetVector3(L, 3);
            float           arg2 = (float)LuaScriptMgr.GetNumber(L, 4);
            float           arg3 = (float)LuaScriptMgr.GetNumber(L, 5);
            Color           arg4 = LuaScriptMgr.GetColor(L, 6);
            float           arg5 = (float)LuaScriptMgr.GetNumber(L, 7);
            float           arg6 = (float)LuaScriptMgr.GetNumber(L, 8);
            obj.Emit(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: ParticleEmitter.Emit");
        }

        return(0);
    }
Ejemplo n.º 20
0
        public override void Load()
        {
            explosion = new ParticleFactory().Create("explosion") as ParticleEmitter;
            int hash1 = explosion.GetHashCode();

            explosionClone = new ParticleFactory().Create("explosion") as ParticleEmitter;
            int hash2 = explosionClone.GetHashCode();

            shield = new ParticleFactory().Create("shield") as ParticleEmitter;
            health = new ParticleFactory().Create("health") as ParticleEmitter;

            shield.transform.SetPosition(new Vector2(200, 300));
            shield.Emit();
            health.transform.SetPosition(new Vector2(400, 300));
            health.Emit();
        }
Ejemplo n.º 21
0
 // oh yeah i added this.
 public void CreateSmallPurpleExplosion(Vector3 pos, float size, float energy)
 {
     explosionSmallPurpleInstance.Emit(pos, Vector3.zero, 7, .2f, Color.white);
     for (int i = 0; i < 7; i++)
     {
         //			Vector3 vel = new Vector3(Random.Range(-10f,10f),Random.Range(-1f,1f),Random.Range(-10f,10f));
         //			size += Random.Range(-.1f,.1f)
         //
         //					energy
         //					color
         //
         //			sparkleFall1Instance.Emit(pos,
         //			sparkleFall1Instance.Emit(pos,vel,size,1.5f+Random.Range(-.4f,.4f),new Color(1,0,1));
         //			sparkleFall2Instance.Emit(pos,new Vector3(Random.Range(-10f,10f),2+Random.Range(-1f,1f),Random.Range(-10f,10f)),size+Random.Range(-.2f,.2f),energy+Random.Range(-.4f,.4f),new Color(1,0,1));
     }
 }
Ejemplo n.º 22
0
    //
    // 보석과 아이템을 배치한다.
    //
    void SetupGemsAndItems()
    {
        m_mapData.gemParticleIndex = new int[m_mapData.length, m_mapData.width];
        m_gemTotalNum = 0;

        // 보석 수를 세어, 같은 수량의 보석을 발생시킨다.
        for (int x = 0; x < m_mapData.width; x++)
        {
            for (int z = 0; z < m_mapData.length; z++)
            {
                if (IsGem(x, z))
                {
                    m_gemTotalNum++;
                }
            }
        }
        m_gemEmitter = GetComponent <ParticleEmitter>() as ParticleEmitter;
        m_gemEmitter.Emit(m_gemTotalNum);

        // 보석 배치.
        Particle[] gemParticle = m_gemEmitter.particles;
        int        gemCnt      = 0;

        for (int x = 0; x < m_mapData.width; x++)
        {
            for (int z = 0; z < m_mapData.length; z++)
            {
                Vector3 bpos = new Vector3(x + m_mapData.offset_x, GEM_Y, z + m_mapData.offset_z);
                m_mapData.gemParticleIndex[z, x] = -1;
                if (IsGem(x, z))
                {
                    gemParticle[gemCnt].position     = bpos;
                    gemParticle[gemCnt].size         = GEM_SIZE;
                    m_mapData.gemParticleIndex[z, x] = gemCnt;
                    gemCnt++;
                }

                // 아이템 생성.
                if (m_mapData.data[z, x] == SWORD)
                {
                    GameObject o = (GameObject)Instantiate(m_itemObject[0], bpos, Quaternion.identity);
                    o.transform.parent = m_items.transform;
                }
            }
        }
        m_gemEmitter.particles = gemParticle;
    }
    /// <summary>
    /// This function is called by the trigger whenever
    /// this trigger has been TRIGGERED.
    /// </summary>
    /// <param name="current">
    /// The current value of the targeted controller.
    /// </param>
    /// <param name="previous">
    /// The previous value of the targeted controller.
    /// </param>
    /// <param name="difference">
    /// The value difference of the targeted controller.
    /// </param>
    /// <param name="adjustedDifference">
    /// The adjusted value difference of the targeted controller.
    /// This value is the difference value as if it took place over a
    /// certain time period, controlled by VisBaseController.mc_fTargetAdjustedDifferenceTime.  The
    /// default of this essientially indicates a frame rate of 60 fps to determine
    /// the adjusted difference.  This should be used for almost all difference
    /// calculations, as it is NOT frame rate dependent.
    /// </param>
    public override void OnTriggered(float current, float previous, float difference, float adjustedDifference)
    {
        ParticleEmitter particleEmitterComp = GetComponent <ParticleEmitter>();

        if (particleEmitterComp != null)
        {
            particleEmitterComp.Emit();
        }

#if !(UNITY_2_6 || UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_3 || UNITY_3_4)
        ParticleSystem particleSystemComp = GetComponent <ParticleSystem>();
        if (particleSystemComp != null)
        {
            particleSystemComp.Emit(emitCount);
        }
#endif
    }
Ejemplo n.º 24
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);
            if (Input.IsKeyDown(System.Windows.Forms.Keys.E))
            {
                //explosion.Emit();
                explosion2.Emit();

                /*var explosion2 = explosion.Clone() as ParticleEmitter;
                 * ParticleEmitter explosion = new ParticleFactory().Create("explosion") as ParticleEmitter;
                 * explosion.transform.SetPosition(new Vector2(500, 100));
                 *
                 * explosion2.transform.SetPosition(explosion2.transform.position + new Vector2(100, 100));
                 * explosion2.Emit();
                 * explosion.Emit();*/
            }
        }
Ejemplo n.º 25
0
    public void Detach()
    {
        // Fire
        GetComponent <Rigidbody>().AddForce((Camera.main.transform.forward * fireVelocity), ForceMode.VelocityChange);

        // Emit particles
        if (fireParticles != null)
        {
            fireParticles.worldVelocity = Camera.main.transform.forward * -10;
            fireParticles.Emit();
        }

        // Play sound
        if ((soundSource != null) && (fireClip != null))
        {
            soundSource.PlayOneShot(fireClip);
        }
    }
Ejemplo n.º 26
0
    private static int Emit(IntPtr L)
    {
        int num = LuaDLL.lua_gettop(L);

        if (num == 1)
        {
            ParticleEmitter particleEmitter = (ParticleEmitter)LuaScriptMgr.GetUnityObjectSelf(L, 1, "ParticleEmitter");
            particleEmitter.Emit();
            return(0);
        }
        if (num == 2)
        {
            ParticleEmitter particleEmitter2 = (ParticleEmitter)LuaScriptMgr.GetUnityObjectSelf(L, 1, "ParticleEmitter");
            int             count            = (int)LuaScriptMgr.GetNumber(L, 2);
            particleEmitter2.Emit(count);
            return(0);
        }
        if (num == 6)
        {
            ParticleEmitter particleEmitter3 = (ParticleEmitter)LuaScriptMgr.GetUnityObjectSelf(L, 1, "ParticleEmitter");
            Vector3         vector           = LuaScriptMgr.GetVector3(L, 2);
            Vector3         vector2          = LuaScriptMgr.GetVector3(L, 3);
            float           size             = (float)LuaScriptMgr.GetNumber(L, 4);
            float           energy           = (float)LuaScriptMgr.GetNumber(L, 5);
            Color           color            = LuaScriptMgr.GetColor(L, 6);
            particleEmitter3.Emit(vector, vector2, size, energy, color);
            return(0);
        }
        if (num == 8)
        {
            ParticleEmitter particleEmitter4 = (ParticleEmitter)LuaScriptMgr.GetUnityObjectSelf(L, 1, "ParticleEmitter");
            Vector3         vector3          = LuaScriptMgr.GetVector3(L, 2);
            Vector3         vector4          = LuaScriptMgr.GetVector3(L, 3);
            float           size2            = (float)LuaScriptMgr.GetNumber(L, 4);
            float           energy2          = (float)LuaScriptMgr.GetNumber(L, 5);
            Color           color2           = LuaScriptMgr.GetColor(L, 6);
            float           rotation         = (float)LuaScriptMgr.GetNumber(L, 7);
            float           angularVelocity  = (float)LuaScriptMgr.GetNumber(L, 8);
            particleEmitter4.Emit(vector3, vector4, size2, energy2, color2, rotation, angularVelocity);
            return(0);
        }
        LuaDLL.luaL_error(L, "invalid arguments to method: ParticleEmitter.Emit");
        return(0);
    }
Ejemplo n.º 27
0
    private void SpawnEffect()
    {
        Transform transform = UnityEngine.Object.Instantiate(this.particleEffect, base.transform.position, base.transform.rotation) as Transform;

        transform.parent = base.gameObject.transform;
        ParticleEmitter  component  = transform.GetComponent <ParticleEmitter>();
        ParticleAnimator component2 = component.transform.GetComponent <ParticleAnimator>();

        if (component2 != null)
        {
            component2.autodestruct = true;
        }
        component.Emit(this.numberOfArms * this.particlesPerArm);
        Particle[] particles = component.particles;
        float      num       = 6.28318548f / (float)this.numberOfArms;

        for (int i = 0; i < this.numberOfArms; i++)
        {
            float num2 = 0f;
            float f    = (float)i * num;
            for (int j = 0; j < this.particlesPerArm; j++)
            {
                int     num3     = i * this.particlesPerArm + j;
                float   num4     = this.originOffset + this.turnDistance * num2;
                Vector3 position = transform.localPosition;
                position.x += num4 * Mathf.Cos(num2);
                position.z += num4 * Mathf.Sin(num2);
                float x = position.x * Mathf.Cos(f) + position.z * Mathf.Sin(f);
                float z = -position.x * Mathf.Sin(f) + position.z * Mathf.Cos(f);
                position.x  = x;
                position.z  = z;
                position.y += (float)j * this.verticalTurnDistance;
                if (component.useWorldSpace)
                {
                    position = base.transform.TransformPoint(position);
                }
                particles[num3].position = position;
                num2 += this.particleSeparation;
                particles[num3].energy = particles[num3].energy - (float)j * this.fadeValue;
                particles[num3].size   = particles[num3].size - (float)j * this.sizeValue;
            }
        }
        component.particles = particles;
    }
Ejemplo n.º 28
0
    // private bool isSpawned = false;

    /* ------------------------------------------------------------------------------------------------------
     *  -- SpawnRing --
     *
     *  This function spawns a new particle effect system each time it's called.  The system
     *  spawned is the prefab referenced by the public ringEffect variable.
     * ------------------------------------------------------------------------------------------------------- */
    private void SpawnRing()
    {
        // Instantiate the effect prefab.
        GameObject effectObject = ((Transform)Instantiate(ringEffect.transform, this.transform.position, this.transform.rotation)).gameObject;

        // Parent the new effect to this script's transform.
        effectObject.transform.parent = this.gameObject.transform;

        // Get the particle emitter from the new effect object.
        ParticleEmitter emitter = effectObject.particleEmitter;

        // Generate the particles.
        emitter.Emit();

        // Extract the particles from the created emitter.  Notice that we copy the particles into a new javascript array.
        // According to the Unity docs example this shouldn't be necessary, but I couldn't get it to work otherwise.
        // Below, when the updated p array is reassigned to the emitter particle array, the assignment failed when p was
        // simply assigned the value "emitter.particles".
        Particle[] p = new Particle[emitter.particles.Length];

        // Loop thru the particles, giving each an initial position and velocity.
        for (var i = 0; i < p.Length; i++)
        {
            p[i] = emitter.particles[i];
            // Generate a random unit vector in the plane defined by our transform's red axis centered around the
            // transform's green axis.  This vector serves as the basis for the initial position and velocity of the particle.
            Vector3 ruv = RandomUnitVectorInPlane(effectObject.transform, effectObject.transform.up);

            // Calc the initial position of the particle accounting for the specified ring radii.  Note the use of Range
            // to get a random distance distribution within the ring.
            Vector3 newPos = effectObject.transform.position
                             + ((ruv * innerRadius) + (ruv * Random.Range(innerRadius, outerRadius)));
            p[i].position        = newPos; //emitter.particles[i].position;
            p[i].angularVelocity = Random.Range(30f, 60f);

            // The velocity vector is simply the unit vector modified by the speed.  The velocity vector is used by the
            // Particle Animator component to move the particles.
            p[i].velocity = ruv * speed; //emitter.particles[i].velocity;
        }
        // Update the actual particles.
        emitter.particles     = p;
        emitter.worldVelocity = new Vector3(0f, Random.Range(10f, 20f), 0);
    }
Ejemplo n.º 29
0
        public override void Update(float deltaTime)
        {
            Vector2 pos = this.Entity.Position;


            float xSpd = _input.GetLeftStick().X;
            float ySpd = _input.GetLeftStick().Y;

            pos.X += xSpd * (_pxPerSecond * deltaTime);
            pos.Y += ySpd * (_pxPerSecond * deltaTime);

            this.Entity.Position = pos;
            this.Entity.Scene.MainCamera.Position = pos;

            if (_input.IsButtonPressed(Buttons.A))
            {
                _emitter.Emit();
            }
        }
Ejemplo n.º 30
0
    public void CreateSomeStars(Vector3 pos, float size, float energy)
    {
        for (int i = 0; i < 7; i++)
        {
            sparkleFall1Instance.Emit(
                pos,
                new Vector3(Random.Range(-10f, 10f), Random.Range(4f, 10f), Random.Range(-10f, 10f)),
                size * Random.Range(0.8f, 1.2f),
                1.5f + Random.Range(-.4f, .4f),
                new Color(1, 0, 1));

            sparkleFall2Instance.Emit(
                pos,
                new Vector3(Random.Range(-10f, 10f), 2 + Random.Range(-1f, 1f), Random.Range(-10f, 10f)),
                size * Random.Range(0.8f, 1.2f),
                energy + Random.Range(-.4f, .4f),
                new Color(1, 0, 1));
        }
    }