예제 #1
0
        protected void SetLastGameObject(int touchIndex, GameObject gameObject)
        {
            Entity entity = null;
            Planet planet = null;

            if (gameObject != null)
            {
                EntityRef component = gameObject.GetComponent <EntityRef>();
                if (component != null)
                {
                    entity = component.Entity;
                }
                else
                {
                    PlanetRef component2 = gameObject.GetComponent <PlanetRef>();
                    if (component2 != null)
                    {
                        planet = component2.Planet;
                    }
                }
            }
            this.lastPlanet[touchIndex] = planet;
            this.lastEntity[touchIndex] = entity;
        }
        private void OnPlanetLoaded(object asset, object cookie)
        {
            if (Service.Get <ScreenController>().IsFatalAlertActive())
            {
                return;
            }
            MainCamera    mainCamera         = Service.Get <CameraManager>().MainCamera;
            CurrentPlayer currentPlayer      = Service.Get <CurrentPlayer>();
            AssetManager  assetManager       = Service.Get <AssetManager>();
            AssetHandle   eventEffectsHandle = AssetHandle.Invalid;
            AssetHandle   particleFXHandle   = AssetHandle.Invalid;
            AssetHandle   planetGlowHandle   = AssetHandle.Invalid;
            Planet        planet             = (Planet)cookie;
            GameObject    gameObject         = (GameObject)asset;

            planet.PlanetGameObject = gameObject;
            Transform transform = gameObject.transform;

            transform.position    = this.GetPlanetVect3Position(planet.VO.Angle, planet.VO.Radius, -planet.VO.HeightOffset);
            planet.planetMaterial = PlanetUtils.GetPlanetMaterial(gameObject);
            Bounds gameObjectLocalBounds = UnityUtils.GetGameObjectLocalBounds(gameObject, false);

            planet.ObjectExtents = gameObjectLocalBounds.extents;
            PlanetRef planetRef = gameObject.AddComponent <PlanetRef>();

            planetRef.Planet = planet;
            BoxCollider boxCollider = gameObject.AddComponent <BoxCollider>();

            boxCollider.size = gameObjectLocalBounds.size;
            Service.Get <UXController>().MiscElementsManager.CreatePlanetBackgroundUI(planet);
            planet.planetMaterial = PlanetUtils.GetPlanetMaterial(gameObject);
            if (!currentPlayer.IsPlanetUnlocked(planet.VO.Uid))
            {
                Service.Get <UXController>().MiscElementsManager.CreatePlanetLockedUI(planet);
                planet.planetMaterial.SetFloat("_Bright", 0.35f);
            }
            assetManager.Load(ref planetGlowHandle, "fx_planetGlow", new AssetSuccessDelegate(this.OnPlanetGlowEffectLoaded), null, planet);
            planet.PlanetGlowHandle = planetGlowHandle;
            string text = "";

            if (currentPlayer.Faction == FactionType.Empire)
            {
                text = "tiefighterplanet_emp-ani";
            }
            else if (currentPlayer.Faction == FactionType.Rebel)
            {
                text = "xwingplanet_rbl-ani";
            }
            if (!string.IsNullOrEmpty(text))
            {
                assetManager.Load(ref eventEffectsHandle, text, new AssetSuccessDelegate(this.OnEventEffectsLoaded), new AssetFailureDelegate(this.OnEffectLoadFailed), planet);
            }
            if (this.DoesPlanetHaveEvent(planet))
            {
                TimedEventState tournamentState = planet.TournamentState;
                if (tournamentState != TimedEventState.Upcoming)
                {
                    if (tournamentState == TimedEventState.Live)
                    {
                        assetManager.Load(ref particleFXHandle, "fx_planet_Conflict", new AssetSuccessDelegate(this.OnEventParticleFXLoaded), new AssetFailureDelegate(this.OnParticleFXLoadFailed), planet);
                    }
                }
                else
                {
                    assetManager.Load(ref particleFXHandle, "fx_planet_Imminent", new AssetSuccessDelegate(this.OnEventParticleFXLoaded), new AssetFailureDelegate(this.OnParticleFXLoadFailed), planet);
                }
            }
            planet.EventEffectsHandle = eventEffectsHandle;
            planet.ParticleFXHandle   = particleFXHandle;
            transform.LookAt(mainCamera.Camera.transform.position);
        }