public TransportController()
        {
            this.TRANSPORT_SHIP_EMPIRE = "ThetaClassBarge1";
            this.TRANSPORT_SHIP_REBEL  = "Cr25transport1";
            base..ctor();
            this.entityController = Service.Get <EntityController>();
            this.sdc         = Service.Get <IDataController>();
            this.fxManager   = Service.Get <FXManager>();
            this.entityFader = new ViewFader();
            Service.Set <TransportController>(this);
            EventManager eventManager = Service.Get <EventManager>();

            eventManager.RegisterObserver(this, EventId.TroopRecruited, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.ContractStarted, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.ContractContinued, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.ContractCanceled, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.TroopReachedPathEnd, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.WorldReset, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.BuildingReplaced, EventPriority.Default);
            this.landingFxHandles = new Dictionary <int, AssetHandle>();
            this.takeOffFxHandles = new Dictionary <int, AssetHandle>();
            this.landingFxObjects = new Dictionary <int, GameObject>();
            this.takeOffFxObjects = new Dictionary <int, GameObject>();
            this.busyEntities     = new Dictionary <Entity, TroopTypeVO>();
        }
 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);
 }
示例#3
0
        private void OnEntityFadeComplete(object fadedObject)
        {
            BuildingType type = this.buildingToRemove.Get <BuildingComponent>().BuildingType.Type;

            Service.Get <EntityFactory>().DestroyEntity(this.buildingToRemove, true, false);
            Service.Get <EventManager>().SendEvent(EventId.PostBuildingEntityKilled, type);
            this.buildingToRemove = null;
            this.fader            = null;
            this.parent.ChildComplete(this);
        }
示例#4
0
 public SpecialAttackController()
 {
     Service.SpecialAttackController = this;
     this.specialAttacksDeployed     = new Queue <SpecialAttack>();
     this.specialAttacksExpended     = new List <SpecialAttack>();
     this.projectilesInFlight        = new Dictionary <ProjectileTypeVO, int>();
     this.preloadedAssets            = new Dictionary <string, AssetHandle>();
     this.preloadAssetPool           = new List <GameObject>();
     this.events          = Service.EventManager;
     this.simTimers       = new List <uint>();
     this.viewTimers      = new List <uint>();
     this.viewObjectFader = new ViewFader();
     this.Reset();
 }
        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;
        }
示例#6
0
        public TransportController()
        {
            this.entityController = Service.EntityController;
            this.sdc                    = Service.StaticDataController;
            this.fxManager              = Service.FXManager;
            this.entityFader            = new ViewFader();
            Service.TransportController = this;
            EventManager eventManager = Service.EventManager;

            eventManager.RegisterObserver(this, EventId.TroopRecruited, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.ContractStarted, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.ContractContinued, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.ContractCanceled, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.TroopReachedPathEnd, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.WorldReset, EventPriority.Default);
            eventManager.RegisterObserver(this, EventId.BuildingReplaced, EventPriority.Default);
            this.landingFxHandles = new Dictionary <int, AssetHandle>();
            this.takeOffFxHandles = new Dictionary <int, AssetHandle>();
            this.landingFxObjects = new Dictionary <int, GameObject>();
            this.takeOffFxObjects = new Dictionary <int, GameObject>();
            this.busyEntities     = new Dictionary <Entity, TroopTypeVO>();
        }
示例#7
0
        public override void Execute()
        {
            base.Execute();
            BoardCell <Entity> cellAt = Service.Get <BoardController>().Board.GetCellAt(this.boardX, this.boardZ);

            if (cellAt == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Story {0} is attempting to remove a building at {1}, {2}, but there is no cell.", new object[]
                {
                    this.vo.Uid,
                    this.boardX,
                    this.boardZ
                });
                this.parent.ChildComplete(this);
                return;
            }
            if (cellAt.Children == null)
            {
                return;
            }
            this.buildingToRemove = null;
            for (LinkedListNode <BoardItem <Entity> > linkedListNode = cellAt.Children.First; linkedListNode != null; linkedListNode = linkedListNode.Next)
            {
                Entity            data = linkedListNode.Value.Data;
                BuildingComponent buildingComponent = data.Get <BuildingComponent>();
                if (buildingComponent != null)
                {
                    this.buildingToRemove = data;
                    break;
                }
            }
            if (this.buildingToRemove != null)
            {
                this.fader = new ViewFader();
                this.fader.FadeOut(this.buildingToRemove, 0f, 1f, null, new FadingDelegate(this.OnEntityFadeComplete));
                Service.Get <EventManager>().SendEvent(EventId.BuildingRemovedFromBoard, this.buildingToRemove);
            }
        }
示例#8
0
 public HealthController()
 {
     Service.Set <HealthController>(this);
     this.entityFader = new ViewFader();
     Service.Get <EventManager>().RegisterObserver(this, EventId.ProcBuff, EventPriority.Default);
 }
示例#9
0
 public HealthController()
 {
     Service.HealthController = this;
     this.entityFader         = new ViewFader();
     Service.EventManager.RegisterObserver(this, EventId.ProcBuff, EventPriority.Default);
 }