Esempio n. 1
0
        private bool AIHaveReplacementForTech(StrategicAI ai, Tech tech)
        {
            bool flag = false;

            foreach (AIResearchFramework.AITechReplacementRow replacement in this._replacements)
            {
                if (tech == replacement.Old)
                {
                    PlayerTechInfo playerTechInfo = AIResearchFramework.AIGetPlayerTechInfo(ai, replacement.New);
                    if (playerTechInfo != null)
                    {
                        switch (replacement.Contexts)
                        {
                        case AIResearchFramework.AITechReplacementContexts.Available:
                            flag = AIResearchFramework.AIIsTechAvailable(playerTechInfo.State) || AIResearchFramework.AIHaveTech(playerTechInfo.State);
                            break;

                        case AIResearchFramework.AITechReplacementContexts.Researched:
                            flag = AIResearchFramework.AIHaveTech(playerTechInfo.State);
                            break;
                        }
                        if (flag)
                        {
                            break;
                        }
                    }
                }
            }
            return(flag);
        }
        public override void Initialize()
        {
            PlayerTechInfo pti  = this._app.GameDatabase.GetPlayerTechInfo(this._app.LocalPlayer.ID, this._techID);
            Tech           tech = this._app.AssetDatabase.MasterTechTree.Technologies.First <Tech>((Func <Tech, bool>)(x => x.Id == pti.TechFileID));

            this._app.UI.SetText(this._app.UI.Path(this.ID, "research_title"), this._app.AssetDatabase.GetLocalizedTechnologyName(tech.Id));
            this._app.UI.SetText(this._app.UI.Path(this.ID, "research_details"), App.Localize("@TECH_DESC_" + tech.Id));
        }
Esempio n. 3
0
        public override void Initialize()
        {
            PlayerTechInfo pti = this._app.GameDatabase.GetPlayerTechInfo(this._app.LocalPlayer.ID, this._event.TechID);

            this._app.UI.SetText(this._app.UI.Path(this.ID, "feasible_title"), string.Format(App.Localize("@FEASIBILITY_RESULT"), (object)this._app.AssetDatabase.GetLocalizedTechnologyName(this._app.AssetDatabase.MasterTechTree.Technologies.First <Tech>((Func <Tech, bool>)(x => x.Id == pti.TechFileID)).Id), (object)this._event.FeasibilityPercent));
            this._app.UI.SetText(this._app.UI.Path(this.ID, "feasible_details"), this._event.GetEventMessage(this._app.Game));
            this._researchInfo = new ResearchInfoPanel(this._app.UI, this._app.UI.Path(this.ID, "research_details"));
            this._researchInfo.SetTech(this._app, this._event.TechID);
        }
Esempio n. 4
0
        public static int GetPsiResistanceFromTech(AssetDatabase ab, List <PlayerTechInfo> techs)
        {
            PlayerTechInfo playerTechInfo = techs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "CYB_PsiShield"));

            if (playerTechInfo != null && playerTechInfo.State == TechStates.Researched)
            {
                return(ab.GetTechBonus <int>("CYB_PsiShield", "psiPower"));
            }
            return(0);
        }
Esempio n. 5
0
        private static int AIGetTechProgress(StrategicAI ai, Tech tech)
        {
            PlayerTechInfo playerTechInfo = AIResearchFramework.AIGetPlayerTechInfo(ai, tech);

            if (playerTechInfo == null)
            {
                return(0);
            }
            return(playerTechInfo.Progress);
        }
Esempio n. 6
0
        public static float GetSubversionRange(
            AssetDatabase ab,
            List <PlayerTechInfo> techs,
            bool isLoa)
        {
            PlayerTechInfo playerTechInfo = techs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "PSI_Subversion"));

            if (isLoa || playerTechInfo != null && playerTechInfo.State == TechStates.Researched)
            {
                return(ab.GetTechBonus <float>("PSI_Subversion", "range"));
            }
            return(0.0f);
        }
Esempio n. 7
0
        public void UpdateResearchProgress()
        {
            int researchingTechId = this.App.GameDatabase.GetPlayerResearchingTechID(this.App.LocalPlayer.ID);

            if (researchingTechId != 0)
            {
                PlayerTechInfo playerTechInfo = this.App.GameDatabase.GetPlayerTechInfo(this.App.LocalPlayer.ID, researchingTechId);
                this.PostSetProp("AmountResearched", (float)playerTechInfo.Progress / (float)playerTechInfo.ResearchCost);
            }
            else
            {
                this.PostSetProp("AmountResearched", 0.0f);
            }
        }
Esempio n. 8
0
        private static int AIGetTurnsToComplete(StrategicAI ai, Tech tech)
        {
            PlayerTechInfo playerTechInfo = ai.Game.GameDatabase.GetPlayerTechInfo(ai.Player.ID, ai.Game.GameDatabase.GetTechID(tech.Id));

            ai.Game.GameDatabase.GetPlayerInfo(ai.Player.ID);
            int researchPointsPerTurn = ai.CachedAvailableResearchPointsPerTurn;
            int?completeResearch      = GameSession.CalculateTurnsToCompleteResearch(playerTechInfo.ResearchCost, playerTechInfo.Progress, researchPointsPerTurn);

            if (!completeResearch.HasValue)
            {
                return(int.MaxValue);
            }
            return(completeResearch.Value);
        }
Esempio n. 9
0
 public bool IsAvailable(GameDatabase db, int playerId, bool forSuulka)
 {
     if (this.Ability == SectionEnumerations.PsionicAbility.AbaddonLaser || !forSuulka && this.RequiresSuulka)
     {
         return(false);
     }
     if (!string.IsNullOrEmpty(this.RequiredTechID))
     {
         PlayerTechInfo playerTechInfo = db.GetPlayerTechInfo(playerId, db.GetTechID(this.RequiredTechID));
         if (playerTechInfo == null || playerTechInfo.State != TechStates.Researched)
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 10
0
        public static float GetTotalStructure(
            AssetDatabase ab,
            float baseStruct,
            List <PlayerTechInfo> playerTechs)
        {
            PlayerTechInfo playerTechInfo1 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Quantum_Capacitors"));
            PlayerTechInfo playerTechInfo2 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Shield_Magnifier"));
            float          num             = 1f;

            if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched)
            {
                num += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "shieldstructure");
            }
            if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched)
            {
                num += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "shieldstructure");
            }
            return(baseStruct * num);
        }
Esempio n. 11
0
        public override void Initialize()
        {
            if (ScriptHost.AllowConsole)
            {
                this._app.UI.SetVisible("navTechInfo", true);
            }
            else
            {
                this._app.UI.SetVisible("navTechInfo", false);
            }
            PlayerTechInfo pti  = this._app.GameDatabase.GetPlayerTechInfo(this._app.LocalPlayer.ID, this._techID);
            Tech           tech = this._app.AssetDatabase.MasterTechTree.Technologies.First <Tech>((Func <Tech, bool>)(x => x.Id == pti.TechFileID));

            this._app.UI.SetText(this._app.UI.Path(this.ID, "research_title"), this._app.AssetDatabase.GetLocalizedTechnologyName(tech.Id));
            if (!this._app.UserProfile.ResearchedTechs.Contains(tech.Id))
            {
                this._app.UserProfile.ResearchedTechs.Add(tech.Id);
            }
            this._researchInfo = new ResearchInfoPanel(this._app.UI, this._app.UI.Path(this.ID, "research_details"));
            this._researchInfo.SetTech(this._app, this._techID);
        }
Esempio n. 12
0
        public static ShipSpeedModifiers GetShipSpeedModifiers(
            AssetDatabase ab,
            Player player,
            RealShipClasses shipClass,
            IEnumerable <PlayerTechInfo> playerTechs,
            bool isDeepSpace)
        {
            ShipSpeedModifiers shipSpeedModifiers = new ShipSpeedModifiers();

            shipSpeedModifiers.SpeedModifier       = 1f;
            shipSpeedModifiers.RotSpeedModifier    = 1f;
            shipSpeedModifiers.LinearAccelModifier = 1f;
            shipSpeedModifiers.RotAccelModifier    = 1f;
            if (player != null)
            {
                PlayerTechInfo playerTechInfo1 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Ionic_Thruster"));
                if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched)
                {
                    float techBonus1 = ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "shiprot");
                    float techBonus2 = ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "shipaccel");
                    shipSpeedModifiers.RotSpeedModifier    += techBonus1;
                    shipSpeedModifiers.LinearAccelModifier += techBonus2;
                    shipSpeedModifiers.RotAccelModifier    += techBonus2;
                }
                PlayerTechInfo playerTechInfo2 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Small_Scale_Fusion"));
                if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched && (shipClass == RealShipClasses.AssaultShuttle || shipClass == RealShipClasses.Drone || shipClass == RealShipClasses.Biomissile))
                {
                    shipSpeedModifiers.SpeedModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "speed");
                }
                if (isDeepSpace && player.Faction.Name == "liir_zuul")
                {
                    shipSpeedModifiers.SpeedModifier       += 0.2f;
                    shipSpeedModifiers.RotSpeedModifier    += 0.2f;
                    shipSpeedModifiers.LinearAccelModifier += 0.2f;
                    shipSpeedModifiers.RotAccelModifier    += 0.2f;
                }
            }
            return(shipSpeedModifiers);
        }
 protected void SetSyncedTechFamily(TechFamily family)
 {
     this._game.UI.ClearItems(this.RightContentList);
     this._TechToggles.Clear();
     this._TechPanels.Clear();
     foreach (PlayerTechInfo playerTechInfo in this._game.GameDatabase.GetPlayerTechInfos(this._game.LocalPlayer.ID).Where <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(j => j.Id == x.TechFileID)).Family == family.Id)).ToList <PlayerTechInfo>())
     {
         PlayerTechInfo tech = playerTechInfo;
         if (this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.TechFileID)).Allows.Any <Allowable>((Func <Allowable, bool>)(x => (double)x.GetFactionProbabilityPercentage(this._game.LocalPlayer.Faction.Name.ToLower()) > 0.0)))
         {
             this._game.UI.AddItem(this.RightContentList, "", tech.TechID, "", "TechCard_Toggle");
             string itemGlobalId = this._game.UI.GetItemGlobalID(this.RightContentList, "", tech.TechID, "");
             this._TechPanels.Add(tech.TechFileID, itemGlobalId);
             this._game.UI.SetChecked(this.UI.Path(itemGlobalId, "techtoggle"), (!this._CheckedTechs.Any <KeyValuePair <string, bool> >((Func <KeyValuePair <string, bool>, bool>)(x => x.Key == tech.TechFileID)) ? 0 : (this._CheckedTechs[tech.TechFileID] ? 1 : 0)) != 0);
             this._game.UI.SetVisible(this.UI.Path(itemGlobalId, "contentSelected"), (!this._CheckedTechs.Any <KeyValuePair <string, bool> >((Func <KeyValuePair <string, bool>, bool>)(x => x.Key == tech.TechFileID)) ? 0 : (this._CheckedTechs[tech.TechFileID] ? 1 : 0)) != 0);
             this._game.UI.SetPropertyString(this.UI.Path(itemGlobalId, "techtoggle"), "id", "techtoggle|" + this._FamilyID.FirstOrDefault <KeyValuePair <int, TechFamily> >((Func <KeyValuePair <int, TechFamily>, bool>)(x => x.Value == family)).Key.ToString() + "|" + tech.TechFileID);
             string globalId = this._game.UI.GetGlobalID(this.UI.Path(itemGlobalId, "techtoggle|" + this._FamilyID.FirstOrDefault <KeyValuePair <int, TechFamily> >((Func <KeyValuePair <int, TechFamily>, bool>)(x => x.Value == family)).Key.ToString() + "|" + tech.TechFileID));
             this._TechToggles.Add(tech.TechFileID, globalId);
             this._game.UI.SetText(this._game.UI.Path(itemGlobalId, "techLabel"), this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.TechFileID)).Name);
             this._game.UI.SetPropertyString(this._game.UI.Path(itemGlobalId, "icon"), "sprite", Path.GetFileNameWithoutExtension(this._game.AssetDatabase.MasterTechTree.Technologies.FirstOrDefault <Tech>((Func <Tech, bool>)(x => x.Id == tech.TechFileID)).Icon));
         }
     }
 }
Esempio n. 14
0
 public static int GetWeaponLevelFromTechs(LogicalWeapon weapon, List <PlayerTechInfo> techs)
 {
     if (weapon == null || (!((IEnumerable <WeaponEnums.WeaponTraits>)weapon.Traits).Any <WeaponEnums.WeaponTraits>((Func <WeaponEnums.WeaponTraits, bool>)(x => x == WeaponEnums.WeaponTraits.Upgradable)) || techs.Count == 0))
     {
         return(1);
     }
     switch (weapon.PayloadType)
     {
     case WeaponEnums.PayloadTypes.Missile:
     case WeaponEnums.PayloadTypes.BattleRider:
         PlayerTechInfo playerTechInfo1 = techs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "WAR_Anti-Matter_Warheads"));
         PlayerTechInfo playerTechInfo2 = techs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "WAR_Reflex_Warheads"));
         if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched)
         {
             return(3);
         }
         if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched)
         {
             return(2);
         }
         break;
     }
     return(1);
 }
Esempio n. 15
0
        public static WeaponTechModifiers ObtainWeaponTechModifiers(
            AssetDatabase ab,
            WeaponEnums.TurretClasses tc,
            LogicalWeapon weapon,
            IEnumerable <PlayerTechInfo> playerTechs)
        {
            WeaponTechModifiers weaponTechModifiers = new WeaponTechModifiers();

            weaponTechModifiers.DamageModifier = 0.0f;
            weaponTechModifiers.SpeedModifier  = 0.0f;
            weaponTechModifiers.AccelModifier  = 0.0f;
            weaponTechModifiers.MassModifier   = 0.0f;
            weaponTechModifiers.ROFModifier    = 1f;
            weaponTechModifiers.RangeModifier  = 0.0f;
            weaponTechModifiers.SmartNanites   = false;
            if (weapon == null || playerTechs == null || playerTechs.Count <PlayerTechInfo>() == 0)
            {
                return(weaponTechModifiers);
            }
            if (tc != WeaponEnums.TurretClasses.Torpedo && weapon.PayloadType == WeaponEnums.PayloadTypes.Bolt)
            {
                PlayerTechInfo playerTechInfo1 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "BAL_Neutronium_Rounds"));
                PlayerTechInfo playerTechInfo2 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "BAL_Acceleration_Amplification"));
                if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched)
                {
                    weaponTechModifiers.DamageModifier += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "damage");
                    weaponTechModifiers.MassModifier   += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "mass");
                }
                if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched)
                {
                    weaponTechModifiers.DamageModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "damage");
                    weaponTechModifiers.SpeedModifier  += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "speed");
                }
            }
            if (weapon.PayloadType == WeaponEnums.PayloadTypes.Missile)
            {
                PlayerTechInfo playerTechInfo1 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "WAR_MicroFusion_Drives"));
                PlayerTechInfo playerTechInfo2 = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Ionic_Thruster"));
                if (playerTechInfo1 != null && playerTechInfo1.State == TechStates.Researched)
                {
                    weaponTechModifiers.SpeedModifier += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "speed");
                    weaponTechModifiers.RangeModifier += ab.GetTechBonus <float>(playerTechInfo1.TechFileID, "range");
                }
                if (playerTechInfo2 != null && playerTechInfo2.State == TechStates.Researched)
                {
                    weaponTechModifiers.SpeedModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "speed");
                    weaponTechModifiers.AccelModifier += ab.GetTechBonus <float>(playerTechInfo2.TechFileID, "accel");
                }
            }
            if (weapon.PayloadType == WeaponEnums.PayloadTypes.Beam)
            {
                PlayerTechInfo playerTechInfo = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "NRG_Quantum_Capacitors"));
                if (playerTechInfo != null && playerTechInfo.State == TechStates.Researched)
                {
                    weaponTechModifiers.ROFModifier += ab.GetTechBonus <float>(playerTechInfo.TechFileID, "rateoffire");
                }
            }
            if (((IEnumerable <WeaponEnums.WeaponTraits>)weapon.Traits).Contains <WeaponEnums.WeaponTraits>(WeaponEnums.WeaponTraits.Ballistic))
            {
                PlayerTechInfo playerTechInfo = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "BAL_VRF_Systems"));
                if (playerTechInfo != null && playerTechInfo.State == TechStates.Researched)
                {
                    weaponTechModifiers.ROFModifier += ab.GetTechBonus <float>(playerTechInfo.TechFileID, "rateoffire");
                }
            }
            if (((IEnumerable <WeaponEnums.WeaponTraits>)weapon.Traits).Contains <WeaponEnums.WeaponTraits>(WeaponEnums.WeaponTraits.Nanite))
            {
                PlayerTechInfo playerTechInfo = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "IND_Smart_Nanites"));
                weaponTechModifiers.SmartNanites = playerTechInfo != null && playerTechInfo.State == TechStates.Researched;
            }
            return(weaponTechModifiers);
        }
Esempio n. 16
0
        private void SyncLimitationGroup(LimitationTreatyType ltt)
        {
            this._app.UI.ClearItems("lstLimitationGroup");
            switch (ltt)
            {
            case LimitationTreatyType.ShipClass:
                using (Dictionary <ShipClass, string> .Enumerator enumerator = TreatyEditDialog.ShipClassLimitationGroups.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <ShipClass, string> current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value));
                    }
                    break;
                }

            case LimitationTreatyType.Weapon:
                using (IEnumerator <LogicalWeapon> enumerator = this._app.AssetDatabase.Weapons.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        LogicalWeapon current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, current.UniqueWeaponID, current.WeaponName);
                    }
                    break;
                }

            case LimitationTreatyType.ResearchTree:
                int userItemId = 0;
                using (List <TechFamily> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.TechFamilies.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TechFamily current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, userItemId, current.Name);
                        ++userItemId;
                    }
                    break;
                }

            case LimitationTreatyType.ResearchTech:
                using (List <Tech> .Enumerator enumerator = this._app.AssetDatabase.MasterTechTree.Technologies.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Tech           current         = enumerator.Current;
                        int            techId          = this._app.GameDatabase.GetTechID(current.Id);
                        PlayerTechInfo playerTechInfo1 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.InitiatingPlayerId, techId);
                        PlayerTechInfo playerTechInfo2 = this._app.GameDatabase.GetPlayerTechInfo(this._editedTreaty.ReceivingPlayerId, techId);
                        if (playerTechInfo1 != null && playerTechInfo1.State != TechStates.Researched && (playerTechInfo1.State != TechStates.Researching && playerTechInfo2 != null) && (playerTechInfo2.State != TechStates.Researched && playerTechInfo2.State != TechStates.Researching))
                        {
                            this._app.UI.AddItem("lstLimitationGroup", string.Empty, techId, current.Name);
                        }
                    }
                    break;
                }

            case LimitationTreatyType.StationType:
                using (Dictionary <StationType, string> .Enumerator enumerator = TreatyEditDialog.StationTypeLimitationGroups.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <StationType, string> current = enumerator.Current;
                        this._app.UI.AddItem("lstLimitationGroup", string.Empty, (int)current.Key, App.Localize(current.Value));
                    }
                    break;
                }
            }
        }
Esempio n. 17
0
 private string GetTechName(PlayerTechInfo o)
 {
     return(this.assetdb.GetLocalizedTechnologyName(o.TechFileID));
 }
Esempio n. 18
0
        public override void OnCommit(
            GameSession game,
            int playerId,
            int targetPlayerId,
            int?missionid = null)
        {
            List <CounterIntelResponse> source = new List <CounterIntelResponse>();

            if (missionid.HasValue)
            {
                source = game.GameDatabase.GetCounterIntelResponses(missionid.Value).ToList <CounterIntelResponse>();
            }
            if (source.Any <CounterIntelResponse>((Func <CounterIntelResponse, bool>)(x => !x.auto)))
            {
                game.GameDatabase.InsertTurnEvent(new TurnEvent()
                {
                    EventType      = TurnEventType.EV_INTEL_MISSION_CURRENT_TECH,
                    EventMessage   = TurnEventMessage.EM_INTEL_MISSION_CURRENT_TECH,
                    TechID         = game.GameDatabase.GetTechID(source.First <CounterIntelResponse>().value),
                    PlayerID       = playerId,
                    TargetPlayerID = targetPlayerId,
                    TurnNumber     = game.GameDatabase.GetTurnCount(),
                    ShowsDialog    = true
                });
            }
            else
            {
                int techId = game.GameDatabase.GetPlayerResearchingTechID(targetPlayerId);
                if (source.Any <CounterIntelResponse>((Func <CounterIntelResponse, bool>)(x => x.auto)))
                {
                    List <PlayerTechInfo> list = game.GameDatabase.GetPlayerTechInfos(targetPlayerId).ToList <PlayerTechInfo>();
                    techId = list.ToArray()[game.Random.Next(0, list.Count)].TechID;
                }
                if (techId != 0)
                {
                    game.GameDatabase.GetPlayerTechInfo(targetPlayerId, techId);
                    game.GameDatabase.InsertTurnEvent(new TurnEvent()
                    {
                        EventType      = TurnEventType.EV_INTEL_MISSION_CURRENT_TECH,
                        EventMessage   = TurnEventMessage.EM_INTEL_MISSION_CURRENT_TECH,
                        TechID         = techId,
                        PlayerID       = playerId,
                        TargetPlayerID = targetPlayerId,
                        TurnNumber     = game.GameDatabase.GetTurnCount(),
                        ShowsDialog    = true
                    });
                }
                else
                {
                    List <PlayerTechInfo> list = game.GameDatabase.GetPlayerTechInfos(targetPlayerId).Where <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x =>
                    {
                        if (x.State != TechStates.Researched)
                        {
                            return(false);
                        }
                        int?turnResearched = x.TurnResearched;
                        if (turnResearched.GetValueOrDefault() > 1)
                        {
                            return(turnResearched.HasValue);
                        }
                        return(false);
                    })).ToList <PlayerTechInfo>();
                    if (list.Count == 0)
                    {
                        game.GameDatabase.InsertTurnEvent(new TurnEvent()
                        {
                            EventType      = TurnEventType.EV_INTEL_MISSION_NO_COMPLETE_TECHS,
                            EventMessage   = TurnEventMessage.EM_INTEL_MISSION_NO_COMPLETE_TECHS,
                            PlayerID       = playerId,
                            TargetPlayerID = targetPlayerId,
                            TurnNumber     = game.GameDatabase.GetTurnCount()
                        });
                    }
                    else
                    {
                        PlayerTechInfo playerTechInfo = list.OrderByDescending <PlayerTechInfo, int?>((Func <PlayerTechInfo, int?>)(x => x.TurnResearched)).First <PlayerTechInfo>();
                        game.GameDatabase.InsertTurnEvent(new TurnEvent()
                        {
                            EventType      = TurnEventType.EV_INTEL_MISSION_RECENT_TECH,
                            EventMessage   = TurnEventMessage.EM_INTEL_MISSION_RECENT_TECH,
                            TechID         = playerTechInfo.TechID,
                            PlayerID       = playerId,
                            TargetPlayerID = targetPlayerId,
                            TurnNumber     = game.GameDatabase.GetTurnCount()
                        });
                    }
                }
            }
        }
Esempio n. 19
0
        public static float GetShieldRegenPerSec(List <PlayerTechInfo> playerTechs)
        {
            PlayerTechInfo playerTechInfo = playerTechs.FirstOrDefault <PlayerTechInfo>((Func <PlayerTechInfo, bool>)(x => x.TechFileID == "SLD_Shields_Rechargers"));

            return(playerTechInfo != null && playerTechInfo.State == TechStates.Researched ? 50f : 0.0f);
        }