Beispiel #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);
            }
        }
Beispiel #2
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);
            }
        }