Exemple #1
0
        public override void Initialize()
        {
            CombatData       combat = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn);
            PlayerCombatData player = combat.GetPlayer(this._app.LocalPlayer.ID);

            if (player == null)
            {
                this._app.UI.CloseDialog((Dialog)this, true);
            }
            else
            {
                this._app.GameDatabase.GetPlayerInfos();
                StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID);
                string         str            = App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE");
                if (starSystemInfo != (StarSystemInfo)null)
                {
                    str = starSystemInfo.Name;
                }
                this._app.UI.SetPropertyString("title", "text", "Combat - " + player.VictoryStatus.ToString() + " at " + str);
                this.syncCombatantsLists();
                this.SyncPlayerSide(player.PlayerID);
                if (this.EnemyPlayers.Any <int>())
                {
                    this.SyncEnemySide(this.EnemyPlayers.First <int>());
                }
                StarSystemMapUI.Sync(this._app, this._systemID, "systemMapContent", false);
            }
        }
Exemple #2
0
        public void syncCombatantsLists()
        {
            CombatData       combat  = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn);
            PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID);

            foreach (PlayerInfo playerInfo in this._app.GameDatabase.GetPlayerInfos())
            {
                PlayerInfo player = playerInfo;
                if (combat.GetPlayer(player.ID) != null)
                {
                    DiplomacyInfo diplomacyInfo = this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID);
                    string        itemGlobalId;
                    if (diplomacyInfo.State == DiplomacyState.WAR)
                    {
                        this._app.UI.AddItem("enemiesList", "", player.ID, "");
                        itemGlobalId = this._app.UI.GetItemGlobalID("enemiesList", "", player.ID, "");
                        this.EnemyPlayers.Add(player.ID);
                    }
                    else
                    {
                        this._app.UI.AddItem("alliesList", "", player.ID, "");
                        itemGlobalId = this._app.UI.GetItemGlobalID("alliesList", "", player.ID, "");
                    }
                    PlayerSetup playerSetup   = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID));
                    string      propertyValue = playerSetup == null || !(playerSetup.Name != "") ? player.Name : playerSetup.Name;
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "name"), "text", propertyValue);
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "playeravatar"), "texture", player.AvatarAssetPath);
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "badge"), "texture", player.BadgeAssetPath);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId, "primaryColor"), "color", player.PrimaryColor);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId, "secondaryColor"), "color", player.SecondaryColor);
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "avatarButton"), "id", "avatarButton|" + (diplomacyInfo.State == DiplomacyState.WAR ? "E|" : "A|") + player.ID.ToString());
                }
            }
        }
Exemple #3
0
        public void SyncEnemySide(int playerid)
        {
            CombatData       combat  = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn);
            PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID);

            if (player1 == null)
            {
                this._app.UI.CloseDialog((Dialog)this, true);
            }
            else
            {
                foreach (PlanetWidget sideplanetWidget in this._EnemySideplanetWidgets)
                {
                    sideplanetWidget.Terminate();
                }
                this._EnemySideplanetWidgets.Clear();
                IEnumerable <PlayerInfo> playerInfos    = this._app.GameDatabase.GetPlayerInfos();
                StarSystemInfo           starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID);
                App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE");
                if (starSystemInfo != (StarSystemInfo)null)
                {
                    string name = starSystemInfo.Name;
                }
                int    val2_1 = 0;
                int    val2_2 = 0;
                float  val2_3 = 0.0f;
                float  val2_4 = 0.0f;
                double num1   = 0.0;
                double num2   = 0.0;
                float  num3   = 0.0f;
                int    num4   = 0;
                Dictionary <int, float> dictionary1 = new Dictionary <int, float>();
                PlayerInfo       player             = playerInfos.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == playerid));
                PlayerCombatData player2            = combat.GetPlayer(player.ID);
                if (player2 != null)
                {
                    this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID);
                    PlayerSetup playerSetup    = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID));
                    string      propertyValue1 = playerSetup == null || !(playerSetup.Name != "") || playerSetup.AI ? player.Name : playerSetup.Name;
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "name"), "text", propertyValue1);
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "playeravatar"), "texture", player.AvatarAssetPath);
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "badge"), "texture", player.BadgeAssetPath);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "primaryColor"), "color", player.PrimaryColor);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "secondaryColor"), "color", player.SecondaryColor);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "empireColor"), "color", player.PrimaryColor);
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerName"), "text", propertyValue1);
                    List <ShipData>   shipData1   = player2.ShipData;
                    List <WeaponData> weaponData1 = player2.WeaponData;
                    List <PlanetData> planetData1 = player2.PlanetData;
                    int   count  = shipData1.Count;
                    int   val1_1 = 0;
                    float val1_2 = 0.0f;
                    float val1_3 = 0.0f;
                    Dictionary <int, string> dictionary2 = new Dictionary <int, string>();
                    int userItemId1 = 0;
                    this._app.UI.ClearItems(this._app.UI.Path("enemySide", "fleetDamage"));
                    foreach (ShipData shipData2 in shipData1)
                    {
                        val1_1 += shipData2.killCount;
                        val1_2 += shipData2.damageDealt;
                        val1_3 += shipData2.damageReceived;
                        num4   += shipData2.destroyed ? 1 : 0;
                        DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(shipData2.designID);
                        if (designInfo != null)
                        {
                            RealShipClasses?realShipClass = designInfo.GetRealShipClass();
                            if ((realShipClass.GetValueOrDefault() != RealShipClasses.AssaultShuttle ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0)
                            {
                                realShipClass = designInfo.GetRealShipClass();
                                if ((realShipClass.GetValueOrDefault() != RealShipClasses.Drone ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0)
                                {
                                    realShipClass = designInfo.GetRealShipClass();
                                    if ((realShipClass.GetValueOrDefault() != RealShipClasses.BoardingPod ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0 && this._app.Game.ScriptModules.MeteorShower.PlayerID != player.ID)
                                    {
                                        string propertyValue2 = "";
                                        if (shipData2.destroyed)
                                        {
                                            propertyValue2 = designInfo.Name + " class ship has been destroyed.";
                                        }
                                        else if ((double)shipData2.damageReceived > 0.0)
                                        {
                                            propertyValue2 = designInfo.Name + " class ship has been damaged.";
                                        }
                                        if (propertyValue2 != "")
                                        {
                                            this._app.UI.AddItem(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, "");
                                            this._app.UI.SetPropertyString(this._app.UI.Path(this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, ""), "name"), "text", propertyValue2);
                                            ++userItemId1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerScore"), "text", (shipData1.Count - num4).ToString() + "/" + shipData1.Count.ToString());
                    this._app.UI.SetSliderRange(this._app.UI.Path("enemySide", "playerData", "assets"), 0, shipData1.Count);
                    this._app.UI.SetSliderValue(this._app.UI.Path("enemySide", "playerData", "assets"), shipData1.Count - num4);
                    foreach (WeaponData weaponData2 in weaponData1)
                    {
                        if (!dictionary1.ContainsKey(weaponData2.weaponID))
                        {
                            dictionary1.Add(weaponData2.weaponID, 0.0f);
                        }
                        Dictionary <int, float> dictionary3;
                        int weaponId;
                        (dictionary3 = dictionary1)[weaponId = weaponData2.weaponID] = dictionary3[weaponId] + weaponData2.damageDealt;
                    }
                    this._app.UI.ClearItems(this._app.UI.Path("enemySide", "weaponDamage"));
                    int    num5        = 0;
                    int    userItemId2 = 0;
                    string str         = null;
                    foreach (int key in dictionary1.Keys)
                    {
                        int weapon = key;
                        if (num5 == 5 || str == null)
                        {
                            this._app.UI.AddItem(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, "");
                            str = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, "");
                            ++userItemId2;
                            num5 = 0;
                            for (int index = 0; index < 5; ++index)
                            {
                                this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + index.ToString()), false);
                            }
                        }
                        this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "damageDealt"), "text", dictionary1[weapon].ToString("N0"));
                        LogicalWeapon logicalWeapon  = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon));
                        string        iconSpriteName = logicalWeapon.IconSpriteName;
                        this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "weaponIcon"), "sprite", iconSpriteName);
                        this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString()), "tooltip", logicalWeapon.WeaponName);
                        this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + num5.ToString()), true);
                        ++num5;
                    }
                    this._app.UI.ClearItems(this._app.UI.Path("enemySide", "planetDamage"));
                    foreach (PlanetData planetData2 in planetData1)
                    {
                        ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetData2.orbitalObjectID);
                        if (colonyInfoForPlanet != null)
                        {
                            num1 += planetData2.imperialDamage;
                            num2 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage));
                            num3 += planetData2.infrastructureDamage;
                            this._app.UI.AddItem(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, "");
                            string            itemGlobalId       = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, "");
                            OrbitalObjectInfo orbitalObjectInfo  = this._app.GameDatabase.GetOrbitalObjectInfo(colonyInfoForPlanet.OrbitalObjectID);
                            PlanetInfo        planetInfo         = this._app.GameDatabase.GetPlanetInfo(colonyInfoForPlanet.OrbitalObjectID);
                            Faction           faction            = this._app.AssetDatabase.GetFaction(this._app.GameDatabase.GetPlayerFactionID(colonyInfoForPlanet.PlayerID));
                            double            civilianPopulation = this._app.GameDatabase.GetCivilianPopulation(colonyInfoForPlanet.OrbitalObjectID, faction.ID, faction.HasSlaves());
                            float             num6 = planetInfo != null ? planetInfo.Infrastructure : 0.0f;
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "planetName"), "text", orbitalObjectInfo != null ? orbitalObjectInfo.Name : "?");
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "civslbl"), "text", civilianPopulation.ToString("N0"));
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "implbl"), "text", colonyInfoForPlanet.ImperialPop.ToString("N0"));
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "infralbl"), "text", num6.ToString());
                            double num7 = civilianPopulation + planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage));
                            this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "civAmount"), 0, (int)num7);
                            this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "civAmount"), (int)(num7 - planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage))));
                            double num8 = colonyInfoForPlanet.ImperialPop + planetData2.imperialDamage;
                            this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "impAmount"), 0, (int)num8);
                            this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "impAmount"), (int)(num8 - planetData2.imperialDamage));
                            float num9 = num6 + planetData2.infrastructureDamage;
                            this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "infraAmount"), 0, (int)(100.0 * (double)num9));
                            this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "infraAmount"), (int)(100.0 * ((double)num9 - (double)planetData2.infrastructureDamage)));
                            if (planetInfo != null)
                            {
                                this._EnemySideplanetWidgets.Add(new PlanetWidget(this._app, itemGlobalId));
                                this._EnemySideplanetWidgets.Last <PlanetWidget>().Sync(planetInfo.ID, false, false);
                            }
                        }
                    }
                    Math.Max(count, val2_1);
                    Math.Max(val1_1, val2_2);
                    Math.Max(val1_2, val2_3);
                    Math.Max(val1_3, val2_4);
                }
                this._app.UI.AutoSizeContents(this._app.UI.Path(this.ID, "enemySide"));
            }
        }
Exemple #4
0
        private static void CompleteSimulation(
            GameSession game,
            int systemId,
            Dictionary <FleetInfo, List <ShipCombatInfo> > shipCombatInfo,
            List <PlanetCombatInfo> planets)
        {
            CombatData combatData = game.CombatData.AddCombat(GameSession.GetNextUniqueCombatID(), systemId, game.GameDatabase.GetTurnCount());

            foreach (KeyValuePair <FleetInfo, List <ShipCombatInfo> > keyValuePair1 in shipCombatInfo)
            {
                PlayerCombatData orAddPlayer = combatData.GetOrAddPlayer(keyValuePair1.Key.PlayerID);
                orAddPlayer.VictoryStatus = GameSession.VictoryStatus.Draw;
                foreach (ShipCombatInfo shipCombatInfo1 in keyValuePair1.Value)
                {
                    ShipCombatInfo sci = shipCombatInfo1;
                    if ((double)sci.structureFactor == 0.0)
                    {
                        if (sci.shipInfo.DesignInfo.IsSuulka())
                        {
                            TurnEvent turnEvent = game.GameDatabase.GetTurnEventsByTurnNumber(game.GameDatabase.GetTurnCount(), orAddPlayer.PlayerID).FirstOrDefault <TurnEvent>((Func <TurnEvent, bool>)(x => x.ShipID == sci.shipInfo.ID));
                            if (turnEvent != null)
                            {
                                game.GameDatabase.RemoveTurnEvent(turnEvent.ID);
                            }
                            List <int> intList1 = new List <int>();
                            List <int> intList2 = new List <int>();
                            foreach (KeyValuePair <FleetInfo, List <ShipCombatInfo> > keyValuePair2 in shipCombatInfo)
                            {
                                if (orAddPlayer.PlayerID != keyValuePair2.Key.PlayerID && !intList1.Contains(keyValuePair2.Key.PlayerID) && !intList2.Contains(keyValuePair2.Key.PlayerID))
                                {
                                    switch (game.GameDatabase.GetDiplomacyStateBetweenPlayers(orAddPlayer.PlayerID, keyValuePair2.Key.PlayerID))
                                    {
                                    case DiplomacyState.WAR:
                                        intList1.Add(keyValuePair2.Key.PlayerID);
                                        continue;

                                    case DiplomacyState.NEUTRAL:
                                        intList2.Add(keyValuePair2.Key.PlayerID);
                                        continue;

                                    default:
                                        continue;
                                    }
                                }
                            }
                            int num = 0;
                            if (intList1.Count > 0)
                            {
                                num = App.GetSafeRandom().Choose <int>((IList <int>)intList1);
                            }
                            else if (intList2.Count > 0)
                            {
                                num = App.GetSafeRandom().Choose <int>((IList <int>)intList2);
                            }
                            game.GameDatabase.InsertTurnEvent(new TurnEvent()
                            {
                                EventType    = TurnEventType.EV_SUULKA_DIES,
                                EventMessage = TurnEventMessage.EM_SUULKA_DIES,
                                PlayerID     = num,
                                SystemID     = systemId,
                                ShipID       = sci.shipInfo.ID,
                                DesignID     = sci.shipInfo.DesignID,
                                TurnNumber   = game.GameDatabase.GetTurnCount(),
                                ShowsDialog  = false
                            });
                            SuulkaInfo suulkaByShipId = game.GameDatabase.GetSuulkaByShipID(sci.shipInfo.ID);
                            if (suulkaByShipId != null)
                            {
                                game.GameDatabase.RemoveSuulka(suulkaByShipId.ID);
                            }
                        }
                        game.GameDatabase.RemoveShip(sci.shipInfo.ID);
                        GameTrigger.PushEvent(EventType.EVNT_SHIPDIED, (object)sci.shipInfo.DesignInfo.Class, game);
                        orAddPlayer.AddShipData(sci.shipInfo.DesignID, 0.0f, 0.0f, 0, true);
                        if (ScriptHost.AllowConsole)
                        {
                            App.Log.Trace(string.Format("Ship destroyed: {0} ({1})", (object)sci.shipInfo.ID, (object)sci.shipInfo.ShipName), "combat");
                        }
                    }
                    else
                    {
                        if (sci.shipInfo.DesignInfo == null)
                        {
                            sci.shipInfo.DesignInfo = game.GameDatabase.GetDesignInfo(sci.shipInfo.DesignID);
                        }
                        foreach (SectionInstanceInfo sectionInstanceInfo in game.GameDatabase.GetShipSectionInstances(sci.shipInfo.ID).ToList <SectionInstanceInfo>())
                        {
                            SectionInstanceInfo sii = sectionInstanceInfo;
                            int minStructure        = ((IEnumerable <DesignSectionInfo>)sci.shipInfo.DesignInfo.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ID == sii.SectionID)).GetMinStructure(game.GameDatabase, game.AssetDatabase);
                            sii.Structure -= sii.Structure - (int)Math.Round((double)sci.structureFactor);
                            sii.Structure  = Math.Max(sii.Structure, minStructure);
                            game.GameDatabase.UpdateSectionInstance(sii);
                            if (sii.Structure == minStructure)
                            {
                                foreach (ModuleInstanceInfo module in game.GameDatabase.GetModuleInstances(sii.ID).ToList <ModuleInstanceInfo>())
                                {
                                    module.Structure = 0;
                                    game.GameDatabase.UpdateModuleInstance(module);
                                }
                                foreach (WeaponInstanceInfo weapon in game.GameDatabase.GetWeaponInstances(sii.ID).ToList <WeaponInstanceInfo>())
                                {
                                    weapon.Structure = 0.0f;
                                    game.GameDatabase.UpdateWeaponInstance(weapon);
                                }
                            }
                        }
                    }
                }
                if (!CombatSimulator.IsFleetAlive(keyValuePair1.Value))
                {
                    game.GameDatabase.RemoveFleet(keyValuePair1.Key.ID);
                    GameTrigger.PushEvent(EventType.EVNT_FLEETDIED, (object)keyValuePair1.Key.Name, game);
                    if (ScriptHost.AllowConsole)
                    {
                        App.Log.Trace(string.Format("Fleet destroyed: {0} ({1})", (object)keyValuePair1.Key.ID, (object)keyValuePair1.Key.Name), "combat");
                    }
                }
                else
                {
                    CombatSimulator.CheckFleetCommandPoints(game, keyValuePair1.Key);
                }
            }
            bool flag = true;

            foreach (PlanetCombatInfo planet in planets)
            {
                game.GameDatabase.UpdatePlanet(planet.planetInfo);
                if (planet.colonyInfo != null)
                {
                    if (planet.colonyInfo.ImperialPop <= 0.0)
                    {
                        game.GameDatabase.RemoveColonyOnPlanet(planet.planetInfo.ID);
                        if (ScriptHost.AllowConsole)
                        {
                            App.Log.Trace(string.Format("Colony defeated: planetid={0}", (object)planet.planetInfo.ID), "combat");
                        }
                    }
                    else
                    {
                        flag = false;
                        planet.colonyInfo.DamagedLastTurn = true;
                        game.GameDatabase.UpdateColony(planet.colonyInfo);
                        foreach (ColonyFactionInfo faction in planet.colonyInfo.Factions)
                        {
                            game.GameDatabase.UpdateCivilianPopulation(faction);
                        }
                    }
                }
            }
            if (flag)
            {
                foreach (StationInfo stationInfo in game.GameDatabase.GetStationForSystem(systemId).ToList <StationInfo>())
                {
                    game.GameDatabase.DestroyStation(game, stationInfo.ID, 0);
                }
            }
            game.GameDatabase.InsertCombatData(systemId, combatData.CombatID, combatData.Turn, combatData.ToByteArray());
        }
Exemple #5
0
    void ImportPlayerCombatData(PlayerCombatData playerCD)
    {
        //Import Movement Data
        combatHUDLog.RemoveAllMovement();
        foreach (PlayerCombatMovementData playerCMD in playerCD.pcmd)
        {
            List <Vector3> des = new List <Vector3>();
            foreach (PlayerCombatMovementDestination vec in playerCMD.destination)
            {
                des.Add(new Vector3(vec.posX, vec.posY, 0));
            }
            combatHUDLog.LogMovePosition(des, playerCMD.hash);
        }
        if (combatHUDLog.loggedMoves.Count == 0)
        {
            GameManagerScript.ins.playerInfo.polyNav.Stop();
        }

        //Import Attack Data
        combatHUDAttack.RemoveAllAttacks();
        GameManagerScript.ins.playerInfo.CancelAllSpells();
        foreach (PlayerCombatAttackData playerCAD in playerCD.pcad)
        {
            CombatHUDAttack.Attack a = new CombatHUDAttack.Attack();
            a.selectedSpell        = SpellManagerScript.ins.GetSpellFromID(playerCAD.selectedSpellID);
            a.selfCast             = playerCAD.selfCast;
            a.isCasting            = playerCAD.isCasting;
            a.fireMode             = playerCAD.fm;
            a.attackPoint          = new Vector3(playerCAD.attackPointPosX, playerCAD.attackPointPosY, 0);
            a.attackDirection      = new Vector3(playerCAD.attackDirectionX, playerCAD.attackDirectionY, 0);
            a.attackPointModePoint = new Vector3(playerCAD.attackPointModePosX, playerCAD.attackPointModePosY, 0);
            a.hash         = playerCAD.hash;
            a.attackTarget = NPCManagerScript.ins.GetNPCInSceneFromID(playerCAD.attackTarget);
            combatHUDAttack.LoadAttackToLayout(a);
        }
        combatHUDAttack.DrawAttackPositions();
        combatHUDAttack.SortAttackLayout();

        //Import Order Data
        combatSpeech.RemoveAllOrders();
        foreach (PlayerCombatOrderData playerCOD in playerCD.pcod)
        {
            combatSpeech.ImportOrderData(playerCOD.npcID, playerCOD.o, new Vector3(playerCOD.standAreaPosX, playerCOD.standAreaPosY, 0), new Vector3(playerCOD.watchAreaPosX, playerCOD.watchAreaPosY, 0));
        }

        //Import Progress Data
        combatHUDAttack.memory.Clear();
        GameManagerScript.ins.playerInfo.progress  = playerCD.pcqd.spellProgress;
        GameManagerScript.ins.playerInfo.wasLoaded = true;

        if (GameManagerScript.ins.playerInfo.spellQueue.Count > 0)
        {
            GameManagerScript.ins.playerInfo.spellQueue[0].loggedInfo.GetComponentInChildren <Image>().fillAmount = playerCD.pcqd.spellProgress / (GameManagerScript.ins.playerInfo.spellQueue[0].selectedSpell.castTime * 100);
        }
        combatSpeech.progress  = playerCD.pcqd.orderProgress;
        combatSpeech.wasLoaded = true;
        foreach (MemoryData md in playerCD.pcqd.memoryData)
        {
            combatHUDAttack.memory.Add(NPCManagerScript.ins.GetNPCInSceneFromID(md.npcID), new Vector3(md.posX, md.posY));
        }
    }
Exemple #6
0
    PlayerCombatData ExportPlayerCombatData()
    {
        PlayerCombatData playerCD = new PlayerCombatData();

        //Movement Data
        playerCD.pcmd = new List <PlayerCombatMovementData>();
        foreach (CombatHUDLog.Movement m in combatHUDLog.loggedMoves)
        {
            PlayerCombatMovementData playerCMD = new PlayerCombatMovementData();
            playerCMD.hash        = m.hash;
            playerCMD.destination = new List <PlayerCombatMovementDestination>();
            foreach (Vector3 v in m.destination)
            {
                PlayerCombatMovementDestination playerCMDestination = new PlayerCombatMovementDestination();
                playerCMDestination.posX = v.x;
                playerCMDestination.posY = v.y;
                playerCMD.destination.Add(playerCMDestination);
            }
            playerCD.pcmd.Add(playerCMD);
        }
        //Attack Data - Spell Queue
        playerCD.pcad = new List <PlayerCombatAttackData>();
        foreach (CombatHUDAttack.Attack a in GameManagerScript.ins.playerInfo.spellQueue)
        {
            PlayerCombatAttackData playerCAD = new PlayerCombatAttackData();
            playerCAD.selectedSpellID = a.selectedSpell.ID;
            playerCAD.selfCast        = a.selfCast;
            playerCAD.isCasting       = a.isCasting;
            playerCAD.fm   = a.fireMode;
            playerCAD.hash = a.hash;
            if (a.attackTarget != null)
            {
                playerCAD.attackTarget = a.attackTarget.GetComponent <CharacterInfo>().id;
            }
            else
            {
                playerCAD.attackTarget = 0;
            }
            playerCAD.attackPointPosX     = a.attackPoint.x;
            playerCAD.attackPointPosY     = a.attackPoint.y;
            playerCAD.attackPointModePosX = a.attackPointModePoint.x;
            playerCAD.attackPointModePosY = a.attackPointModePoint.y;
            playerCAD.attackDirectionX    = a.attackDirection.x;
            playerCAD.attackDirectionY    = a.attackDirection.y;
            playerCD.pcad.Add(playerCAD);
        }
        //Attack Data - On Line
        foreach (CombatHUDAttack.Attack a in combatHUDAttack.loggedAttacks)
        {
            PlayerCombatAttackData playerCAD = new PlayerCombatAttackData();
            playerCAD.selectedSpellID = a.selectedSpell.ID;
            playerCAD.selfCast        = a.selfCast;
            playerCAD.isCasting       = a.isCasting;
            playerCAD.fm   = a.fireMode;
            playerCAD.hash = a.hash;
            if (a.attackTarget != null)
            {
                playerCAD.attackTarget = a.attackTarget.GetComponent <CharacterInfo>().id;
            }
            else
            {
                playerCAD.attackTarget = 0;
            }
            playerCAD.attackPointPosX     = a.attackPoint.x;
            playerCAD.attackPointPosY     = a.attackPoint.y;
            playerCAD.attackPointModePosX = a.attackPointModePoint.x;
            playerCAD.attackPointModePosY = a.attackPointModePoint.y;
            playerCAD.attackDirectionX    = a.attackDirection.x;
            playerCAD.attackDirectionY    = a.attackDirection.y;
            playerCD.pcad.Add(playerCAD);
        }
        //Order Data
        playerCD.pcod = new List <PlayerCombatOrderData>();
        foreach (CombatSpeech.GivenOrder go in combatSpeech.givenOrders)
        {
            PlayerCombatOrderData playerCOD = new PlayerCombatOrderData();
            playerCOD.npcID = go.npc.GetComponent <CharacterInfo>().id;
            playerCOD.o     = go.o;
            if (go.standArea != null)
            {
                playerCOD.standAreaPosX = go.standArea.transform.position.x;
                playerCOD.standAreaPosY = go.standArea.transform.position.y;
            }
            if (go.watchArea != null)
            {
                playerCOD.watchAreaPosX = go.watchArea.transform.position.x;
                playerCOD.watchAreaPosY = go.watchArea.transform.position.y;
            }
            playerCD.pcod.Add(playerCOD);
        }
        //Progress Data
        playerCD.pcqd = new PlayerCombatQueueData();
        playerCD.pcqd.orderProgress = combatSpeech.progress;
        playerCD.pcqd.spellProgress = GameManagerScript.ins.playerInfo.progress;
        playerCD.pcqd.memoryData    = new List <MemoryData>();
        foreach (GameObject g in combatHUDAttack.memory.Keys)
        {
            MemoryData md = new MemoryData();
            md.npcID = g.GetComponent <CharacterInfo>().id;
            md.posX  = g.transform.position.x;
            md.posY  = g.transform.position.y;
            playerCD.pcqd.memoryData.Add(md);
        }

        return(playerCD);
    }
        public override void Initialize()
        {
            CombatData       combat  = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn);
            PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID);

            if (player1 == null)
            {
                this._app.UI.CloseDialog((Dialog)this, true);
            }
            else
            {
                IEnumerable <PlayerInfo> playerInfos    = this._app.GameDatabase.GetPlayerInfos();
                StarSystemInfo           starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID);
                string str1 = App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE");
                if (starSystemInfo != (StarSystemInfo)null)
                {
                    str1 = starSystemInfo.Name;
                }
                this._app.UI.SetPropertyString("summaryText", "text", "Combat - " + player1.VictoryStatus.ToString() + " at " + str1);
                int    num1   = 0;
                int    num2   = 0;
                float  val2_1 = 0.0f;
                float  val2_2 = 0.0f;
                double num3   = 0.0;
                double num4   = 0.0;
                float  num5   = 0.0f;
                double num6   = 0.0;
                double num7   = 0.0;
                float  num8   = 0.0f;
                int    num9   = 0;
                int    num10  = 0;
                Dictionary <int, float> dictionary1 = new Dictionary <int, float>();
                Dictionary <int, float> dictionary2 = new Dictionary <int, float>();
                foreach (PlayerInfo playerInfo in playerInfos)
                {
                    PlayerInfo       player  = playerInfo;
                    PlayerCombatData player2 = combat.GetPlayer(player.ID);
                    if (player2 != null)
                    {
                        DiplomacyInfo diplomacyInfo = this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID);
                        string        itemGlobalId1;
                        if (diplomacyInfo.State == DiplomacyState.WAR)
                        {
                            this._app.UI.AddItem("enemiesAvatars", "", player.ID, "");
                            itemGlobalId1 = this._app.UI.GetItemGlobalID("enemiesAvatars", "", player.ID, "");
                        }
                        else
                        {
                            this._app.UI.AddItem("alliesAvatars", "", player.ID, "");
                            itemGlobalId1 = this._app.UI.GetItemGlobalID("alliesAvatars", "", player.ID, "");
                        }
                        PlayerSetup playerSetup   = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID));
                        string      propertyValue = playerSetup == null ? player.Name : playerSetup.Name;
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "name"), "text", propertyValue);
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "playeravatar"), "texture", player.AvatarAssetPath);
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId1, "badge"), "texture", player.BadgeAssetPath);
                        this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId1, "primaryColor"), "color", player.PrimaryColor);
                        this._app.UI.SetPropertyColorNormalized(this._app.UI.Path(itemGlobalId1, "secondaryColor"), "color", player.SecondaryColor);
                        this._app.UI.AddItem("combatSummary", "", player.ID, "");
                        string itemGlobalId2 = this._app.UI.GetItemGlobalID("combatSummary", "", player.ID, "");
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "itemName"), "text", propertyValue);
                        List <ShipData>   shipData1   = player2.ShipData;
                        List <WeaponData> weaponData1 = player2.WeaponData;
                        List <PlanetData> planetData1 = player2.PlanetData;
                        int   count  = shipData1.Count;
                        int   num11  = 0;
                        float val1_1 = 0.0f;
                        float val1_2 = 0.0f;
                        Dictionary <int, string> dictionary3 = new Dictionary <int, string>();
                        foreach (ShipData shipData2 in shipData1)
                        {
                            num11  += shipData2.killCount;
                            val1_1 += shipData2.damageDealt;
                            val1_2 += shipData2.damageReceived;
                            if (diplomacyInfo.State == DiplomacyState.WAR)
                            {
                                num10 += shipData2.destroyed ? 1 : 0;
                            }
                            else
                            {
                                num9 += shipData2.destroyed ? 1 : 0;
                            }
                            if (!dictionary3.ContainsKey(shipData2.designID))
                            {
                                this._app.UI.AddItem(this._app.UI.Path(itemGlobalId2, "shipList"), "", shipData2.designID, "");
                                dictionary3.Add(shipData2.designID, this._app.UI.GetItemGlobalID(this._app.UI.Path(itemGlobalId2, "shipList"), "", shipData2.designID, ""));
                            }
                        }
                        foreach (WeaponData weaponData2 in weaponData1)
                        {
                            if (diplomacyInfo.State == DiplomacyState.WAR)
                            {
                                if (!dictionary2.ContainsKey(weaponData2.weaponID))
                                {
                                    dictionary2.Add(weaponData2.weaponID, 0.0f);
                                }
                                Dictionary <int, float> dictionary4;
                                int weaponId;
                                (dictionary4 = dictionary2)[weaponId = weaponData2.weaponID] = dictionary4[weaponId] + weaponData2.damageDealt;
                            }
                            else
                            {
                                if (!dictionary1.ContainsKey(weaponData2.weaponID))
                                {
                                    dictionary1.Add(weaponData2.weaponID, 0.0f);
                                }
                                Dictionary <int, float> dictionary4;
                                int weaponId;
                                (dictionary4 = dictionary1)[weaponId = weaponData2.weaponID] = dictionary4[weaponId] + weaponData2.damageDealt;
                            }
                        }
                        foreach (PlanetData planetData2 in planetData1)
                        {
                            ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetData2.orbitalObjectID);
                            if (colonyInfoForPlanet != null)
                            {
                                if (colonyInfoForPlanet.PlayerID != this._app.LocalPlayer.ID)
                                {
                                    num3 += planetData2.imperialDamage;
                                    num4 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage));
                                    num5 += planetData2.infrastructureDamage;
                                }
                                else
                                {
                                    num6 += planetData2.imperialDamage;
                                    num7 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage));
                                    num8 += planetData2.infrastructureDamage;
                                }
                            }
                        }
                        foreach (int key in dictionary3.Keys)
                        {
                            int        des        = key;
                            DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(des);
                            int        num12      = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Count <ShipData>();
                            this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "stotalUnits"), 0, count);
                            this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "stotalUnits"), num12);
                            this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "stotalUnitsLabel"), "text", num12.ToString());
                            int num13 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, int>)(x => x.killCount));
                            this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdestroyedUnits"), 0, num11);
                            this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdestroyedUnits"), num13);
                            this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdestroyedUnitsLabel"), "text", num13.ToString());
                            float num14 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, float>)(x => x.damageDealt));
                            this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdamageInflicted"), 0, (int)val1_1);
                            this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdamageInflicted"), (int)num14);
                            this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdamageInflictedLabel"), "text", num14.ToString("N0"));
                            float num15 = shipData1.Where <ShipData>((Func <ShipData, bool>)(x => x.designID == des)).Sum <ShipData>((Func <ShipData, float>)(x => x.damageReceived));
                            this._app.UI.SetSliderRange(this._app.UI.Path(dictionary3[des], "sdamageTaken"), 0, (int)val1_2);
                            this._app.UI.SetSliderValue(this._app.UI.Path(dictionary3[des], "sdamageTaken"), (int)num15);
                            this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "sdamageTakenLabel"), "text", num15.ToString("N0"));
                            this._app.UI.SetPropertyString(this._app.UI.Path(dictionary3[des], "subitem_label"), "text", designInfo.Name);
                        }
                        num1   = Math.Max(count, num1);
                        num2   = Math.Max(num11, num2);
                        val2_1 = Math.Max(val1_1, val2_1);
                        val2_2 = Math.Max(val1_2, val2_2);
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "totalUnits"), 0, count);
                        this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "totalUnits"), count);
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "totalUnitsLabel"), "text", count.ToString());
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "destroyedUnits"), 0, num11);
                        this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "destroyedUnits"), num11);
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "destroyedUnitsLabel"), "text", num11.ToString());
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "damageInflicted"), 0, (int)val1_1);
                        this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "damageInflicted"), (int)val1_1);
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "damageInflictedLabel"), "text", val1_1.ToString("N0"));
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId2, "damageTaken"), 0, (int)val1_2);
                        this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId2, "damageTaken"), (int)val1_2);
                        this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId2, "damageTakenLabel"), "text", val1_2.ToString("N0"));
                    }
                }
                foreach (PlayerInfo playerInfo in playerInfos)
                {
                    if (combat.GetPlayer(playerInfo.ID) != null)
                    {
                        string itemGlobalId = this._app.UI.GetItemGlobalID("combatSummary", "", playerInfo.ID, "");
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "totalUnits"), 0, num1);
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "destroyedUnits"), 0, num2);
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "damageInflicted"), 0, (int)val2_1);
                        this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "damageTaken"), 0, (int)val2_2);
                    }
                }
                foreach (int key in dictionary1.Keys)
                {
                    int weapon = key;
                    this._app.UI.AddItem("alliedWeaponList", "", weapon, "");
                    string itemGlobalId = this._app.UI.GetItemGlobalID("alliedWeaponList", "", weapon, "");
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "damageDealt"), "text", dictionary1[weapon].ToString("N0"));
                    LogicalWeapon logicalWeapon  = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon));
                    string        iconSpriteName = logicalWeapon.IconSpriteName;
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "weaponIcon"), "sprite", iconSpriteName);
                    this._app.UI.SetPropertyString(itemGlobalId, "tooltip", logicalWeapon.WeaponName);
                }
                foreach (int key in dictionary2.Keys)
                {
                    int weapon = key;
                    this._app.UI.AddItem("enemyWeaponList", "", weapon, "");
                    string itemGlobalId = this._app.UI.GetItemGlobalID("enemyWeaponList", "", weapon, "");
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "damageDealt"), "text", dictionary2[weapon].ToString("N0"));
                    string iconSpriteName = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon)).IconSpriteName;
                    this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "weaponIcon"), "sprite", iconSpriteName);
                }
                int    num16 = 0;
                string text1 = "";
                if (num7 > 0.0 && num6 > 0.0)
                {
                    text1 = text1 + num6.ToString("N0") + " Imperialists and " + num7.ToString("N0") + " civilians lost. ";
                }
                else if (num7 > 0.0)
                {
                    text1 = text1 + num7.ToString("N0") + " civilians lost. ";
                }
                else if (num6 > 0.0)
                {
                    text1 = text1 + num6.ToString("N0") + " Imperialists lost. ";
                }
                if (num4 > 0.0 && num3 > 0.0)
                {
                    text1 = text1 + num3.ToString("N0") + " enemy Imperialists and " + num4.ToString("N0") + " enemy civilians killed.";
                }
                else if (num4 > 0.0)
                {
                    text1 = text1 + num4.ToString("N0") + " enemy civilians killed.";
                }
                else if (num3 > 0.0)
                {
                    text1 = text1 + num3.ToString("N0") + " enemy Imperialists killed.";
                }
                if (text1.Length > 0)
                {
                    this._app.UI.AddItem("happenings", "", num16++, text1);
                }
                string text2 = "";
                float  num17;
                if ((double)num8 > 0.01)
                {
                    string str2 = text2;
                    num17 = num8 * 100f;
                    string str3 = num17.ToString("#0.00");
                    text2 = str2 + "Infrastructure reduced by " + str3 + "%";
                }
                if ((double)num5 > 0.01)
                {
                    string str2 = text2;
                    num17 = num5 * 100f;
                    string str3 = num17.ToString("#0.00");
                    text2 = str2 + " Enemy infrastructure reduced by " + str3 + "%";
                }
                if (text2.Length > 0)
                {
                    this._app.UI.AddItem("happenings", "", num16++, text2);
                }
                string str4 = "";
                if (num9 > 0)
                {
                    str4 = num9 <= 1 ? str4 + num9.ToString() + " friendly ship lost. " : str4 + num9.ToString() + " friendly ships lost. ";
                }
                if (num10 > 0)
                {
                    str4 = num9 <= 1 ? str4 + num10.ToString() + " enemy ship destroyed." : str4 + num10.ToString() + " enemy ships destroyed.";
                }
                if (str4.Length <= 0)
                {
                    return;
                }
                UICommChannel ui         = this._app.UI;
                int           userItemId = num16;
                int           num18      = userItemId + 1;
                string        text3      = str4;
                ui.AddItem("happenings", "", userItemId, text3);
            }
        }