示例#1
0
        IEnumerator AttackOverTime()
        {
            TalkAudio.clip = AttackClip;
            TalkAudio.Play();

            ScanAudio.Play();

            for (int i = 0; i < Particles.Length; i++)
            {
                Particles [i].emissionRate = ElevatedEmissionRate;
                Particles [i].startSpeed   = ElevatedEmissionSpeed;
            }

            if (mPowerBeam == null)
            {
                mPowerBeam = (GameObject.Instantiate(BeamPrefab.gameObject, HeadPivot.position, HeadPivot.rotation) as GameObject).GetComponent <PowerBeam> ();
            }
            mEffectSphere = (GameObject.Instantiate(EffectSpherePrefab.gameObject) as GameObject).GetComponent <MagicEffectSphere> ();
            mEffectSphere.transform.position = AttackTarget.position;
            mEffectSphere.RTExpansionTime    = 3f;
            mEffectSphere.RTDuration         = 10f;
            mEffectSphere.RTCooldownTime     = 3f;

            mPowerBeam.WarmUpColor = Color.yellow;
            mPowerBeam.FireColor   = Color.yellow;
            mPowerBeam.AttachTo(HeadPivot, AttackTarget);
            mPowerBeam.WarmUp();
            mPowerBeam.Fire(5f);

            yield return(new WaitForSeconds(3f));

            for (int i = 0; i < Particles.Length; i++)
            {
                Particles [i].emissionRate = NormalEmissionRate;
                Particles [i].startSpeed   = NormalEmissionSpeed;
            }

            mPowerBeam.StopFiring();

            while (mEffectSphere != null && !mEffectSphere.Depleted)
            {
                yield return(null);
            }

            GameObject.Destroy(mEffectSphere.gameObject);

            Attacking = false;
            yield break;
        }
示例#2
0
        protected IEnumerator FireBeamsAtExplosions(List <FXPiece> explosions)
        {
            if (explosions == null)
            {
                Debug.Log("Explosions were null in destroy player home.");
                yield break;
            }
            //start the beam firing
            Beam.AttachTo(BeamOrigin, BeamTarget);
            Beam.Fire(1000f);
            bool    finishedFiring   = false;
            FXPiece currentExplosion = new FXPiece();

            currentExplosion.TimeAdded = Mathf.Infinity;
            double start;

            while (!finishedFiring)
            {
                finishedFiring = true;
                //go through each explosion (they're in no particular order)
                //find all explosions that haven't happened yet
                //choose the explosion that's closest to the current time

                for (int i = 0; i < explosions.Count; i++)
                {
                    FXPiece explosion = explosions [i];
                    if (WorldClock.AdjustedRealTime > explosion.TimeAdded + explosion.Delay)
                    {
                        //this explosion hasn't elapsed
                        //we're also not done firing
                        if (explosion.TimeAdded + explosion.Delay < currentExplosion.TimeAdded + currentExplosion.Delay)
                        {
                            //this explosion happens before the current explosion
                            currentExplosion = explosion;
                        }
                    }
                    else
                    {
                        //we still have more explosions to blow up
                        finishedFiring = false;
                    }
                }
                //aim the beam at that spot
                BeamTarget.position = TargetStructure.StructureBase.transform.position + currentExplosion.Position;
                start = WorldClock.AdjustedRealTime;
                while (WorldClock.AdjustedRealTime < start + 0.05f)
                {
                    yield return(null);
                }
            }
            //wait a sec for the last explosion
            start = WorldClock.AdjustedRealTime;
            while (WorldClock.AdjustedRealTime < start + 1.5f)
            {
                yield return(null);
            }
            //we're done firing - power down the beam
            Beam.StopFiring();
            //it will destroy itself
            mPrimaryTarget = null;
            Beam.RequiresOriginAndTarget = true;
            yield break;
        }