Example #1
0
 /// <summary>
 /// Destroy the currently created CrewMember object and adjust any older CrewMember objects where the member has retired/been fired
 /// </summary>
 public void ResetCrew()
 {
     //remove attachment between CrewMemberUI and PositionUI
     foreach (var position in (PositionUI[])FindObjectsOfType(typeof(PositionUI)))
     {
         position.RemoveCrew();
     }
     //destroy recruitment buttons
     foreach (var b in CrewMembers)
     {
         Destroy(b.gameObject);
     }
     foreach (var crewMember in UIManagement.CrewMemberUI)
     {
         crewMember.CurrentUpdate();
     }
     //destroy recruitment buttons
     foreach (var b in _recruitButtons)
     {
         Destroy(b.gameObject);
     }
     CrewMembers.Clear();
     _recruitButtons.Clear();
     //recreate crew and repeat previous line-up
     CreateCrew();
     RepeatLineUp();
     //close any open pop-ups if needed
     UIManagement.PositionDisplay.ClosePositionPopUp(string.Empty);
     UIManagement.MemberMeeting.CloseCrewMemberPopUp(string.Empty);
     UIManagement.DisableSmallBlocker();
     DoBestFit();
     SortCrew();
     CrewContainerPaging();
 }
 /// <summary>
 /// Adjust blocker position in hierarchy according to if another pop-up that uses it is displayed as well
 /// </summary>
 public void ChangeBlockerOrder()
 {
     if (gameObject.activeInHierarchy)
     {
         transform.EnableSmallBlocker(() => ClosePositionPopUp(TrackerTriggerSource.PopUpBlocker.ToString()));
     }
     else if (!transform.parent.GetChild(transform.parent.childCount - 1).gameObject.activeInHierarchy)
     {
         UIManagement.DisableSmallBlocker();
     }
 }
 /// <summary>
 /// Triggered by button. Close fire warning pop-up.
 /// </summary>
 public void CloseFireCrewWarning(string source)
 {
     TrackerEventSender.SendEvent(new TraceEvent("FirePopUpClosed", TrackerAsset.Verb.Skipped, new Dictionary <TrackerContextKey, object>
     {
         { TrackerContextKey.PositionName, _currentMember.Name },
         { TrackerContextKey.TriggerUI, source }
     }, AccessibleTracker.Accessible.Screen));
     _fireWarningPopUp.Active(false);
     if (gameObject.activeInHierarchy)
     {
         transform.EnableSmallBlocker(() => CloseCrewMemberPopUp(TrackerTriggerSource.PopUpBlocker.ToString()));
     }
     else
     {
         UIManagement.DisableSmallBlocker();
     }
 }
 /// <summary>
 /// Hide the pop-up for Position details
 /// </summary>
 public void ClosePositionPopUp(string source)
 {
     if (gameObject.activeInHierarchy)
     {
         TrackerEventSender.SendEvent(new TraceEvent("PositionPopUpClosed", TrackerAsset.Verb.Accessed, new Dictionary <TrackerContextKey, object>
         {
             { TrackerContextKey.PositionName, _currentPosition },
             { TrackerContextKey.TriggerUI, source }
         }, AccessibleTracker.Accessible.Screen));
         gameObject.Active(false);
         if (UIManagement.MemberMeeting.gameObject.activeInHierarchy)
         {
             UIManagement.MemberMeeting.gameObject.transform.EnableSmallBlocker(() => UIManagement.MemberMeeting.CloseCrewMemberPopUp(TrackerTriggerSource.PopUpBlocker.ToString()));
         }
         else
         {
             UIManagement.DisableSmallBlocker();
         }
         UIManagement.Tutorial.ShareEvent(GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
 }
    /// <summary>
    /// Display pop-up which shows the race result
    /// </summary>
    public void Display(Dictionary <Position, CrewMember> currentPositions, int finishPosition)
    {
        //hide other pop-ups and disable the other blocker
        UIManagement.PositionDisplay.ClosePositionPopUp(string.Empty);
        UIManagement.MemberMeeting.CloseCrewMemberPopUp(string.Empty);
        UIManagement.DisableSmallBlocker();
        //enable object and blocker
        gameObject.Active(true);
        transform.EnableBlocker(() => Close(TrackerTriggerSource.PopUpBlocker.ToString()));
        //store the finishing position in case of redraws
        _lastRaceFinishPosition = finishPosition;
        //wipe previous crew
        foreach (Transform child in _crewContainer)
        {
            Destroy(child.gameObject);
        }
        //draw selected crew with expression matching the result
        var crewCount = 0;

        foreach (var pair in currentPositions)
        {
            var memberObject = Instantiate(_postRaceCrewPrefab, _crewContainer, false).transform;
            memberObject.name = pair.Value.Name;
            var avatar = memberObject.Find("Avatar");
            avatar.GetComponent <AvatarDisplay>().SetAvatar(pair.Value.Avatar, -(finishPosition - 3) * 2);
            avatar.localScale = crewCount % 2 == 0 ? avatar.localScale : new Vector3(-avatar.localScale.x, avatar.localScale.y, avatar.localScale.z);
            memberObject.FindImage("Position").sprite   = UIManagement.TeamSelection.RoleLogos[pair.Key.ToString()];
            memberObject.FindRect("Position").offsetMin = crewCount % 2 == 0 ? new Vector2(10, 0) : new Vector2(-10, 0);
            crewCount++;
            memberObject.SetAsLastSibling();
        }
        OnLanguageChange();
        TrackerEventSender.SendEvent(new TraceEvent("ResultPopUpDisplayed", TrackerAsset.Verb.Accessed, new Dictionary <TrackerContextKey, object>
        {
            { TrackerContextKey.FinishingPosition, finishPosition }
        }, AccessibleTracker.Accessible.Screen));
    }