public void ShowBuildings(List <Transform> warBuildingLocators)
        {
            if (this.assetHandles == null)
            {
                this.assetHandles = new List <AssetHandle>();
            }
            if (this.outline == null)
            {
                this.outline = new OutlinedAsset();
            }
            this.pressedBuilding     = null;
            this.pressTimerId        = 0u;
            this.pressScreenPosition = Vector2.zero;
            this.selectedBuilding    = null;
            this.dragged             = false;
            this.CacheHQBuildingIds();
            BuildingUpgradeCatalog catalog      = Service.Get <BuildingUpgradeCatalog>();
            AssetManager           assetManager = Service.Get <AssetManager>();
            SquadWarManager        warManager   = Service.Get <SquadController>().WarManager;
            SquadWarSquadData      squadData    = warManager.GetSquadData(SquadWarSquadType.PLAYER_SQUAD);

            this.AddBuildingsForParticipants(squadData, true, catalog, assetManager, warBuildingLocators);
            SquadWarSquadData squadData2 = warManager.GetSquadData(SquadWarSquadType.OPPONENT_SQUAD);

            this.AddBuildingsForParticipants(squadData2, false, catalog, assetManager, warBuildingLocators);
            Service.Get <UserInputManager>().RegisterObserver(this, UserInputLayer.World);
        }
Пример #2
0
        private static BattleInitializationData CreateBuffBaseBattleFromBattleTypeVO(string id, SquadWarBuffBaseData buffBaseData)
        {
            BattleInitializationData battleInitializationData = BattleInitializationData.CreateFromBattleTypeVO(id);

            battleInitializationData.BattleType                   = BattleType.PveBuffBase;
            battleInitializationData.Attacker.GuildId             = Service.SquadController.StateManager.GetCurrentSquad().SquadID;
            battleInitializationData.AttackerGuildTroopsAvailable = BattleInitializationData.GetCurrentPlayerGuildTroops();
            SquadWarManager warManager = Service.SquadController.WarManager;

            battleInitializationData.AttackerWarBuffs = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Attacker.GuildId);
            battleInitializationData.DefenderWarBuffs = null;
            SquadWarSquadData squadData  = warManager.GetSquadData(SquadWarSquadType.PLAYER_SQUAD);
            SquadWarSquadData squadData2 = warManager.GetSquadData(SquadWarSquadType.OPPONENT_SQUAD);
            string            ownerId    = buffBaseData.OwnerId;

            if (!string.IsNullOrEmpty(ownerId))
            {
                if (ownerId == squadData2.SquadId)
                {
                    battleInitializationData.Defender.PlayerFaction = squadData2.Faction;
                }
                else if (ownerId == squadData.SquadId)
                {
                    battleInitializationData.Defender.PlayerFaction = squadData.Faction;
                }
            }
            else
            {
                battleInitializationData.Defender.PlayerFaction = FactionType.Smuggler;
            }
            battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId);
            battleInitializationData.DefenderEquipment = null;
            return(battleInitializationData);
        }
Пример #3
0
        private SquadWarParticipantState GetAdjacentParticipant(SquadWarParticipantState start, int direction)
        {
            SquadWarData currentSquadWar = Service.Get <SquadController>().WarManager.CurrentSquadWar;

            if (currentSquadWar == null)
            {
                return(start);
            }
            SquadWarSquadData squadWarSquadData = null;
            int num  = -1;
            int i    = 0;
            int num2 = currentSquadWar.Squads.Length;

            while (i < num2)
            {
                num = currentSquadWar.Squads[i].Participants.IndexOf(start);
                if (num != -1)
                {
                    squadWarSquadData = currentSquadWar.Squads[i];
                    break;
                }
                i++;
            }
            if (num == -1)
            {
                return(start);
            }
            int count = squadWarSquadData.Participants.Count;
            int index = (count + num + direction) % count;

            return(squadWarSquadData.Participants[index]);
        }
Пример #4
0
        public override void RefreshView()
        {
            if (!base.IsLoaded())
            {
                return;
            }
            SquadWarManager   warManager       = Service.Get <SquadController>().WarManager;
            SquadWarSquadType participantSquad = warManager.GetParticipantSquad(this.participantState.SquadMemberId);
            SquadWarSquadData squadData        = warManager.GetSquadData(participantSquad);

            this.playerNameLabel.Text = this.lang.Get("WAR_PLAYER_DETAILS_NAME", new object[]
            {
                this.participantState.SquadMemberName,
                this.participantState.HQLevel
            });
            this.attacksRemainingLabel.Text = this.lang.Get("WAR_PLAYER_DETAILS_TURNS_LEFT", new object[]
            {
                this.participantState.TurnsLeft
            });
            this.uplinksAvailableLabel.Text = this.lang.Get("WAR_PLAYER_DETAILS_POINTS_LEFT", new object[]
            {
                this.participantState.VictoryPointsLeft
            });
            FactionIconUpgradeController factionIconUpgradeController = Service.Get <FactionIconUpgradeController>();
            int    rating = GameUtils.CalculateVictoryRating(this.participantState.AttacksWon, this.participantState.DefensesWon);
            string icon   = factionIconUpgradeController.GetIcon(squadData.Faction, rating);

            if (factionIconUpgradeController.UseUpgradeImage(rating))
            {
                this.factionSprite.SpriteName     = icon;
                this.factionSprite.Visible        = true;
                this.factionDefaultSprite.Visible = false;
            }
            else
            {
                this.factionSprite.Visible           = false;
                this.factionDefaultSprite.Visible    = true;
                this.factionDefaultSprite.SpriteName = icon;
            }
            string empty = string.Empty;

            if (warManager.CanScoutWarMember(this.participantState.SquadMemberId, ref empty))
            {
                this.scoutButton.VisuallyEnableButton();
                this.scoutButtonLabel.TextColor = this.scoutButtonLabel.OriginalTextColor;
            }
            else
            {
                this.scoutButton.VisuallyDisableButton();
                this.scoutButtonLabel.TextColor = UXUtils.COLOR_LABEL_DISABLED;
            }
            this.UpdateUplinkHelper(0, this.participantState.VictoryPointsLeft >= 3, "WAR_PLAYER_DETAILS_REQ_1");
            this.UpdateUplinkHelper(1, this.participantState.VictoryPointsLeft >= 2, "WAR_PLAYER_DETAILS_REQ_2");
            this.UpdateUplinkHelper(2, this.participantState.VictoryPointsLeft >= 1, "WAR_PLAYER_DETAILS_REQ_3");
        }
        private void AddBuildingsForParticipants(SquadWarSquadData squadData, bool isForPlayerSquad, BuildingUpgradeCatalog catalog, AssetManager assetManager, List <Transform> warBuildingLocators)
        {
            List <SquadWarParticipantState> list = new List <SquadWarParticipantState>(squadData.Participants);

            list.Sort(new Comparison <SquadWarParticipantState>(this.SortParticipantsAsc));
            string upgradeGroup = (squadData.Faction == FactionType.Empire) ? this.empireHQId : this.rebelHQId;
            bool   isEmpire     = squadData.Faction == FactionType.Empire;
            int    i            = 0;
            int    count        = list.Count;

            while (i < count)
            {
                BuildingTypeVO byLevel = catalog.GetByLevel(upgradeGroup, list[i].HQLevel);
                if (byLevel != null)
                {
                    this.AddBuildingForParticipant(list[i], byLevel, isForPlayerSquad, isEmpire, i, assetManager, warBuildingLocators[i]);
                }
                i++;
            }
        }
Пример #6
0
        public static SquadMsg GenerateMessageFromGetSquadWarStatusResponse(GetSquadWarStatusResponse response)
        {
            SquadWarSquadData           squadWarSquadData  = new SquadWarSquadData();
            SquadWarSquadData           squadWarSquadData2 = new SquadWarSquadData();
            List <SquadWarBuffBaseData> list = new List <SquadWarBuffBaseData>();

            squadWarSquadData.FromObject(response.Squad1Data);
            squadWarSquadData2.FromObject(response.Squad2Data);
            List <object> list2 = response.BuffBaseData as List <object>;
            int           i     = 0;
            int           count = list2.Count;

            while (i < count)
            {
                SquadWarBuffBaseData squadWarBuffBaseData = new SquadWarBuffBaseData();
                squadWarBuffBaseData.FromObject(list2[i]);
                list.Add(squadWarBuffBaseData);
                i++;
            }
            SquadWarData squadWarData = new SquadWarData();

            squadWarData.WarId     = response.Id;
            squadWarData.Squads[0] = squadWarSquadData;
            squadWarData.Squads[1] = squadWarSquadData2;
            squadWarData.BuffBases = list;
            squadWarData.PrepGraceStartTimeStamp   = response.PrepGraceStartTimeStamp;
            squadWarData.PrepEndTimeStamp          = response.PrepEndTimeStamp;
            squadWarData.ActionGraceStartTimeStamp = response.ActionGraceStartTimeStamp;
            squadWarData.ActionEndTimeStamp        = response.ActionEndTimeStamp;
            squadWarData.StartTimeStamp            = response.StartTimeStamp;
            squadWarData.CooldownEndTimeStamp      = response.CooldownEndTimeStamp;
            squadWarData.RewardsProcessed          = response.RewardsProcessed;
            return(new SquadMsg
            {
                CurrentSquadWarData = squadWarData
            });
        }
Пример #7
0
        private void Refresh()
        {
            WarBuffVO         warBuffVO   = Service.Get <IDataController>().Get <WarBuffVO>(this.buffBaseData.BuffBaseId);
            SquadWarManager   warManager  = Service.Get <SquadController>().WarManager;
            SquadWarSquadData squadData   = warManager.GetSquadData(this.buffBaseData.OwnerId);
            FactionType       factionType = FactionType.Neutral;
            string            text        = this.buffBaseData.GetDisplayBaseLevel().ToString();

            if (squadData != null)
            {
                factionType = squadData.Faction;
            }
            string uid;
            string text2;

            if (factionType == FactionType.Empire)
            {
                uid   = warBuffVO.MasterEmpireBuildingUid;
                text2 = LangUtils.GetFactionName(factionType);
            }
            else if (factionType == FactionType.Rebel)
            {
                uid   = warBuffVO.MasterRebelBuildingUid;
                text2 = LangUtils.GetFactionName(factionType);
            }
            else
            {
                uid   = warBuffVO.MasterNeutralBuildingUid;
                text2 = this.lang.Get("BUFF_BASE_UNOWNED_FACTION_NAME", new object[0]);
            }
            this.spriteFactionIcon.SpriteName = UXUtils.GetIconNameFromFactionType(factionType);
            this.labelBuffBaseName.Text       = this.lang.Get("WAR_BOARD_BUFF_BASE_TITLE", new object[]
            {
                this.lang.Get(warBuffVO.BuffBaseName, new object[0]),
                LangUtils.GetPlanetDisplayName(warBuffVO.PlanetId)
            });
            this.labelBuffBaseLevel.Text = this.lang.Get("WAR_BOARD_BUFF_BASE_LEVEL", new object[]
            {
                text,
                text2
            });
            this.labelCaptureRequirement.Text = this.lang.Get("WAR_BOARD_BUFF_BASE_CAPTURE_REQUIREMENT", new object[0]);
            this.labelProduces.Text           = this.lang.Get("BUFF_BASE_PRODUCES", new object[0]);
            this.labelBuffDescription.Text    = this.lang.Get(warBuffVO.BuffStringDesc, new object[0]);
            this.labelLocked.Text             = this.lang.Get("PLANET_LOCKED_REQUIREMENT", new object[0]);
            this.labelLocked.Visible          = !Service.Get <CurrentPlayer>().IsPlanetUnlocked(warBuffVO.PlanetId);
            TextureVO       textureVO      = null;
            IDataController dataController = Service.Get <IDataController>();

            if (warBuffVO.PlanetId == GameConstants.TATOOINE_PLANET_UID)
            {
                textureVO = dataController.GetOptional <TextureVO>("squadwars_basedetails_tatooine");
            }
            else if (warBuffVO.PlanetId == GameConstants.YAVIN_PLANET_UID)
            {
                textureVO = dataController.GetOptional <TextureVO>("squadwars_basedetails_yavin");
            }
            else if (warBuffVO.PlanetId == GameConstants.DANDORAN_PLANET_UID)
            {
                textureVO = dataController.GetOptional <TextureVO>("squadwars_basedetails_dandoran");
            }
            else if (warBuffVO.PlanetId == GameConstants.ERKIT_PLANET_UID)
            {
                textureVO = dataController.GetOptional <TextureVO>("squadwars_basedetails_erkit");
            }
            else if (warBuffVO.PlanetId == GameConstants.TFA_PLANET_UID)
            {
                textureVO = dataController.GetOptional <TextureVO>("squadwars_basedetails_tfa");
            }
            else if (warBuffVO.PlanetId == GameConstants.HOTH_PLANET_UID)
            {
                textureVO = dataController.GetOptional <TextureVO>("squadwars_basedetails_hoth");
            }
            if (textureVO != null)
            {
                this.textureBaseDetail.LoadTexture(textureVO.AssetName);
            }
            BuildingTypeVO data = Service.Get <IDataController>().Get <BuildingTypeVO>(uid);

            UXUtils.SetupGeometryForIcon(this.spriteBuffBaseIcon, data);
            this.spriteBuffIcon.SpriteName = warBuffVO.BuffIcon;
            string empty = string.Empty;

            if (warManager.CanScoutBuffBase(this.buffBaseData, ref empty))
            {
                this.btnScout.VisuallyEnableButton();
                this.labelScout.TextColor = this.labelScout.OriginalTextColor;
                return;
            }
            this.btnScout.VisuallyDisableButton();
            this.labelScout.TextColor = UXUtils.COLOR_LABEL_DISABLED;
        }