Пример #1
0
    /// <summary>
    /// Bring in elements that need to be known to this object, set properties related to this object and set the UI accordingly
    /// </summary>
    public void SetUp(bool usable, CrewMember crewMember, int mood, TrackerTriggerSource source = TrackerTriggerSource.TeamManagementScreen)
    {
        CrewMember = crewMember;
        Current    = crewMember.Current();
        Usable     = usable;
        _source    = source;

        _borderImage    = GetComponent <Image>();
        _backImage      = transform.FindImage("AvatarIcon");
        _button         = GetComponent <Button>();
        _avatarDisplay  = GetComponentInChildren <AvatarDisplay>();
        _positionImage  = transform.FindImage("Position");
        _positionButton = transform.FindButton("Position");
        _nameText       = transform.FindText("Name");
        _sortImage      = transform.FindImage("Sort");
        _sortText       = transform.FindText("Sort/Sort Text");
        _aspectFitter   = GetComponent <AspectRatioFitter>();

        _defaultParent     = transform.parent;
        _nameText.text     = CrewMember.FirstInitialLastName();
        _backImage.color   = Usable ? new Color(0, 1, 1) : Current ? new Color(0, 0.5f, 0.5f) : Color.white;
        _borderImage.color = ShowEmotion ? AvatarDisplay.MoodColor(mood) : Current ? Color.grey : Color.black;
        UpdateAvatar(mood);
        _button.enabled          = Current && GameManagement.SeasonOngoing;
        _positionButton.enabled  = GameManagement.SeasonOngoing;
        _aspectFitter.aspectMode = Usable ? AspectRatioFitter.AspectMode.FitInParent : AspectRatioFitter.AspectMode.WidthControlsHeight;
    }
Пример #2
0
 /// <summary>
 /// Reset and populate the pop-up for a new event
 /// </summary>
 public void ResetDisplay(PostRaceEventState current)
 {
     if (current.Dialogue != null)
     {
         LastState = current.Dialogue.NextState;
         if (current.Dialogue.NextState == "-")
         {
             LastState = current.Dialogue.CurrentState;
         }
         var subjects = current.Subjects.Select(s => Localization.HasKey(s) ? Localization.Get(s) : Regex.Replace(s, @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0")).ToArray();
         _dialogueText.text = Localization.GetAndFormat(current.Dialogue.Utterance, false, subjects);
     }
     _avatarDisplay.SetAvatar(current.CrewMember.Avatar, current.CrewMember.GetMood());
     _avatarDisplay.Parent().GetComponent <Image>().color = AvatarDisplay.MoodColor(current.CrewMember.GetMood());
     CurrentCrewMember = current.CrewMember;
     _nameText.text    = current.CrewMember.Name;
 }
Пример #3
0
    /// <summary>
    /// Update the avatar expression and border color using the string provided. Partially used for debugging
    /// </summary>
    public void ForcedMoodChange(string moodChange)
    {
        var mood = AvatarMood.Neutral;

        switch (moodChange)
        {
        case "negative":
            mood = CrewMember.Name.Length % 2 == 0 ? AvatarMood.StronglyDisagree : AvatarMood.Disagree;
            break;

        case "positive":
            mood = CrewMember.Name.Length % 2 == 0 ? AvatarMood.StronglyAgree : AvatarMood.Agree;
            break;

        case "accurate":
            mood = AvatarDisplay.GetMood(CrewMember.GetMood());
            break;
        }
        _avatarDisplay.UpdateMood(mood);
        _borderImage.color = ShowEmotion ? AvatarDisplay.MoodColor(mood) : Current ? Color.grey : Color.black;
    }
    /// <summary>
    /// Populate the information required in the pop-up
    /// </summary>
    public void Display()
    {
        if (!gameObject.activeInHierarchy)
        {
            return;
        }
        //ActionAllowance display
        _allowanceBar.fillAmount = GameManagement.ActionAllowancePercentage;
        _allowanceText.text      = GameManagement.ActionAllowance.ToString();
        //CrewMember avatar
        var mood = _currentMember.GetMood();

        _avatarDisplay.SetAvatar(_currentMember.Avatar, mood);
        _avatarDisplay.GetComponent <Image>().color          = new UnityEngine.Color(0, 1, 1);
        _avatarDisplay.Parent().GetComponent <Image>().color = AvatarDisplay.MoodColor(mood);
        //CrewMember information
        var currentRole = _currentMember.BoatPosition();

        _nameText.text = _currentMember.Name;
        _ageText.text  = _currentMember.Age.ToString();
        //set up button if CrewMember is positioned, hide if not
        _roleButton.gameObject.Active(currentRole != Position.Null);
        if (currentRole != Position.Null)
        {
            _roleButton.onClick.RemoveAllListeners();
            _roleButton.onClick.AddListener(() => UIManagement.PositionDisplay.SetUpDisplay(currentRole, TrackerTriggerSource.TeamManagementScreen.ToString()));
            _roleButton.transform.FindImage("Image").sprite = UIManagement.TeamSelection.RoleLogos[currentRole.ToString()];
        }
        //set stat bar fill amount (foreground) and sprite (background)
        foreach (var skill in _skills)
        {
            var skillvalue = _currentMember.RevealedSkills[(Skill)Enum.Parse(typeof(Skill), skill.name)];
            skill.FindImage("Foreground Bar").fillAmount = skillvalue * 0.1f;
            skill.FindImage("Hidden Image").enabled      = skillvalue == 0;
            skill.FindImage("Skill Image").enabled       = skillvalue != 0;
        }
        foreach (var question in _questions)
        {
            var configKey = (ConfigKey)Enum.Parse(typeof(ConfigKey), $"{question.name}Cost");
            question.FindText("Cost/Amount").text         = configKey.ValueString(true, _currentMember);
            question.GetComponent <Button>().interactable = configKey.Affordable(_currentMember);
        }
        _fireButton.transform.FindText("Cost/Amount").text = ConfigKey.FiringCost.ValueString();
        _fireButton.interactable = GameManagement.CanRemoveFromCrew;
        if (!_fireButton.interactable)
        {
            if (!ConfigKey.FiringCost.Affordable())
            {
                FeedbackHoverOver("FIRE_BUTTON_HOVER_ALLOWANCE");
            }
            else if (!GameManagement.CrewEditAllowed)
            {
                FeedbackHoverOver(Localization.GetAndFormat("FIRE_BUTTON_HOVER_LIMIT", false, GameManagement.StartingCrewEditAllowance));
            }
            else if (!GameManagement.Team.CanRemoveFromCrew())
            {
                FeedbackHoverOver("FIRE_BUTTON_HOVER_CREW_LIMIT");
            }
            else if (GameManagement.ShowTutorial)
            {
                FeedbackHoverOver("FIRE_BUTTON_HOVER_TUTORIAL");
            }
        }
        else
        {
            FeedbackHoverOver();
        }
        //display revealed opinions for each other active CrewMember
        DisplayOpinions();
        var managerOpinionImage = transform.FindComponentInChildren <Image>("Manager Opinion");
        var managerOpinion      = _currentMember.RevealedCrewOpinions[GameManagement.ManagerName];

        managerOpinionImage.sprite = GetOpinionIcon(managerOpinion);
        OnLanguageChange();
    }