Exemplo n.º 1
0
 public override void RefreshView()
 {
     this.UpdateMembers();
     if (Service.SquadController.WarManager.MatchMakingPrepMode)
     {
         this.groupStartWarBtns.Visible = true;
         this.memberPanel.SetPanelUnifiedAnchorBottomOffset(120);
         SquadController squadController = Service.SquadController;
         SquadWarManager warManager      = squadController.WarManager;
         int             warPartyCount   = warManager.GetWarPartyCount();
         this.labelStartWarSelected.Text = this.lang.Get("WAR_MEMBERS_SELECTED", new object[]
         {
             warPartyCount,
             GameConstants.WAR_PARTICIPANT_COUNT
         });
         if (warPartyCount < GameConstants.WAR_PARTICIPANT_COUNT)
         {
             this.btnStartWarConfirm.Enabled = false;
             this.btnStartWarConfirm.VisuallyDisableButton();
         }
         else
         {
             this.btnStartWarConfirm.Enabled = true;
             this.btnStartWarConfirm.VisuallyEnableButton();
         }
     }
     else
     {
         this.groupStartWarBtns.Visible = false;
         this.memberPanel.SetPanelUnifiedAnchorBottomOffset(15);
     }
 }
Exemplo n.º 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);
        }
        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);
        }
Exemplo n.º 4
0
        private void OnCancelStartWar(UXButton button)
        {
            SquadWarManager warManager = Service.SquadController.WarManager;

            warManager.CancelEnteringMatchmaking();
            this.screen.RefreshViews();
        }
Exemplo n.º 5
0
        public static BattleInitializationData CreateFromMemberWarData(SquadMemberWarData memberWarData, Dictionary <string, int> donatedSquadTroops, Dictionary <string, int> champions, FactionType faction, string participantSquadId, List <string> equipment)
        {
            BattleInitializationData battleInitializationData = new BattleInitializationData();

            battleInitializationData.BattleType = BattleType.PvpAttackSquadWar;
            CurrentPlayer currentPlayer = Service.CurrentPlayer;

            battleInitializationData.Attacker                     = new BattleParticipant(currentPlayer.PlayerId, currentPlayer.PlayerName, currentPlayer.Faction);
            battleInitializationData.Attacker.GuildId             = Service.SquadController.StateManager.GetCurrentSquad().SquadID;
            battleInitializationData.Defender                     = new BattleParticipant(memberWarData.SquadMemberId, memberWarData.SquadMemberName, faction);
            battleInitializationData.Defender.GuildId             = participantSquadId;
            battleInitializationData.AttackerDeployableData       = BattleDeploymentData.CreateEmpty();
            battleInitializationData.DefenderDeployableData       = BattleDeploymentData.CreateEmpty();
            battleInitializationData.AllowMultipleHeroDeploys     = false;
            battleInitializationData.OverrideDeployables          = false;
            battleInitializationData.BattleLength                 = GameConstants.PVP_MATCH_DURATION;
            battleInitializationData.PlanetId                     = memberWarData.BaseMap.Planet.Uid;
            battleInitializationData.MemberWarData                = memberWarData;
            battleInitializationData.VictoryConditions            = Service.VictoryConditionController.GetDefaultConditions();
            battleInitializationData.DefenderGuildTroopsAvailable = donatedSquadTroops;
            battleInitializationData.DefenderChampionsAvailable   = champions;
            battleInitializationData.AttackerGuildTroopsAvailable = BattleInitializationData.GetCurrentPlayerGuildTroops();
            battleInitializationData.DisabledBuildings            = null;
            battleInitializationData.IsReplay                     = false;
            battleInitializationData.IsRevenge                    = false;
            battleInitializationData.AllowReplay                  = true;
            SquadWarManager warManager = Service.SquadController.WarManager;

            battleInitializationData.AttackerWarBuffs  = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Attacker.GuildId);
            battleInitializationData.DefenderWarBuffs  = warManager.GetBuffBasesOwnedBySquad(battleInitializationData.Defender.GuildId);
            battleInitializationData.AttackerEquipment = BattleInitializationData.GetCurrentPlayerEquipment(battleInitializationData.PlanetId);
            battleInitializationData.DefenderEquipment = equipment;
            return(battleInitializationData);
        }
Exemplo n.º 6
0
        public void ShowParticipantOptions(GameObject obj, SquadWarParticipantState state)
        {
            if (this.opponentState != null && this.opponentState == state)
            {
                return;
            }
            this.opponentState    = state;
            this.buffBaseData     = null;
            this.Visible          = true;
            this.transformToTrack = obj.transform;
            this.animator.Play("Off", 0, 1f);
            this.animator.ResetTrigger("Off");
            this.animator.ResetTrigger("ShowBottom");
            this.animator.SetTrigger("ShowTop");
            SquadWarManager warManager = Service.Get <SquadController>().WarManager;
            string          empty      = string.Empty;

            if (warManager.CanScoutWarMember(this.opponentState.SquadMemberId, ref empty))
            {
                this.scoutMemberButton.VisuallyEnableButton();
                this.scoutMemberLabel.TextColor = this.scoutBuffBaseLabel.OriginalTextColor;
            }
            else
            {
                this.scoutMemberButton.VisuallyDisableButton();
                this.scoutMemberLabel.TextColor = UXUtils.COLOR_LABEL_DISABLED;
            }
            this.PlayShowAudioClip();
            Service.Get <ViewTimeEngine>().RegisterFrameTimeObserver(this);
        }
Exemplo n.º 7
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");
        }
Exemplo n.º 8
0
        public List <IAssetVO> GetProjectilePreloads(Map map)
        {
            List <string> attackerWarBuffs = null;
            List <string> defenderWarBuffs = null;
            Squad         currentSquad     = Service.SquadController.StateManager.GetCurrentSquad();

            if (currentSquad != null)
            {
                SquadWarManager warManager = Service.SquadController.WarManager;
                attackerWarBuffs = warManager.GetBuffBasesOwnedBySquad(currentSquad.SquadID);
                defenderWarBuffs = warManager.GetBuffBasesOwnedBySquad(this.squadId);
            }
            return(ProjectileUtils.GetBattleProjectileAssets(map, null, null, attackerWarBuffs, defenderWarBuffs, this.defenderSquadTroops, this.defenderChampions, this.battleData.AttackerEquipment, this.battleData.DefenderEquipment));
        }
Exemplo n.º 9
0
        public override void HideView()
        {
            this.memberContainer.Visible = false;
            EventManager eventManager = Service.EventManager;

            eventManager.UnregisterObserver(this, EventId.SquadDetailsUpdated);
            this.tabButton.Selected = false;
            SquadWarManager warManager = Service.SquadController.WarManager;

            if (warManager.MatchMakingPrepMode)
            {
                warManager.CancelEnteringMatchmaking();
            }
        }
Exemplo n.º 10
0
 private void OnWarBoardLoaded(object asset, object cookie)
 {
     this.warBoard = (GameObject)asset;
     this.warBoardLoadSequenceFinished = true;
     this.maxRotation = 11f;
     this.minRotation = -7f;
     if (this.warBoard != null)
     {
         this.warBoardTransform               = this.warBoard.transform;
         this.warBoardTransform.parent        = this.warboardMasterTransform;
         this.warBoardTransform.localPosition = Vector3.zero;
         this.warBoardTransform.localRotation = Quaternion.identity;
         this.warBoard.SetActive(false);
         this.WarBuildingLocators.Clear();
         this.locatorGroup = this.warBoard.transform.Find("planet_surface");
         if (this.locatorGroup != null)
         {
             SquadController squadController = Service.SquadController;
             SquadWarManager warManager      = squadController.WarManager;
             int             numParticipants = warManager.NumParticipants;
             Transform       transform       = null;
             for (int i = 0; i < numParticipants; i++)
             {
                 string name = "locator" + i.ToString();
                 transform = this.locatorGroup.Find(name);
                 this.WarBuildingLocators.Add(transform);
                 if (i == 1)
                 {
                     this.maxRotation = -transform.localEulerAngles.x + -1.72057f;
                 }
             }
             if (transform != null)
             {
                 this.minRotation = -transform.localEulerAngles.x + -1.72057f;
             }
             AnimationCurve animationCurve = new AnimationCurve(this.animationKeys);
             if (this.rotateTween != null)
             {
                 this.rotateTween.Destroy();
                 this.rotateTween = null;
             }
             this.rotateTween = new RotateTween(this.locatorGroup, 1.5f, Quaternion.Euler(new Vector3(this.minRotation + -1.72057f, 0f, 0f)), Quaternion.Euler(new Vector3(this.maxRotation + -1.72057f, 0f, 0f)), animationCurve, null, null);
             Service.WarBoardBuildingController.ShowBuildings(this.WarBuildingLocators);
             Service.UserInputManager.RegisterObserver(this, UserInputLayer.InternalLowest);
         }
     }
     this.CheckForAllLoadsComplete();
 }
Exemplo n.º 11
0
        private void OnCollectButtonClicked(UXButton button)
        {
            string text = button.Tag as string;

            this.HideCollectButton(text);
            SquadWarManager warManager      = Service.Get <SquadController>().WarManager;
            SquadWarData    currentSquadWar = warManager.CurrentSquadWar;

            if (currentSquadWar != null && currentSquadWar.WarId == text && warManager.GetCurrentStatus() == SquadWarStatusType.PhaseCooldown && !(Service.Get <GameStateMachine>().CurrentState is GalaxyState))
            {
                Service.Get <UXController>().HUD.SlideSquadScreenClosedInstantly();
                warManager.EnterWarBoardMode();
                return;
            }
            warManager.ClaimSquadWarReward(text);
        }
Exemplo n.º 12
0
        public SquadWarSquadType GetCurrentDisplaySquad()
        {
            SquadWarManager    warManager    = Service.Get <SquadController>().WarManager;
            SquadWarStatusType currentStatus = warManager.GetCurrentStatus();
            SquadWarSquadType  result        = SquadWarSquadType.PLAYER_SQUAD;

            if (currentStatus == SquadWarStatusType.PhasePrep || currentStatus == SquadWarStatusType.PhasePrepGrace)
            {
                result = SquadWarSquadType.PLAYER_SQUAD;
            }
            else if (currentStatus == SquadWarStatusType.PhaseAction || currentStatus == SquadWarStatusType.PhaseActionGrace || currentStatus == SquadWarStatusType.PhaseCooldown)
            {
                result = SquadWarSquadType.OPPONENT_SQUAD;
            }
            return(result);
        }
Exemplo n.º 13
0
 private void OnScoutButton(UXButton button)
 {
     if (this.buffBaseData != null)
     {
         SquadWarManager warManager = Service.SquadController.WarManager;
         string          empty      = string.Empty;
         if (warManager.CanScoutBuffBase(this.buffBaseData, ref empty))
         {
             string buffBaseId = this.buffBaseData.BuffBaseId;
             if (Service.SquadController.WarManager.ScoutBuffBase(buffBaseId))
             {
                 this.Close(null);
             }
         }
         else
         {
             Service.UXController.MiscElementsManager.ShowPlayerInstructions(empty);
         }
     }
 }
Exemplo n.º 14
0
 private void OnScoutMemberClicked(UXButton button)
 {
     if (this.opponentState != null)
     {
         SquadWarManager warManager = Service.SquadController.WarManager;
         string          empty      = string.Empty;
         if (warManager.CanScoutWarMember(this.opponentState.SquadMemberId, ref empty))
         {
             string squadMemberId = this.opponentState.SquadMemberId;
             if (warManager.ScoutWarMember(squadMemberId))
             {
                 this.Hide();
             }
         }
         else
         {
             Service.UXController.MiscElementsManager.ShowPlayerInstructions(empty);
         }
     }
 }
Exemplo n.º 15
0
 private void OnScoutBuffBaseClicked(UXButton button)
 {
     if (this.buffBaseData != null)
     {
         SquadWarManager warManager = Service.Get <SquadController>().WarManager;
         string          empty      = string.Empty;
         if (warManager.CanScoutBuffBase(this.buffBaseData, ref empty))
         {
             string buffBaseId = this.buffBaseData.BuffBaseId;
             if (Service.Get <SquadController>().WarManager.ScoutBuffBase(buffBaseId))
             {
                 this.Hide();
                 return;
             }
         }
         else
         {
             Service.Get <UXController>().MiscElementsManager.ShowPlayerInstructions(empty);
         }
     }
 }
Exemplo n.º 16
0
 private void OnScoutClicked(UXButton button)
 {
     if (this.participantState != null)
     {
         SquadWarManager warManager = Service.Get <SquadController>().WarManager;
         string          empty      = string.Empty;
         if (warManager.CanScoutWarMember(this.participantState.SquadMemberId, ref empty))
         {
             string squadMemberId = this.participantState.SquadMemberId;
             if (warManager.ScoutWarMember(squadMemberId))
             {
                 this.Close(null);
                 return;
             }
         }
         else
         {
             Service.Get <UXController>().MiscElementsManager.ShowPlayerInstructions(empty);
         }
     }
 }
Exemplo n.º 17
0
        private void OnStartWarConfirm(UXButton button)
        {
            SquadWarManager warManager = Service.SquadController.WarManager;

            warManager.StartMatchMaking(this.allowSameFaction);
            IState currentState = Service.GameStateMachine.CurrentState;

            if (currentState is WarBoardState)
            {
                this.screen.InstantClose(false, null);
                SquadWarScreen highestLevelScreen = Service.ScreenController.GetHighestLevelScreen <SquadWarScreen>();
                if (highestLevelScreen != null)
                {
                    highestLevelScreen.CloseSquadWarScreen(null);
                }
            }
            else
            {
                this.screen.AnimateClosed(false, null);
            }
        }
Exemplo n.º 18
0
        public void ShowBuffBaseOptions(UXCheckbox checkbox, SquadWarBuffBaseData data)
        {
            if (this.buffBaseData != null && this.buffBaseData == data)
            {
                return;
            }
            this.buffBaseData     = data;
            this.opponentState    = null;
            this.Visible          = true;
            this.transformToTrack = null;
            Vector3[] worldCorners = checkbox.GetWorldCorners();
            Vector3   position     = checkbox.Root.transform.position;

            if (worldCorners != null)
            {
                position.y = worldCorners[0].y;
            }
            this.rootTrans.position = position;
            this.animator.Play("Off", 0, 1f);
            this.animator.ResetTrigger("Off");
            this.animator.ResetTrigger("ShowTop");
            this.animator.SetTrigger("ShowBottom");
            SquadWarManager warManager = Service.Get <SquadController>().WarManager;
            string          empty      = string.Empty;

            if (warManager.CanScoutBuffBase(this.buffBaseData, ref empty))
            {
                this.scoutBuffBaseButton.VisuallyEnableButton();
                this.scoutBuffBaseLabel.TextColor = this.scoutBuffBaseLabel.OriginalTextColor;
            }
            else
            {
                this.scoutBuffBaseButton.VisuallyDisableButton();
                this.scoutBuffBaseLabel.TextColor = UXUtils.COLOR_LABEL_DISABLED;
            }
            this.PlayShowAudioClip();
        }
Exemplo n.º 19
0
        public List <IAssetVO> GetProjectilePreloads(Map map)
        {
            List <string> attackerWarBuffs = null;
            List <string> defenderWarBuffs = null;

            if (this.isPveBuffBase)
            {
                Squad currentSquad = Service.Get <SquadController>().StateManager.GetCurrentSquad();
                if (currentSquad != null)
                {
                    SquadWarManager warManager = Service.Get <SquadController>().WarManager;
                    attackerWarBuffs = warManager.GetBuffBasesOwnedBySquad(currentSquad.SquadID);
                }
            }
            List <string> attackerEquipment = null;
            List <string> defenderEquipment = null;

            if (this.battleData != null)
            {
                attackerEquipment = this.battleData.AttackerEquipment;
                defenderEquipment = this.battleData.DefenderEquipment;
            }
            return(ProjectileUtils.GetBattleProjectileAssets(map, this.battle, null, attackerWarBuffs, defenderWarBuffs, null, null, attackerEquipment, defenderEquipment));
        }
        public void SelectBuilding(GameObject building)
        {
            Quaternion rotationTarget = Service.Get <WarBoardViewController>().GetRotationTarget(building.transform);
            Quaternion planetRotation = Service.Get <WarBoardViewController>().GetPlanetRotation();
            float      num            = rotationTarget.eulerAngles.x - planetRotation.eulerAngles.x;

            if (num < -7.7f || num > 1.9f)
            {
                return;
            }
            SquadWarParticipantState participantState = this.GetParticipantState(building);

            if (participantState == null)
            {
                return;
            }
            SquadWarManager    warManager    = Service.Get <SquadController>().WarManager;
            SquadWarStatusType currentStatus = warManager.GetCurrentStatus();

            if (currentStatus == SquadWarStatusType.PhaseCooldown)
            {
                return;
            }
            this.selectedBuilding = building;
            Transform transform = building.transform;

            if (transform.childCount > 0)
            {
                GameObject gameObject = transform.GetChild(0).gameObject;
                this.outline.Init(gameObject, "PL_2Color_Mask_HoloBldg_Outline");
            }
            if (participantState != null)
            {
                Service.Get <EventManager>().SendEvent(EventId.WarBoardParticipantBuildingSelected, building);
            }
        }
Exemplo n.º 21
0
        public virtual void OnEnter()
        {
            Service.Get <UXController>().MiscElementsManager.RemoveGalaxyTournamentStatus();
            HudConfig  hudConfig  = null;
            BattleType battleType = this.battleData.BattleType;

            switch (battleType)
            {
            case BattleType.Pvp:
                hudConfig = new HudConfig(new string[]
                {
                    "Currency",
                    "OpponentInfo",
                    "MedalInfo",
                    "ButtonHome",
                    "LabelBaseNameOpponent",
                    "TroopsGrid",
                    "LabelDeployInstructions",
                    "LabelCurrencyValueOpponent"
                });
                if (!this.battleData.IsRevenge)
                {
                    hudConfig.Add("ButtonNextBattle");
                }
                break;

            case BattleType.PveDefend:
                hudConfig = new HudConfig(new string[]
                {
                    "Currency",
                    "PlayerInfo",
                    "LabelBaseNameOpponent",
                    "LabelCurrencyValueOpponent",
                    "TroopsGrid",
                    "LabelDeployInstructions"
                });
                break;

            case BattleType.PveAttack:
            case BattleType.PveFue:
            case BattleType.ClientBattle:
                hudConfig = new HudConfig(new string[]
                {
                    "Currency",
                    "OpponentInfo",
                    "ButtonHome",
                    "LabelBaseNameOpponent",
                    "TroopsGrid",
                    "LabelDeployInstructions",
                    "LabelCurrencyValueOpponent"
                });
                break;

            case BattleType.PveBuffBase:
            case BattleType.PvpAttackSquadWar:
            {
                hudConfig = new HudConfig(new string[]
                    {
                        "OpponentInfo",
                        "LabelBaseNameOpponent",
                        "WarAttack"
                    });
                SquadWarManager    warManager    = Service.Get <SquadController>().WarManager;
                bool               flag          = this.battleData.Attacker.PlayerFaction == this.battleData.Defender.PlayerFaction;
                SquadWarStatusType currentStatus = warManager.GetCurrentStatus();
                if (!flag)
                {
                    hudConfig.Add("BuffsYoursSquadWars");
                }
                if (battleType != BattleType.PveBuffBase)
                {
                    hudConfig.Add("BuffsOpponentsSquadWars");
                }
                if (this.battleData.Attacker.GuildId != this.battleData.Defender.GuildId && !warManager.IsCurrentlyScoutingOwnedBuffBase())
                {
                    hudConfig.Add("WarAttackOpponent");
                    if (currentStatus == SquadWarStatusType.PhaseAction)
                    {
                        hudConfig.Add("TroopsGrid");
                    }
                }
                if (currentStatus == SquadWarStatusType.PhasePrep)
                {
                    if (battleType == BattleType.PvpAttackSquadWar)
                    {
                        Service.Get <BuildingController>().EnterSelectMode();
                    }
                    else
                    {
                        Service.Get <BuildingController>().ExitAllModes();
                    }
                }
                break;
            }
            }
            if (hudConfig != null)
            {
                Service.Get <UXController>().HUD.ConfigureControls(hudConfig);
            }
        }
Exemplo n.º 22
0
        public static bool EvaluateAudienceCondition(AudienceCondition ac)
        {
            Squad  currentSquad  = Service.SquadController.StateManager.GetCurrentSquad();
            string playerId      = Service.CurrentPlayer.PlayerId;
            string conditionType = ac.ConditionType;

            switch (conditionType)
            {
            case "playerInSquadWar":
            {
                bool flag = ac.ConditionValue.ToLower() == "true";
                if (currentSquad != null)
                {
                    SquadMember squadMemberById = SquadUtils.GetSquadMemberById(currentSquad, playerId);
                    if (squadMemberById != null)
                    {
                        SquadWarManager warManager = Service.SquadController.WarManager;
                        return(warManager.IsSquadMemberInWarOrMatchmaking(squadMemberById) == flag);
                    }
                }
                return(false);
            }

            case "squadWarParticipation":
            {
                uint num2       = Convert.ToUInt32(ac.ConditionValue) * 3600u;
                int  serverTime = (int)Service.ServerAPI.ServerTime;
                return((long)serverTime - (long)((ulong)Service.CurrentPlayer.LastWarParticipationTime) >= (long)((ulong)num2));
            }

            case "squadActiveMembers":
            case "squadMembers":
            {
                string[] array = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (array == null || array.Length != 2)
                {
                    Service.Logger.Error("Data error for SQUAD_MEMBER_CONDITION");
                    return(false);
                }
                int num3 = int.Parse(array[0]);
                int num4 = int.Parse(array[1]);
                if (currentSquad == null && num4 == 0)
                {
                    return(true);
                }
                if (currentSquad != null)
                {
                    if (ac.ConditionType == "squadMembers" && currentSquad.MemberCount >= num3 && currentSquad.MemberCount <= num4)
                    {
                        return(true);
                    }
                    if (ac.ConditionType == "squadActiveMembers" && currentSquad.ActiveMemberCount >= num3 && currentSquad.ActiveMemberCount <= num4)
                    {
                        return(true);
                    }
                }
                return(false);
            }

            case "hasCountry":
            {
                string   deviceCountryCode = Service.EnvironmentController.GetDeviceCountryCode();
                string[] array2            = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array2, deviceCountryCode) == -1)
                {
                    return(false);
                }
                break;
            }

            case "lacksCountry":
            {
                string   deviceCountryCode2 = Service.EnvironmentController.GetDeviceCountryCode();
                string[] array3             = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array3, deviceCountryCode2) != -1)
                {
                    return(false);
                }
                break;
            }

            case "hasLanguage":
            {
                string   locale = Service.Lang.Locale;
                string[] array4 = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array4, locale) == -1)
                {
                    return(false);
                }
                break;
            }

            case "lacksLanguage":
            {
                string   locale2 = Service.Lang.Locale;
                string[] array5  = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (Array.IndexOf <string>(array5, locale2) != -1)
                {
                    return(false);
                }
                break;
            }

            case "thirdParty":
                return(false);

            case "platform":
            {
                string[] array6 = ac.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                if (array6 != null)
                {
                    string[] array7 = array6;
                    for (int i = 0; i < array7.Length; i++)
                    {
                        string a = array7[i];
                        if (a == "a")
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            }
            return(true);
        }
Exemplo n.º 23
0
        public static bool IsValidForClient(List <AudienceCondition> audienceConditions)
        {
            Squad  currentSquad = Service.Get <SquadController>().StateManager.GetCurrentSquad();
            string playerId     = Service.Get <CurrentPlayer>().PlayerId;
            int    i            = 0;
            int    count        = audienceConditions.Count;

            while (i < count)
            {
                AudienceCondition audienceCondition = audienceConditions[i];
                string            conditionType     = audienceCondition.ConditionType;
                uint num = < PrivateImplementationDetails >.ComputeStringHash(conditionType);
                if (num <= 1979967659u)
                {
                    if (num <= 709505714u)
                    {
                        if (num != 399293899u)
                        {
                            if (num == 709505714u)
                            {
                                if (conditionType == "platform")
                                {
                                    string[] array = audienceCondition.ConditionValue.Split(new char[]
                                    {
                                        '|'
                                    });
                                    if (array != null)
                                    {
                                        string[] array2 = array;
                                        int      num2   = 0;
                                        if (num2 < array2.Length)
                                        {
                                            string text = array2[num2];
                                            Service.Get <StaRTSLogger>().WarnFormat("Make sure to add #define for missing platfrom {0}", new object[]
                                            {
                                                text
                                            });
                                            return(false);
                                        }
                                    }
                                    return(false);
                                }
                            }
                        }
                        else if (conditionType == "lacksLanguage")
                        {
                            string   locale = Service.Get <Lang>().Locale;
                            string[] array3 = audienceCondition.ConditionValue.Split(new char[]
                            {
                                '|'
                            });
                            if (Array.IndexOf <string>(array3, locale) != -1)
                            {
                                return(false);
                            }
                        }
                    }
                    else if (num != 949377194u)
                    {
                        if (num != 1252504053u)
                        {
                            if (num == 1979967659u)
                            {
                                if (conditionType == "hasCountry")
                                {
                                    string   deviceCountryCode = Service.Get <EnvironmentController>().GetDeviceCountryCode();
                                    string[] array4            = audienceCondition.ConditionValue.Split(new char[]
                                    {
                                        '|'
                                    });
                                    if (Array.IndexOf <string>(array4, deviceCountryCode) == -1)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                        else if (conditionType == "hasLanguage")
                        {
                            string   locale2 = Service.Get <Lang>().Locale;
                            string[] array5  = audienceCondition.ConditionValue.Split(new char[]
                            {
                                '|'
                            });
                            if (Array.IndexOf <string>(array5, locale2) == -1)
                            {
                                return(false);
                            }
                        }
                    }
                    else if (conditionType == "squadWarParticipation")
                    {
                        uint num3       = Convert.ToUInt32(audienceCondition.ConditionValue, CultureInfo.InvariantCulture) * 3600u;
                        int  serverTime = (int)Service.Get <ServerAPI>().ServerTime;
                        return((long)serverTime - (long)((ulong)Service.Get <CurrentPlayer>().LastWarParticipationTime) >= (long)((ulong)num3));
                    }
                }
                else if (num <= 2708772247u)
                {
                    if (num != 2704192874u)
                    {
                        if (num == 2708772247u)
                        {
                            if (conditionType == "playerInSquadWar")
                            {
                                bool flag = audienceCondition.ConditionValue.ToLower() == "true";
                                if (currentSquad != null)
                                {
                                    SquadMember squadMemberById = SquadUtils.GetSquadMemberById(currentSquad, playerId);
                                    if (squadMemberById != null)
                                    {
                                        SquadWarManager warManager = Service.Get <SquadController>().WarManager;
                                        return(warManager.IsSquadMemberInWarOrMatchmaking(squadMemberById) == flag);
                                    }
                                }
                                return(false);
                            }
                        }
                    }
                    else if (conditionType == "thirdParty")
                    {
                        string conditionValue = audienceCondition.ConditionValue;
                        return(conditionValue == "tapjoy" && Service.Get <TapjoyPlugin>().enabled);
                    }
                }
                else if (num != 2846430817u)
                {
                    if (num != 3759229686u)
                    {
                        if (num != 4133241044u)
                        {
                            goto IL_436;
                        }
                        if (!(conditionType == "squadMembers"))
                        {
                            goto IL_436;
                        }
                    }
                    else if (!(conditionType == "squadActiveMembers"))
                    {
                        goto IL_436;
                    }
                    string[] array6 = audienceCondition.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                    if (array6 == null || array6.Length != 2)
                    {
                        Service.Get <StaRTSLogger>().Error("Data error for SQUAD_MEMBER_CONDITION");
                        return(false);
                    }
                    int num4 = int.Parse(array6[0]);
                    int num5 = int.Parse(array6[1]);
                    if (currentSquad == null && num5 == 0)
                    {
                        return(true);
                    }
                    if (currentSquad != null)
                    {
                        if (audienceCondition.ConditionType == "squadMembers" && currentSquad.MemberCount >= num4 && currentSquad.MemberCount <= num5)
                        {
                            return(true);
                        }
                        if (audienceCondition.ConditionType == "squadActiveMembers" && currentSquad.ActiveMemberCount >= num4 && currentSquad.ActiveMemberCount <= num5)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (conditionType == "lacksCountry")
                {
                    string   deviceCountryCode2 = Service.Get <EnvironmentController>().GetDeviceCountryCode();
                    string[] array7             = audienceCondition.ConditionValue.Split(new char[]
                    {
                        '|'
                    });
                    if (Array.IndexOf <string>(array7, deviceCountryCode2) != -1)
                    {
                        return(false);
                    }
                }
IL_436:
                i++;
            }
            return(true);
        }
Exemplo n.º 24
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id <= EventId.SquadScreenOpenedOrClosed)
     {
         if (id != EventId.GameStateChanged)
         {
             if (id == EventId.SquadScreenOpenedOrClosed)
             {
                 this.UpdatePollFrequency();
             }
         }
         else
         {
             SquadWarManager warManager = this.controller.WarManager;
             if (this.IsValidUpdateGameState() && warManager.WarExists())
             {
                 this.UpdateSquadWar(warManager.CurrentSquadWar.WarId, true);
                 Service.Get <EventManager>().UnregisterObserver(this, EventId.GameStateChanged);
             }
         }
     }
     else if (id != EventId.SquadUpdated)
     {
         if (id != EventId.SquadServerMessage)
         {
             if (id == EventId.WarPhaseChanged)
             {
                 SquadWarStatusType squadWarStatusType = (SquadWarStatusType)cookie;
                 this.UpdateCurrentSquadWar();
                 if (squadWarStatusType == SquadWarStatusType.PhaseCooldown)
                 {
                     this.controller.UpdateCurrentSquad();
                 }
             }
         }
         else
         {
             SquadServerMessage squadServerMessage = (SquadServerMessage)cookie;
             if (squadServerMessage.Messages != null)
             {
                 if (this.serverMessages == null)
                 {
                     this.serverMessages = new List <SquadMsg>();
                 }
                 else
                 {
                     this.serverMessages.Clear();
                 }
                 uint num   = 0u;
                 int  i     = 0;
                 int  count = squadServerMessage.Messages.Count;
                 while (i < count)
                 {
                     SquadMsg squadMsg = SquadMsgUtils.GenerateMessageFromServerMessageObject(squadServerMessage.Messages[i]);
                     if (squadMsg != null)
                     {
                         this.serverMessages.Add(squadMsg);
                         if (!string.IsNullOrEmpty(squadMsg.NotifId) && squadMsg.TimeSent > num)
                         {
                             num = squadMsg.TimeSent;
                         }
                     }
                     i++;
                 }
                 if (num > 0u)
                 {
                     this.notifAdapter.ResetPollTimer(num);
                 }
                 this.OnNewSquadMsgs(this.serverMessages);
             }
         }
     }
     else if (cookie == null)
     {
         this.DisablePolling();
     }
     else
     {
         this.EnablePolling();
     }
     return(EatResponse.NotEaten);
 }
        private void FinishPreparingTransmissions(List <TransmissionVO> msgVOs)
        {
            int num = 0;

            this.Transmissions.Clear();
            this.incomingTransmissions.Clear();
            this.transmissionIndex = 0;
            SquadWarManager   warManager        = Service.Get <SquadController>().WarManager;
            SharedPlayerPrefs sharedPlayerPrefs = Service.Get <SharedPlayerPrefs>();
            int             pref           = sharedPlayerPrefs.GetPref <int>("DailyCrateTransTutorialViewed");
            int             serverTime     = (int)Service.Get <ServerAPI>().ServerTime;
            IDataController dataController = Service.Get <IDataController>();
            CurrentPlayer   currentPlayer  = Service.Get <CurrentPlayer>();

            foreach (TransmissionVO current in dataController.GetAll <TransmissionVO>())
            {
                if (current.Faction == currentPlayer.Faction && current.StartTime > 0 && current.StartTime <= serverTime && serverTime < current.EndTime && (!this.IsDailyCrateTutorialTransmission(current) || pref != 1))
                {
                    this.Transmissions.Add(current);
                    if (current.StartTime > this.lastTransmissionTimeViewed)
                    {
                        num++;
                    }
                }
            }
            HolonetController holonetController = Service.Get <HolonetController>();

            msgVOs.Sort(new Comparison <TransmissionVO>(holonetController.CompareTimestamps));
            int hOLONET_EVENT_MESSAGE_MAX_COUNT = GameConstants.HOLONET_EVENT_MESSAGE_MAX_COUNT;
            int count = msgVOs.Count;
            int num2  = 0;

            while (num2 < hOLONET_EVENT_MESSAGE_MAX_COUNT && num2 < count)
            {
                TransmissionVO transmissionVO = msgVOs[num2];
                if (!this.DuplicateTransmission(transmissionVO))
                {
                    this.Transmissions.Add(transmissionVO);
                    if (transmissionVO.StartTime > this.lastTransmissionTimeViewed)
                    {
                        num++;
                        if (this.IsWarTransmission(transmissionVO) && !warManager.IsTimeWithinCurrentSquadWarPhase(transmissionVO.StartTime))
                        {
                            num--;
                        }
                    }
                }
                else
                {
                    Service.Get <StaRTSLogger>().Error("Duplicate entry in transmission event messages repsonse: " + transmissionVO.Uid);
                }
                num2++;
            }
            this.Transmissions.Sort(new Comparison <TransmissionVO>(holonetController.CompareTimestamps));
            int            pref2 = sharedPlayerPrefs.GetPref <int>("HighestViewedSquadLvlUP");
            int            hOLONET_MAX_INCOMING_TRANSMISSIONS = GameConstants.HOLONET_MAX_INCOMING_TRANSMISSIONS;
            int            count2          = this.Transmissions.Count;
            int            num3            = 0;
            TransmissionVO transmissionVO2 = null;
            int            num4            = 0;

            while (num3 < hOLONET_MAX_INCOMING_TRANSMISSIONS && num4 < count2)
            {
                TransmissionVO transmissionVO3 = this.Transmissions[num4];
                if (this.IsIncomingTransmission(transmissionVO3) && (!this.IsWarTransmission(transmissionVO3) || warManager.IsTimeWithinCurrentSquadWarPhase(transmissionVO3.StartTime)))
                {
                    if (this.IsSquadLevelUpTransmission(transmissionVO3))
                    {
                        if (!Service.Get <PerkManager>().HasPlayerSeenPerkTutorial())
                        {
                            goto IL_2A7;
                        }
                        bool flag = transmissionVO2 == null || transmissionVO3.SquadLevel > transmissionVO2.SquadLevel;
                        if (!flag || pref2 >= transmissionVO3.SquadLevel)
                        {
                            goto IL_2A7;
                        }
                        if (transmissionVO2 != null)
                        {
                            num3--;
                            this.incomingTransmissions.Remove(transmissionVO2);
                        }
                        transmissionVO2 = transmissionVO3;
                    }
                    if (pref == 0)
                    {
                        if (this.IsDailyCrateTransmission(transmissionVO3))
                        {
                            goto IL_2A7;
                        }
                        if (this.IsDailyCrateTutorialTransmission(transmissionVO3))
                        {
                            sharedPlayerPrefs.SetPref("DailyCrateTransTutorialViewed", "1");
                        }
                    }
                    num3++;
                    this.incomingTransmissions.Add(transmissionVO3);
                }
IL_2A7:
                num4++;
            }
            this.incomingTransmissions.Sort(new Comparison <TransmissionVO>(this.CompareIncommingPriorites));
            holonetController.ContentPrepared(this, num);
        }