private void Awake() { //initialize the object references in UIManagement UIManagement.Initialize(); //load the avatar sprites from Resources AvatarDisplay.LoadSprites(); //set the state list into a dictionary _stateDict = _states.ToDictionary(s => s.Name, s => s.GameObject); //default to the main menu state GoToState(State.MainMenu); //instantiate RAGE objects if in RAGE mode if (GameManagement.RageMode) { foreach (var obj in GameManagement.PlatformSettings.RageObjects) { var newObj = Instantiate(obj); newObj.name = obj.name; } } //if this is a reload after a tutorial, attempt to reload straight away if (_reload) { Loading.Start(); GameManagement.GameManager.LoadGameTask(GameManagement.GameSavePath, GameManagement.TeamName, success => { if (success) { GoToState(State.TeamManagement); _reload = false; } Loading.Stop(); }); } }
/// <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; }
private void Init() { var bg = CreateChild <UguiSprite>("bg"); { bg.Anchor = AnchorType.Fill; bg.Offset = Offset.Zero; bg.Color = ColorPreset.Passive.Darken(0.5f); } scoreLabel = CreateChild <Label>("score"); { scoreLabel.Pivot = PivotType.Left; scoreLabel.X = 200f; scoreLabel.Alignment = TextAnchor.MiddleLeft; scoreLabel.FontSize = 36; } comboLabel = CreateChild <Label>("combo"); { comboLabel.Anchor = AnchorType.Right; comboLabel.Pivot = PivotType.Right; comboLabel.X = -16f; comboLabel.Alignment = TextAnchor.MiddleRight; comboLabel.FontSize = 28; } avatarDisplay = CreateChild <AvatarDisplay>("avatar"); { avatarDisplay.Pivot = PivotType.Right; avatarDisplay.X = -200f; avatarDisplay.Size = new Vector2(64f, 64f); avatarDisplay.Color = Color.black; } nameLabel = CreateChild <Label>("name"); { nameLabel.Pivot = PivotType.BottomRight; nameLabel.X = -288f; nameLabel.IsBold = true; nameLabel.FontSize = 24; nameLabel.Alignment = TextAnchor.LowerRight; } dateLabel = CreateChild <Label>("date"); { dateLabel.Pivot = PivotType.TopRight; dateLabel.X = -288f; dateLabel.FontSize = 20; dateLabel.Alignment = TextAnchor.UpperRight; } OnEnableInited(); }
/// <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; }
private void Init() { glow = CreateChild <UguiSprite>("glow", 0); { glow.Anchor = AnchorType.Fill; glow.RawSize = new Vector2(-60f, -60f); glow.SpriteName = "glow-circle-32"; glow.Color = new Color(0f, 0f, 0f, 0.5f); } avatarDisplay = CreateChild <AvatarDisplay>("avatar", 1); { avatarDisplay.Anchor = AnchorType.Fill; avatarDisplay.Offset = Offset.Zero; avatarDisplay.MaskSprite = "circle-320"; avatarDisplay.ImageType = Image.Type.Simple; } OnEnableInited(); }
/// <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; }
private void Init() { background = CreateChild <UguiSprite>("background", -1); { background.Anchor = AnchorType.Fill; background.RawSize = Vector2.zero; background.Color = new Color(0f, 0f, 0f, 0.125f); } avatarDisplay = CreateChild <AvatarDisplay>("avatar", 5); { avatarDisplay.Anchor = AnchorType.Left; avatarDisplay.Pivot = PivotType.Left; avatarDisplay.X = 8f; avatarDisplay.Size = new Vector2(48f, 48f); avatarDisplay.Color = new Color(0f, 0f, 0f, 0.125f); avatarDisplay.MaskSprite = null; } nicknameLabel = CreateChild <Label>("nickname", 6); { nicknameLabel.Anchor = AnchorType.Fill; nicknameLabel.Alignment = TextAnchor.MiddleLeft; nicknameLabel.Offset = new Offset(66f, 8f, 10f, 8f); nicknameLabel.WrapText = true; } levelLabel = CreateChild <Label>("level", 7); { levelLabel.Anchor = AnchorType.Fill; levelLabel.Alignment = TextAnchor.LowerRight; levelLabel.Offset = new Offset(66f, 8f, 10f, 8f); levelLabel.FontSize = 14; levelLabel.WrapText = true; } // No need for icon. iconSprite.Destroy(); OnEnableInited(); }
/// <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(); }
public CreateBusActivity() : base(Resource.Layout.create_bus_layout) { OnLoaded += delegate { AllowBackNavigation(); var intent = Intent; if (intent.HasExtra("bus")) { bus = JsonConvert.DeserializeObject <BusInfo>(intent.GetStringExtra("bus")); } isEditing = bus?.Id != null; formInputHandler.SetBindings(new InputBinding[] { new InputBinding("Name", Resource.Id.tb_bus_name, true, InputTypes.Text) { OnBind = (view) => ((TextInputLayout)view).EditText.Text = bus?.Name }, new InputBinding("Model", Resource.Id.tb_model, true, InputTypes.Text) { OnBind = (view) => ((TextInputLayout)view).EditText.Text = bus?.Model }, new InputBinding("SeatStart", Resource.Id.tb_bus_seat_start, true, InputTypes.Number, min: 1) { OnBind = (view) => ((EditText)view).Text = (bus?.Seats?.Split('-').First() ?? "1") }, new InputBinding("SeatEnd", Resource.Id.tb_bus_seat_end, true, InputTypes.Number, min: 1) { OnBind = (view) => ((EditText)view).Text = (bus?.Seats?.Split('-').Last() ?? "90") }, }, FindViewById <ViewGroup>(global::Android.Resource.Id.Content)); // busImageView = FindViewById <AvatarDisplay>(Resource.Id.img_bus); busImageView.PlaceHolderImageSize = new global::Android.Util.Size(128, 128); busImageView.Shape = AvatarDisplay.AvatarShape.RoundedRect; busImageView.DrawShadow = false; busImageView.Click += (s, e) => { PickGalleryImage(); }; if (isEditing && bus.Photo != null) { busImageView.SetPhoto(bus.Photo, thumbnail: false); } // var btnSubmit = FindViewById <Button>(Resource.Id.btn_submit); btnSubmit.Click += async delegate { if (formInputHandler.ValidateInputs(true).Count == 0) { var inputs = formInputHandler.GetInputs(); var proxy = ProxyFactory.GetProxyInstace(); if (!isEditing) { // Create a new bus using (this.ShowProgress(null, "Creating bus, please hold on...")) { var response = await proxy.ExecuteAsync(API.Endpoints.BusesEndpoints.Create(new CreateBusInfo() { Name = inputs["Name"], Model = inputs["Model"], Seats = $"{inputs["SeatStart"]}-{inputs["SeatEnd"]}", })); if (response.Successful) { SetResult(Result.Ok); var createdBus = await response.GetDataAsync <BusInfo>(); // Upload image if any if (busImage != null) { using (var ms = new MemoryStream()) { busImage.Compress(Bitmap.CompressFormat.Png, 90, ms); ms.Flush(); // ms.Seek(0, SeekOrigin.Begin); response = await proxy.ExecuteAsync(API.Endpoints.BusesEndpoints.UploadPhoto(createdBus.Id, ms, "image/png")); } } OnBusCreated?.Invoke(this, createdBus); Finish(); } else { Toast.MakeText(this, response.GetErrorDescription(), ToastLength.Short).Show(); } } } else { // Edit the bus var editBusInfo = new EditBusInfo(); if (bus.Name != inputs["Name"]) { editBusInfo.Name = inputs["Name"]; } else if (bus.Model != inputs["Model"]) { editBusInfo.Model = inputs["Model"]; } else if (bus.Seats != $"{inputs["SeatStart"]}-{"SeatEnd"}") { editBusInfo.Seats = $"{inputs["SeatStart"]}-{"SeatEnd"}"; } // if (editBusInfo.AnyUpdate()) { using (this.ShowProgress(null, "Save changes, please hold on...")) { var response = await proxy.ExecuteAsync(API.Endpoints.BusesEndpoints.Update(bus.Id, editBusInfo)); if (response.Successful) { SetResult(Result.Ok); Finish(); } else { Toast.MakeText(this, response.GetErrorDescription(), ToastLength.Short).Show(); } } } } } }; // btnSubmit.Text = isEditing ? "Save changes" : "Add Bus"; SupportActionBar.Title = isEditing ? "Edit Bus" : "Add Bus"; }; }