Пример #1
0
 public void Cleanup()
 {
     if (this.loadedAssets)
     {
         if (this.effectObj != null)
         {
             UnityEngine.Object.Destroy(this.effectObj);
         }
         UnityUtils.DestroyMaterial(this.troopCardMaterial);
         AssetManager assetManager = Service.Get <AssetManager>();
         if (this.effectHandle != AssetHandle.Invalid)
         {
             assetManager.Unload(this.effectHandle);
             this.effectHandle = AssetHandle.Invalid;
         }
         if (this.troopHandle != AssetHandle.Invalid)
         {
             assetManager.Unload(this.troopHandle);
             this.troopHandle = AssetHandle.Invalid;
         }
     }
     if (this.shuttle == null)
     {
         Service.Get <EventManager>().UnregisterObserver(this, EventId.ShuttleAnimStateChanged);
     }
     else
     {
         this.shuttle = null;
     }
     if (this.timerId != 0u)
     {
         Service.Get <ViewTimerManager>().KillViewTimer(this.timerId);
     }
     else
     {
         this.timerId = 0u;
     }
     if (this.animPosition != null)
     {
         Service.Get <AnimController>().CompleteAndRemoveAnim(this.animPosition);
     }
     this.troopVO           = null;
     this.troopEntity       = null;
     this.starportEntity    = null;
     this.entityFader       = null;
     this.onFinished        = null;
     this.effectObj         = null;
     this.troopCardPS       = null;
     this.shuttleGlowPS     = null;
     this.troopCardTexture  = null;
     this.troopCardMaterial = null;
     this.animPosition      = null;
     this.showFullEffect    = false;
     this.pathReached       = false;
     Service.Get <EventManager>().UnregisterObserver(this, EventId.TroopViewReady);
     Service.Get <EventManager>().UnregisterObserver(this, EventId.BuildingMovedOnBoard);
     Service.Get <EventManager>().UnregisterObserver(this, EventId.BuildingReplaced);
 }
Пример #2
0
        public TransportTroopEffect(Entity troopEntity, TroopTypeVO troopVO, Entity starportEntity, ViewFader entityFader, TransportTroopEffect.OnEffectFinished onFinished, bool showFullEffect)
        {
            this.troopVO        = troopVO;
            this.troopEntity    = troopEntity;
            this.starportEntity = starportEntity;
            this.entityFader    = entityFader;
            this.onFinished     = onFinished;
            this.showFullEffect = showFullEffect;
            if (showFullEffect)
            {
                TextureVO optional = Service.Get <IDataController>().GetOptional <TextureVO>("unittransport_event_troop_" + troopVO.TroopID);
                if (optional != null)
                {
                    GeometryTag geometryTag = new GeometryTag(troopVO, optional.AssetName);
                    Service.Get <EventManager>().SendEvent(EventId.TextureCreated, geometryTag);
                    AssetManager assetManager = Service.Get <AssetManager>();
                    assetManager.Load(ref this.troopHandle, geometryTag.assetName, new AssetSuccessDelegate(this.OnTroopCardLoaded), new AssetFailureDelegate(this.OnTroopCardLoadFailed), null);
                    assetManager.Load(ref this.effectHandle, "troop_card_spawn", new AssetSuccessDelegate(this.OnEffectLoaded), new AssetFailureDelegate(this.OnEffectLoadFailed), null);
                    this.loadedAssets = true;
                }
                else
                {
                    Service.Get <StaRTSLogger>().WarnFormat("Transport troop effect error: {0} not found in TextureData", new object[]
                    {
                        "unittransport_event_troop_" + troopVO.TroopID
                    });
                    this.showFullEffect = false;
                }
            }
            ShuttleAnim shuttleForStarport = Service.Get <ShuttleController>().GetShuttleForStarport(starportEntity);

            if (shuttleForStarport != null && shuttleForStarport.State == ShuttleState.Idle)
            {
                this.shuttle = shuttleForStarport;
            }
            else
            {
                Service.Get <EventManager>().RegisterObserver(this, EventId.ShuttleAnimStateChanged, EventPriority.Default);
            }
            Service.Get <EventManager>().RegisterObserver(this, EventId.BuildingMovedOnBoard, EventPriority.Default);
            Service.Get <EventManager>().RegisterObserver(this, EventId.BuildingReplaced, EventPriority.Default);
            this.timerId     = 0u;
            this.pathReached = false;
        }