Ejemplo n.º 1
0
        private static void SimulateMorrigiRelics(
            Random rand,
            GameSession game,
            int systemId,
            FleetInfo randomsFleet,
            int aiPlayerID,
            List <FleetInfo> aiPlayerFleets)
        {
            int numToKill = rand.NextInclusive(5, 6);
            Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets);

            if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)) == 0)
            {
                return;
            }
            CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill);
            MorrigiRelicInfo relicInfo = game.GameDatabase.GetMorrigiRelicInfos().ToList <MorrigiRelicInfo>().FirstOrDefault <MorrigiRelicInfo>((Func <MorrigiRelicInfo, bool>)(x => x.FleetId == randomsFleet.ID));

            if (relicInfo != null && relicInfo.IsAggressive)
            {
                List <ShipInfo> list = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>();
                game.ScriptModules.MorrigiRelic.ApplyRewardsToPlayers(game.App, relicInfo, list, new List <Player>()
                {
                    game.GetPlayerObject(aiPlayerID)
                });
            }
            else
            {
                CombatSimulatorRandoms.FleetDestroyed(game, aiPlayerID, randomsFleet, (ShipInfo)null);
                game.GameDatabase.RemoveFleet(randomsFleet.ID);
            }
        }
Ejemplo n.º 2
0
        public void ApplyRewardsToPlayers(
            App game,
            MorrigiRelicInfo relicInfo,
            List <ShipInfo> aliveRelicShips,
            List <Player> rewardedPlayers)
        {
            if (relicInfo == null)
            {
                return;
            }
            relicInfo.IsAggressive = false;
            int num1 = 0;

            foreach (ShipInfo aliveRelicShip in aliveRelicShips)
            {
                if (aliveRelicShip.DesignID != MorrigiRelic._designIds.Last <int>() && aliveRelicShip.DesignInfo != null)
                {
                    string sectionName = ((IEnumerable <DesignSectionInfo>)aliveRelicShip.DesignInfo.DesignSections).Select <DesignSectionInfo, ShipSectionAsset>((Func <DesignSectionInfo, ShipSectionAsset>)(x => x.ShipSectionAsset)).FirstOrDefault <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.Type == ShipSectionType.Mission)).SectionName;
                    int    reward      = game.AssetDatabase.GlobalMorrigiRelicData.Rewards[(int)MorrigiRelicControl.GetMorrigiRelicTypeFromName(sectionName)];
                    num1 += reward;
                }
            }
            game.GameDatabase.RemoveFleet(relicInfo.FleetId);
            game.GameDatabase.RemoveEncounter(relicInfo.Id);
            if (rewardedPlayers.Count == 0)
            {
                return;
            }
            int num2 = num1 / rewardedPlayers.Count;

            if (num2 <= 0)
            {
                return;
            }
            foreach (Player rewardedPlayer in rewardedPlayers)
            {
                PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(rewardedPlayer.ID);
                if (playerInfo != null)
                {
                    game.GameDatabase.UpdatePlayerSavings(playerInfo.ID, playerInfo.Savings + (double)num2);
                    game.GameDatabase.InsertTurnEvent(new TurnEvent()
                    {
                        EventType    = TurnEventType.EV_TOMB_DEFENDERS_DESTROYED,
                        EventMessage = TurnEventMessage.EM_TOMB_DEFENDERS_DESTROYED,
                        PlayerID     = playerInfo.ID,
                        SystemID     = relicInfo.SystemId,
                        Savings      = (double)num2,
                        TurnNumber   = game.GameDatabase.GetTurnCount()
                    });
                }
            }
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            this.m_LoadingCrows   = new List <Ship>();
            this.m_LaunchingCrows = new List <Ship>();
            this.m_SpawnedCrows   = new List <MorrigiCrowControl>();
            this.m_State          = MorrigiRelicStates.IDLE;
            this.m_Target         = (IGameObject)null;
            this.m_AvailableCrows = this.m_Game.GameDatabase.GetBattleRidersByParentID(this.m_MorrigiRelic.DatabaseID).ToList <ShipInfo>();
            this.m_MorrigiRelic.PostSetProp("SetAsOnlyLaunchCarrier", true);
            this.m_IsAggressive = false;
            MorrigiRelicInfo morrigiRelicInfo = this.m_Game.GameDatabase.GetMorrigiRelicInfos().ToList <MorrigiRelicInfo>().FirstOrDefault <MorrigiRelicInfo>((Func <MorrigiRelicInfo, bool>)(x => x.FleetId == this.m_FleetId));

            if (morrigiRelicInfo != null)
            {
                this.m_IsAggressive = morrigiRelicInfo.IsAggressive;
            }
            if (!this.m_IsAggressive)
            {
                return;
            }
            this.SpawnMaxCrows();
        }
Ejemplo n.º 4
0
        public void HandlePostCombat(
            List <Player> playersInCombat,
            List <int> fleetIdsInCombat,
            int systemId)
        {
            if (this.m_Game.Game.ScriptModules.MorrigiRelic == null || this.m_Game.Game.ScriptModules.MorrigiRelic.PlayerID != this.m_Player.ID)
            {
                return;
            }
            FleetInfo        relicFleet = (FleetInfo)null;
            List <FleetInfo> source     = new List <FleetInfo>();

            foreach (int fleetID in fleetIdsInCombat)
            {
                FleetInfo fleetInfo = this.m_Game.GameDatabase.GetFleetInfo(fleetID);
                if (fleetInfo != null)
                {
                    if (fleetInfo.PlayerID == this.m_Player.ID)
                    {
                        relicFleet = fleetInfo;
                    }
                    else
                    {
                        source.Add(fleetInfo);
                    }
                }
            }
            if (relicFleet == null)
            {
                return;
            }
            MorrigiRelicInfo relicInfo = this.m_Game.GameDatabase.GetMorrigiRelicInfos().ToList <MorrigiRelicInfo>().FirstOrDefault <MorrigiRelicInfo>((Func <MorrigiRelicInfo, bool>)(x => x.FleetId == relicFleet.ID));

            if (relicInfo == null || !relicInfo.IsAggressive)
            {
                return;
            }
            List <ShipInfo> aliveRelicShips = new List <ShipInfo>();
            bool            flag            = true;

            foreach (CombatAIController combatAiControl in this.m_CombatAIControls)
            {
                if (!combatAiControl.VictoryConditionIsMet())
                {
                    flag = false;
                    break;
                }
                if (combatAiControl is MorrigiRelicControl && combatAiControl.GetShip() != null && !combatAiControl.GetShip().IsDestroyed)
                {
                    aliveRelicShips.Add(this.m_Game.GameDatabase.GetShipInfo(combatAiControl.GetShip().DatabaseID, true));
                }
            }
            if (!flag)
            {
                return;
            }
            List <Player> rewardedPlayers = new List <Player>();

            foreach (Player player in playersInCombat)
            {
                Player p = player;
                if (p.ID != this.m_Player.ID && source.Any <FleetInfo>((Func <FleetInfo, bool>)(x => x.PlayerID == p.ID)))
                {
                    rewardedPlayers.Add(p);
                }
            }
            this.m_Game.Game.ScriptModules.MorrigiRelic.ApplyRewardsToPlayers(this.m_Game, relicInfo, aliveRelicShips, rewardedPlayers);
        }