Exemplo n.º 1
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.º 2
0
 public override void Destroy()
 {
     base.Destroy();
     this.animator      = null;
     this.opponentState = null;
     this.buffBaseData  = null;
 }
Exemplo n.º 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]);
        }
Exemplo n.º 4
0
        private void OnPlayerChangeClicked(UXButton button)
        {
            int direction = (int)button.Tag;

            this.participantState = this.GetAdjacentParticipant(this.participantState, direction);
            this.RefreshView();
        }
Exemplo n.º 5
0
 public SquadWarPlayerDetailsScreen(SquadWarParticipantState participantState) : base("gui_squadwar_playerdetails")
 {
     this.participantState = participantState;
     this.requirements     = new List <UXLabel>();
     this.uplinks          = new List <UXSprite>();
     this.checks           = new List <UXSprite>();
     this.stars            = new List <UXElement>();
 }
Exemplo n.º 6
0
 public override void Destroy()
 {
     base.Destroy();
     Service.EventManager.UnregisterObserver(this, EventId.WarVictoryPointsUpdated);
     this.participantState  = null;
     this.labelTroopTooltip = null;
     this.spritePoint1      = null;
     this.spritePoint2      = null;
     this.spritePoint3      = null;
 }
Exemplo n.º 7
0
 public override EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.WarVictoryPointsUpdated)
     {
         SquadWarParticipantState squadWarParticipantState = (SquadWarParticipantState)cookie;
         if (squadWarParticipantState != null && squadWarParticipantState.SquadMemberId == this.participantState.SquadMemberId)
         {
             this.UpdateView();
         }
     }
     return(base.OnEvent(id, cookie));
 }
Exemplo n.º 8
0
 public void Hide()
 {
     this.opponentState = null;
     this.buffBaseData  = null;
     if (this.Visible)
     {
         this.animator.ResetTrigger("ShowTop");
         this.animator.ResetTrigger("ShowBottom");
         this.animator.SetTrigger("Off");
     }
     this.Visible = false;
     Service.Get <EventManager>().SendEvent(EventId.WarBoardFlyoutHidden, null);
     Service.Get <ViewTimeEngine>().UnregisterFrameTimeObserver(this);
 }
        private void AddBuildingForParticipant(SquadWarParticipantState participantState, BuildingTypeVO buildingVO, bool isForPlayerSquad, bool isEmpire, int index, AssetManager assetManager, Transform locationTransform)
        {
            GameObject gameObject = new GameObject();

            gameObject.name = "WarBoardBuilding_" + participantState.SquadMemberName;
            SquadWarBoardBuilding key = new SquadWarBoardBuilding(participantState, gameObject, isEmpire);

            if (isForPlayerSquad)
            {
                this.participantBuildingsPlayer.Add(key, participantState);
            }
            else
            {
                this.participantBuildingsOpponent.Add(key, participantState);
            }
            this.LoadAsset(gameObject, locationTransform, buildingVO, assetManager);
        }
Exemplo n.º 10
0
        private NotificationObject GetSquadWarUseTurnNotification()
        {
            uint            time       = ServerTime.Time;
            SquadWarManager warManager = Service.Get <SquadController>().WarManager;

            if (warManager == null || warManager.CurrentSquadWar == null)
            {
                return(null);
            }
            SquadWarParticipantState currentParticipantState = warManager.GetCurrentParticipantState();

            if (currentParticipantState == null || currentParticipantState.TurnsLeft <= 0)
            {
                return(null);
            }
            if ((long)warManager.CurrentSquadWar.ActionEndTimeStamp - (long)((ulong)time) <= 0L)
            {
                return(null);
            }
            int num = warManager.CurrentSquadWar.ActionEndTimeStamp - GameConstants.WAR_NOTIF_ACTION_TURNS_REMINDER * 3600 - (int)time;

            if (num <= 0)
            {
                return(null);
            }
            string             text = "squadwars_action_turns_reminder";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);
            string             id                = "notif_" + text;
            string             message           = this.lang.Get(id, new object[0]);
            string             inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]);
            DateTime           time2             = DateTime.get_Now().AddSeconds((double)num);

            if (!this.CheckValidNotificationTime(notificationTypeVO, time2))
            {
                return(null);
            }
            return(new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time2, text, text));
        }
Exemplo n.º 11
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();
        }
        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.º 13
0
        protected override void SetupView()
        {
            base.GetElement <UXElement>("ReplayResults").Visible     = false;
            base.GetElement <UXButton>("ButtonReplayBattle").Visible = false;
            this.lastBattle = null;
            this.battleType = BattleType.ClientBattle;
            if (this.isReplay)
            {
                this.lastBattle = Service.Get <BattlePlaybackController>().CurrentBattleEntry;
                BattleRecord currentBattleRecord = Service.Get <BattlePlaybackController>().CurrentBattleRecord;
                this.battleType = ((currentBattleRecord != null) ? currentBattleRecord.BattleType : BattleType.ClientBattle);
            }
            else
            {
                CurrentBattle currentBattle = Service.Get <BattleController>().GetCurrentBattle();
                this.lastBattle = currentBattle;
                this.battleType = ((currentBattle != null) ? currentBattle.Type : BattleType.ClientBattle);
            }
            if (this.lastBattle == null)
            {
                Service.Get <StaRTSLogger>().Error("Last battle is null");
                return;
            }
            base.GetElement <UXLabel>("LabelPercentageSquadWar").Text = this.lang.Get("PERCENTAGE", new object[]
            {
                this.lastBattle.DamagePercent
            });
            bool    flag    = this.battleType == BattleType.PvpAttackSquadWar;
            UXLabel element = base.GetElement <UXLabel>("LabelResultsSquadWar");

            if (flag)
            {
                int num = Service.Get <SquadController>().WarManager.CalculateVictoryPointsTaken(this.lastBattle);
                element.Text = this.lang.Get("VICTORY_POINTS_EARNED", new object[]
                {
                    num
                });
            }
            else
            {
                bool   flag2 = this.lastBattle.Defender.PlayerFaction != FactionType.Smuggler;
                bool   won   = this.lastBattle.Won;
                string text  = (this.lastBattle.Defender.PlayerFaction == FactionType.Empire) ? "squadwars_end_celeb_empire" : "squadwars_end_celeb_rebel";
                string text2 = (this.lastBattle.Attacker.PlayerFaction == FactionType.Empire) ? "squadwars_end_celeb_empire" : "squadwars_end_celeb_rebel";
                this.currentOwnerTexture = base.GetElement <UXTexture>("TextureFactionIconCurrent");
                this.currentOwnerTexture.LoadTexture((!flag2 & won) ? text2 : text);
                this.newOwnerTexture = base.GetElement <UXTexture>("TextureFactionIconNew");
                this.newOwnerTexture.LoadTexture(won ? text2 : text);
                if (won)
                {
                    SquadWarManager      warManager = Service.Get <SquadController>().WarManager;
                    string               currentlyScoutedBuffBaseId = warManager.GetCurrentlyScoutedBuffBaseId();
                    WarBuffVO            warBuffVO = Service.Get <IDataController>().Get <WarBuffVO>(currentlyScoutedBuffBaseId);
                    SquadWarBuffBaseData currentlyScoutedBuffBaseData = warManager.GetCurrentlyScoutedBuffBaseData();
                    string               text3 = this.lang.Get(warBuffVO.BuffBaseName, new object[0]);
                    string               text4 = currentlyScoutedBuffBaseData.GetDisplayBaseLevel().ToString();
                    this.buffBaseUpgradeLabel.Visible = true;
                    this.buffBaseUpgradeLabel.Text    = this.lang.Get("WAR_BUFF_BASE_UPGRADED", new object[]
                    {
                        text3,
                        text4
                    });
                    this.labelBuffBaseCapturedSquadWar.Visible = true;
                    this.labelBuffBaseCapturedSquadWar.Text    = this.lang.Get("WAR_BATTLE_END_BUFF_BASE_CAPTURED", new object[]
                    {
                        text3
                    });
                }
            }
            element.Visible = flag;
            UXLabel element2 = base.GetElement <UXLabel>("LabelAttacksLeftSquadWar");
            bool    visible  = false;

            if (this.lastBattle.AttackerID == Service.Get <CurrentPlayer>().PlayerId)
            {
                SquadWarParticipantState currentParticipantState = Service.Get <SquadController>().WarManager.GetCurrentParticipantState();
                if (currentParticipantState != null)
                {
                    element2.Text = this.lang.Get("WAR_PLAYER_DETAILS_TURNS_LEFT", new object[]
                    {
                        currentParticipantState.TurnsLeft
                    });
                    visible = true;
                }
            }
            element2.Visible = visible;
            this.InitVictoryPoints(this.lastBattle);
            this.attackerBuffsGrid = base.GetElement <UXGrid>("GridBuffsRightSquadWar");
            SquadWarBuffIconHelper.SetupBuffIcons(this.attackerBuffsGrid, "SpriteIconBuffRightSquadWar", this.lastBattle.AttackerWarBuffs);
            this.defenderBuffsGrid = base.GetElement <UXGrid>("GridBuffsLeftSquadWar");
            SquadWarBuffIconHelper.SetupBuffIcons(this.defenderBuffsGrid, "SpriteIconBuffLeftSquadWar", this.lastBattle.DefenderWarBuffs);
            if (this.lastBattle.Won)
            {
                base.AnimateStars(this.lastBattle.EarnedStars);
            }
            base.InitTroopGrid("GridTroopsExpendedSquadWar", "TemplateTroopsExpendedSquadWar", this.lastBattle);
        }
 private int SortParticipantsAsc(SquadWarParticipantState a, SquadWarParticipantState b)
 {
     return(a.HQLevel - b.HQLevel);
 }
Exemplo n.º 15
0
 public SquadWarBoardPlayerInfo(SquadWarParticipantState participantState, Transform transformToTrack) : base("gui_squadwar_playerinfo", transformToTrack)
 {
     this.participantState = participantState;
     this.isCurrentPlayer  = (participantState.SquadMemberId == Service.CurrentPlayer.PlayerId);
 }
Exemplo n.º 16
0
 public SquadWarBoardBuilding(SquadWarParticipantState participantState, GameObject building, bool isEmpire)
 {
     this.Building   = building;
     this.IsEmpire   = isEmpire;
     this.PlayerInfo = new SquadWarBoardPlayerInfo(participantState, building.transform);
 }
 private bool ShouldParticipantBuildingBeDisabled(SquadWarParticipantState data)
 {
     return(data.TurnsLeft <= 0 && data.VictoryPointsLeft <= 0);
 }
Exemplo n.º 18
0
 public bool IsShowingParticipantOptions(SquadWarParticipantState state)
 {
     return(state != null && this.opponentState != null && this.opponentState.SquadMemberId == state.SquadMemberId);
 }
Exemplo n.º 19
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            if (id != EventId.PreloadedAudioSuccess && id != EventId.PreloadedAudioFailure)
            {
                switch (id)
                {
                case EventId.WarBoardParticipantBuildingSelected:
                {
                    GameObject gameObject = (GameObject)cookie;
                    SquadWarParticipantState participantState = Service.Get <WarBoardBuildingController>().GetParticipantState(gameObject);
                    bool flag = this.flyout != null && this.flyout.IsShowingParticipantOptions(participantState);
                    if (flag)
                    {
                        Service.Get <WarBoardBuildingController>().DeselectBuilding();
                    }
                    else if (this.flyout != null)
                    {
                        this.flyout.ShowParticipantOptions(gameObject, participantState);
                    }
                    break;
                }

                case EventId.WarBoardBuffBaseBuildingSelected:
                {
                    UXCheckbox           uXCheckbox = (UXCheckbox)cookie;
                    SquadWarBuffBaseData data       = (SquadWarBuffBaseData)uXCheckbox.Tag;
                    bool flag2 = this.flyout != null && this.flyout.IsShowingBuffBaseOptions(data);
                    if (flag2)
                    {
                        if (this.flyout != null)
                        {
                            this.flyout.Hide();
                        }
                    }
                    else
                    {
                        if (this.flyout != null)
                        {
                            this.flyout.ShowBuffBaseOptions(uXCheckbox, data);
                        }
                        Service.Get <WarBoardBuildingController>().DeselectBuilding();
                    }
                    break;
                }

                case EventId.WarBoardBuildingDeselected:
                {
                    GameObject building = (GameObject)cookie;
                    SquadWarParticipantState participantState2 = Service.Get <WarBoardBuildingController>().GetParticipantState(building);
                    if ((participantState2 == null || this.flyout.IsShowingParticipantOptions(participantState2)) && this.flyout != null)
                    {
                        this.flyout.Hide();
                    }
                    break;
                }
                }
            }
            else
            {
                AudioTypeVO audioTypeVO = (AudioTypeVO)cookie;
                if (audioTypeVO != null && audioTypeVO.Uid == "sfx_ui_squadwar_warboard_open")
                {
                    this.WarBoardAudioLoadFinished();
                    Service.Get <EventManager>().UnregisterObserver(this, EventId.PreloadedAudioSuccess);
                    Service.Get <EventManager>().UnregisterObserver(this, EventId.PreloadedAudioFailure);
                }
            }
            return(EatResponse.NotEaten);
        }