Ejemplo n.º 1
0
 private void RemoveEmittersForEntity(SmartEntity smartEntity)
 {
     if (smartEntity != null && this.associatedEmitterEntitySet.Contains(smartEntity))
     {
         List <GameObject> list = new List <GameObject>();
         foreach (KeyValuePair <GameObject, SmartEntity> current in this.emitterGameObjectToEntity)
         {
             if (current.get_Value() == smartEntity)
             {
                 GameObject key = current.get_Key();
                 if (key != null)
                 {
                     Service.Get <DerivedTransformationManager>().RemoveDerivedTransformation(key);
                     MultipleEmittersPool.StopChildEmitters(key);
                     list.Add(key);
                 }
                 else
                 {
                     Service.Get <StaRTSLogger>().Error("ProjectileViewManager: Emitter objects are being destroyed");
                 }
             }
         }
         int i     = 0;
         int count = list.Count;
         while (i < count)
         {
             this.emitterGameObjectToEntity.Remove(list[i]);
             i++;
         }
         this.associatedEmitterEntitySet.Remove(smartEntity);
     }
 }
Ejemplo n.º 2
0
        public static void StaticReset()
        {
            Camera[] allCameras = Camera.allCameras;
            int      i          = 0;
            int      num        = allCameras.Length;

            while (i < num)
            {
                allCameras[i].enabled = false;
                i++;
            }
            UnityUtils.StaticReset();
            GameServicesManager.StaticReset();
            MultipleEmittersPool.StaticReset();
            if (Service.IsSet <AudioManager>())
            {
                Service.Get <AudioManager>().CleanUp();
            }
            if (Service.IsSet <WWWManager>())
            {
                Service.Get <WWWManager>().CancelAll();
            }
            if (Service.IsSet <AssetManager>())
            {
                Service.Get <AssetManager>().ReleaseAll();
            }
            if (Service.IsSet <EntityController>())
            {
                Service.Get <EntityController>().StaticReset();
            }
            if (Service.IsSet <IDataController>())
            {
                Service.Get <IDataController>().Exterminate();
            }
            if (Service.IsSet <ISocialDataController>())
            {
                Service.Get <ISocialDataController>().StaticReset();
            }
            JsonParser.StaticReset();
            CollisionFilters.StaticReset();
            ProcessingScreen.StaticReset();
            YesNoScreen.StaticReset();
            DynamicRadiusView.StaticReset();
            if (Service.IsSet <Lang>())
            {
                Service.Get <Lang>().CustomKoreanFont = null;
            }
        }
Ejemplo n.º 3
0
 private void InitMultipleEmitterTracker(GameObject rootNode)
 {
     this.root                    = rootNode;
     this.EmitterTracker          = rootNode.transform;
     this.EmitterTracker.position = this.StartLocation;
     this.EmitterTracker.LookAt(this.TargetLocation);
     this.isMultipleEmitter = true;
     this.root.SetActive(true);
     ParticleSystem[] allEmitters = MultipleEmittersPool.GetAllEmitters(this.root);
     ParticleSystem[] array       = allEmitters;
     for (int i = 0; i < array.Length; i++)
     {
         ParticleSystem particle = array[i];
         this.PlayEmitter(particle);
         this.PlayTrails(particle);
     }
 }
Ejemplo n.º 4
0
 public void Reset()
 {
     if (this.DefaultTrackerObject != null)
     {
         this.DefaultTracker.DetachChildren();
         this.DefaultTracker = null;
         UnityEngine.Object.Destroy(this.DefaultTrackerObject);
         this.DefaultTrackerObject = null;
     }
     this.ResetParticle(this.Emitter);
     if (this.root != null)
     {
         ParticleSystem[] allEmitters = MultipleEmittersPool.GetAllEmitters(this.root);
         ParticleSystem[] array       = allEmitters;
         for (int i = 0; i < array.Length; i++)
         {
             ParticleSystem particle = array[i];
             this.ResetParticle(particle);
         }
     }
     if (this.MeshTracker != null && this.MeshTracker.gameObject != null)
     {
         this.MeshTracker.gameObject.SetActive(false);
     }
     if (this.MeshTracker != null)
     {
         this.MeshTracker.DetachChildren();
     }
     if (this.EmitterTracker != null)
     {
         if (this.isMultipleEmitter)
         {
             this.root.SetActive(false);
         }
         else
         {
             this.EmitterTracker.DetachChildren();
         }
     }
     this.root = null;
 }
Ejemplo n.º 5
0
        private void ShowImpactFXForView(ProjectileView view, string assetName)
        {
            EmitterPool emitter = this.GetEmitter(assetName);

            if (emitter == null)
            {
                return;
            }
            Vector3 vector = view.TargetLocation;

            if (view.TargetTracker != null)
            {
                vector = view.TargetTracker.position;
            }
            else if (view.MeshTracker != null)
            {
                vector = view.MeshTracker.position;
            }
            bool directional = view.ProjectileType.Directional;
            bool seeksTarget = view.ProjectileType.SeeksTarget;

            if (directional)
            {
                Vector3 a = view.StartLocation - vector;
                a.Normalize();
                vector += a * 0.2f;
            }
            if (emitter is MultipleEmittersPool)
            {
                MultipleEmittersPool multipleEmittersPool = (MultipleEmittersPool)emitter;
                GameObject           emitterRoot          = multipleEmittersPool.GetEmitterRoot();
                float num = 0f;
                if (emitterRoot != null)
                {
                    emitterRoot.SetActive(true);
                    ParticleSystem[] allEmitters = MultipleEmittersPool.GetAllEmitters(emitterRoot);
                    Transform        transform   = emitterRoot.transform;
                    transform.position = vector;
                    if (directional)
                    {
                        transform.LookAt(view.StartLocation);
                    }
                    ParticleSystem[] array = allEmitters;
                    for (int i = 0; i < array.Length; i++)
                    {
                        ParticleSystem particleSystem = array[i];
                        if (particleSystem.duration > num)
                        {
                            num = particleSystem.duration;
                        }
                        this.PlayParticle(particleSystem);
                    }
                    if (seeksTarget && view.Bullet.Target != null && view.Bullet.Target.GameObjectViewComp != null && !GameUtils.IsEntityDead(view.Bullet.Target))
                    {
                        SmartEntity target         = view.Bullet.Target;
                        Vector3     positionOffset = emitterRoot.transform.position - target.GameObjectViewComp.MainTransform.position;
                        DerivedTransformationObject derivedTransformationObject = new DerivedTransformationObject(target.GameObjectViewComp.MainGameObject, positionOffset, false);
                        Service.Get <DerivedTransformationManager>().AddDerivedTransformation(emitterRoot, derivedTransformationObject);
                        this.AssociateEntityWithEmitterObject(target, emitterRoot);
                    }
                    multipleEmittersPool.StopEmissionAndReturnToPool(emitterRoot, num, 0f);
                    return;
                }
            }
            else if (emitter is SingleEmitterPool)
            {
                SingleEmitterPool singleEmitterPool = (SingleEmitterPool)emitter;
                ParticleSystem    emitter2          = singleEmitterPool.GetEmitter();
                if (emitter2 != null)
                {
                    if (directional)
                    {
                        this.PlayParticleLookingAt(emitter2, vector, view.StartLocation);
                    }
                    else
                    {
                        this.PlayParticleAt(emitter2, vector);
                    }
                    singleEmitterPool.StopEmissionAndReturnToPool(emitter2, emitter2.startLifetime, 0f);
                }
            }
        }
Ejemplo n.º 6
0
        private void StartDirectionalEmitter(SmartEntity owner, GameObject gunLocator, Vector3 startLocation, Vector3 endLocation, string assetName, float fadeTime)
        {
            EmitterPool emitter = this.GetEmitter(assetName);

            if (emitter != null)
            {
                if (emitter is MultipleEmittersPool)
                {
                    MultipleEmittersPool multipleEmittersPool = (MultipleEmittersPool)emitter;
                    GameObject           emitterRoot          = multipleEmittersPool.GetEmitterRoot();
                    float num = 0f;
                    if (emitterRoot != null)
                    {
                        ParticleSystem[] allEmitters = MultipleEmittersPool.GetAllEmitters(emitterRoot);
                        Transform        transform   = emitterRoot.transform;
                        transform.position = startLocation;
                        if (gunLocator != null)
                        {
                            DerivedTransformationObject derivedTransformationObject = new DerivedTransformationObject(gunLocator, Vector3.zero, true);
                            Service.Get <DerivedTransformationManager>().AddDerivedTransformation(emitterRoot, derivedTransformationObject);
                            this.AssociateEntityWithEmitterObject(owner, emitterRoot);
                        }
                        else
                        {
                            GameObjectViewComponent gameObjectViewComponent = null;
                            if (owner != null)
                            {
                                gameObjectViewComponent = owner.GameObjectViewComp;
                            }
                            if (gameObjectViewComponent == null)
                            {
                                transform.LookAt(endLocation);
                            }
                            else
                            {
                                transform.rotation = gameObjectViewComponent.MainTransform.rotation;
                            }
                        }
                        emitterRoot.SetActive(true);
                        ParticleSystem[] array = allEmitters;
                        for (int i = 0; i < array.Length; i++)
                        {
                            ParticleSystem particleSystem = array[i];
                            if (particleSystem != null)
                            {
                                if (particleSystem.duration > num)
                                {
                                    num = particleSystem.duration;
                                }
                                this.PlayParticle(particleSystem);
                            }
                        }
                        multipleEmittersPool.StopEmissionAndReturnToPool(emitterRoot, num, fadeTime);
                        return;
                    }
                }
                else if (emitter is SingleEmitterPool)
                {
                    SingleEmitterPool singleEmitterPool = (SingleEmitterPool)emitter;
                    ParticleSystem    emitter2          = singleEmitterPool.GetEmitter();
                    if (emitter2 != null)
                    {
                        this.PlayParticleAt(emitter2, startLocation);
                        singleEmitterPool.StopEmissionAndReturnToPool(emitter2, emitter2.startLifetime, fadeTime);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private ProjectileView SpawnProjectile(Bullet bullet, bool isOnGround)
        {
            if (!ProjectileUtils.AreAllBulletAssetsLoaded(bullet, this.loadedAssets))
            {
                this.LoadBulletAssets(bullet);
                if (bullet.ProjectileType != null)
                {
                    Service.Get <StaRTSLogger>().Warn("Loading assets on demand for projectile " + bullet.ProjectileType.Uid);
                }
            }
            bool             isDeflection   = bullet.IsDeflection;
            ProjectileTypeVO projectileType = bullet.ProjectileType;
            GameObject       gunLocator     = bullet.GunLocator;
            Vector3          vector;

            if (!isDeflection && gunLocator != null)
            {
                vector = gunLocator.transform.position;
            }
            else
            {
                vector = bullet.SpawnWorldLocation;
            }
            Vector3 targetWorldLocation = bullet.TargetWorldLocation;

            if (isOnGround)
            {
                vector.y = 0f;
                targetWorldLocation.y = 0f;
            }
            else if (projectileType.IsBeam || (bullet.Owner != null && bullet.Target != null && bullet.Target.ShieldBorderComp != null))
            {
                targetWorldLocation.y = vector.y;
            }
            ProjectileView projectileView = (this.projectilePool.Count > 0) ? this.projectilePool.Pop() : new ProjectileView();

            projectileView.Init(projectileType, bullet, isOnGround);
            if (!isDeflection && !string.IsNullOrEmpty(projectileType.MuzzleFlashAssetName))
            {
                this.StartDirectionalEmitter(bullet.Owner, gunLocator, vector, targetWorldLocation, projectileType.MuzzleFlashAssetName, projectileType.MuzzleFlashFadeTime);
                int num = 0;
                if (bullet.AppliedBuffs != null)
                {
                    num = bullet.AppliedBuffs.Count;
                }
                FactionType ownerFaction = bullet.OwnerFaction;
                for (int i = 0; i < num; i++)
                {
                    string muzzleAssetNameBasedOnFaction = bullet.AppliedBuffs[i].BuffType.GetMuzzleAssetNameBasedOnFaction(ownerFaction);
                    if (!string.IsNullOrEmpty(muzzleAssetNameBasedOnFaction))
                    {
                        this.StartDirectionalEmitter(bullet.Owner, gunLocator, vector, targetWorldLocation, muzzleAssetNameBasedOnFaction, projectileType.MuzzleFlashFadeTime);
                    }
                }
            }
            GameObject     gameObject      = null;
            float          num2            = bullet.TravelTime / 1000f;
            GameObject     gameObject2     = null;
            ParticleSystem particleSystem  = null;
            string         bulletAssetName = projectileType.GetBulletAssetName(isOnGround);
            EmitterPool    emitter         = this.GetEmitter(bulletAssetName);

            if (emitter != null)
            {
                float num3 = num2;
                float delayPostEmitterStop = 0f;
                if (projectileType.IsBeam)
                {
                    num3 = num2 * (float)(projectileType.BeamEmitterLength - projectileType.BeamInitialZeroes) / (float)(projectileType.BeamLifeLength - projectileType.BeamInitialZeroes);
                    delayPostEmitterStop = num2 - num3;
                }
                if (emitter is MultipleEmittersPool)
                {
                    MultipleEmittersPool multipleEmittersPool = (MultipleEmittersPool)emitter;
                    gameObject = multipleEmittersPool.GetEmitterRoot();
                    if (gameObject != null)
                    {
                        multipleEmittersPool.StopEmissionAndReturnToPool(gameObject, num3, delayPostEmitterStop);
                    }
                }
                else if (emitter is SingleEmitterPool)
                {
                    SingleEmitterPool singleEmitterPool = (SingleEmitterPool)emitter;
                    particleSystem = singleEmitterPool.GetEmitter();
                    if (particleSystem != null)
                    {
                        singleEmitterPool.StopEmissionAndReturnToPool(particleSystem, num3, delayPostEmitterStop);
                    }
                }
                if (this.meshes.ContainsKey(bulletAssetName))
                {
                    gameObject2 = this.meshes[bulletAssetName].GetMesh();
                }
            }
            Transform targetTransform = this.GetTargetTransform(bullet, vector, targetWorldLocation);

            if (gameObject2 != null && particleSystem != null)
            {
                projectileView.InitWithMeshAndEmitter(num2, vector, targetWorldLocation, gameObject2, particleSystem, targetTransform);
            }
            else if (gameObject2 != null && gameObject == null)
            {
                projectileView.InitWithMesh(num2, vector, targetWorldLocation, gameObject2, targetTransform);
            }
            else if (particleSystem != null)
            {
                projectileView.InitWithEmitter(num2, vector, targetWorldLocation, particleSystem, targetTransform);
            }
            else if (gameObject != null)
            {
                projectileView.InitWithEmitters(num2, vector, targetWorldLocation, gameObject, gameObject2, targetTransform);
            }
            else
            {
                projectileView.InitWithoutBullet(num2, vector, targetWorldLocation, targetTransform);
            }
            this.activeProjectiles.Add(projectileView);
            if (!isOnGround && !string.IsNullOrEmpty(projectileType.GroundBulletAssetName))
            {
                this.SpawnProjectile(bullet, true);
            }
            return(projectileView);
        }