예제 #1
0
        private void DeployTroopGroup(int index, TroopTypeVO troop, DefenseTroopGroup group)
        {
            int degrees = group.Direction;

            if (group.Quantity > 1)
            {
                degrees = group.Direction + group.Spread * index / (group.Quantity - 1) - group.Spread / 2;
            }
            int locX = 0;
            int locZ = 0;

            DefensiveBattleController.GetBoardEdge(degrees, group.Range, out locX, out locZ);
            IntPosition nearestValidBoardPosition = this.GetNearestValidBoardPosition(locX, locZ);
            bool        sendPlacedEvent           = index == 0;
            Entity      entity = this.troopController.SpawnTroop(troop, TeamType.Attacker, nearestValidBoardPosition, TroopSpawnMode.Unleashed, sendPlacedEvent);

            if (entity != null)
            {
                if (!troop.IsHealer)
                {
                    this.waves[this.currentWaveIndex].Troops.Add(entity);
                }
                Service.BattleController.OnTroopDeployed(troop.Uid, TeamType.Attacker, nearestValidBoardPosition);
                Service.EventManager.SendEvent(EventId.TroopDeployed, entity);
            }
        }
예제 #2
0
        private void DeployNextWave(uint id, object cookie)
        {
            this.timers.Remove(id);
            this.currentWaveIndex    = this.wavesDeployed;
            this.currentWave         = this.waves[this.currentWaveIndex];
            this.waveDirectionOffset = ((!this.randomizeWaves) ? 0 : Service.Rand.SimRange(0, 360));
            List <DefenseTroopGroup> list = DefensiveBattleController.ParseTroopGroups(this.currentWave.Encounter.Uid, this.currentWave.Encounter.WaveGroup, this.waveDirectionOffset);
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                DefenseTroopGroup defenseTroopGroup = list[i];
                this.timers.Add(this.timerManager.CreateSimTimer(defenseTroopGroup.Seconds * 1000u, false, new TimerDelegate(this.DeployGroupAfterDelay), defenseTroopGroup));
            }
            this.wavesDeployed++;
        }
예제 #3
0
        public void StartDefenseMission(CampaignMissionVO mission)
        {
            if (this.activeDefenseBattle)
            {
                Service.Logger.WarnFormat("Mission {0} is already in progress.  Cannot start Mission {1}.", new object[]
                {
                    this.currentMission.Uid,
                    mission.Uid
                });
                return;
            }
            this.troopController     = Service.TroopController;
            this.eventManager        = Service.EventManager;
            this.activeDefenseBattle = true;
            this.autoMoveCamera      = false;
            this.currentMission      = mission;
            this.randomizeWaves      = !mission.FixedWaves;
            this.waves         = DefensiveBattleController.ParseWaves(this.currentMission.Waves);
            this.wavesDeployed = 0;
            this.waveCount     = this.waves.Count;
            this.AllWavesClear = false;
            if (mission.IsRaidDefense())
            {
                Service.RaidDefenseController.OnStartRaidDefenseMission();
            }
            this.eventManager.RegisterObserver(this, EventId.EntityKilled, EventPriority.BeforeDefault);
            this.eventManager.RegisterObserver(this, EventId.UserStartedCameraMove, EventPriority.Default);
            this.eventManager.RegisterObserver(this, EventId.CameraFinishedMoving, EventPriority.Default);
            this.eventManager.RegisterObserver(this, EventId.PreEntityKilled, EventPriority.Default);
            this.eventManager.RegisterObserver(this, EventId.EntityHit, EventPriority.Default);
            TrapViewController  trapViewController = Service.TrapViewController;
            NodeList <TrapNode> trapNodeList       = Service.BuildingLookupController.TrapNodeList;

            for (TrapNode trapNode = trapNodeList.Head; trapNode != null; trapNode = trapNode.Next)
            {
                trapViewController.UpdateTrapVisibility((SmartEntity)trapNode.Entity);
            }
            Vector3 zero = Vector3.zero;

            Service.WorldInitializer.View.ZoomTo(0.7f);
            Service.WorldInitializer.View.PanToLocation(zero);
            this.DeployNextWave(0u, null);
        }
        public void StartDefenseMissionAfterLoadingAssets(CampaignMissionVO mission)
        {
            DefenseWave defenseWave         = this.waves[this.currentWaveIndex];
            List <DefenseTroopGroup> list   = DefensiveBattleController.ParseTroopGroups(defenseWave.Encounter.Uid, defenseWave.Encounter.WaveGroup, 0);
            int                count        = list.Count;
            AssetManager       assetManager = Service.Get <AssetManager>();
            List <string>      list2        = new List <string>();
            List <object>      list3        = new List <object>();
            List <AssetHandle> list4        = new List <AssetHandle>();

            for (int i = 0; i < count; i++)
            {
                DefenseTroopGroup defenseTroopGroup = list[i];
                TroopTypeVO       troopTypeVO       = this.sdc.Get <TroopTypeVO>(defenseTroopGroup.TroopUid);
                list2.Add(troopTypeVO.AssetName);
                list3.Add(new InternalLoadCookie(troopTypeVO.AssetName));
                list4.Add(AssetHandle.Invalid);
            }
            assetManager.MultiLoad(list4, list2, null, null, null, new AssetsCompleteDelegate(this.StartDefenseMissionAfterPreload), mission);
        }
예제 #5
0
        private void DeployGroupAfterDelay(uint id, object cookie)
        {
            this.timers.Remove(id);
            DefenseTroopGroup defenseTroopGroup = (DefenseTroopGroup)cookie;
            TroopTypeVO       troop             = this.sdc.Get <TroopTypeVO>(defenseTroopGroup.TroopUid);

            for (int i = 0; i < defenseTroopGroup.Quantity; i++)
            {
                this.DeployTroopGroup(i, troop, defenseTroopGroup);
            }
            if (this.waves[this.currentWaveIndex].Troops.Count == 0 && this.timers.Count == 0)
            {
                this.EndCurrentWave();
            }
            if (Service.CurrentPlayer.CampaignProgress.FueInProgress)
            {
                int boardX = 0;
                int boardZ = 0;
                DefensiveBattleController.GetBoardEdge(defenseTroopGroup.Direction, defenseTroopGroup.Range, out boardX, out boardZ);
                this.AddCameraEvent(Units.BoardToWorldX(boardX), Units.BoardToWorldZ(boardZ), DefensiveCameraEventType.TroopSpawned);
            }
        }
 public unsafe static long $Invoke12(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(DefensiveBattleController.ParseWaves(Marshal.PtrToStringUni(*(IntPtr *)args))));
 }
 public unsafe static long $Invoke11(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(DefensiveBattleController.ParseTroopGroups(Marshal.PtrToStringUni(*(IntPtr *)args), Marshal.PtrToStringUni(*(IntPtr *)(args + 1)), *(int *)(args + 2))));
 }