protected override void Awake() { int row = 0; Vector2 elementSize = _missionButtonPrefab.GetComponent <RectTransform>().sizeDelta; foreach (var mission in _availableMissions) { MissionButton mb = Instantiate(_missionButtonPrefab, _listScrolling.transform); mb.transform.localPosition = new Vector2(0, -row * elementSize.y - (row + 1) * _spacingBetweenButtons.y); row++; mb.Initialize(this, _listScrolling, mission, GetStyleForMission(mission)); } foreach (var mission in _playerActiveMissions) { MissionButton mb = Instantiate(_missionButtonPrefab, _listScrolling.transform); mb.transform.localPosition = new Vector2(0, -row * elementSize.y - (row + 1) * _spacingBetweenButtons.y); row++; mb.Initialize(this, _listScrolling, mission, GetStyleForMission(mission)); } if (_listScrolling.transform.childCount > 0) { MissionButton firstButton = _listScrolling.transform.GetChild(0).GetComponent <MissionButton>(); _firstSelectedObject = firstButton.GetComponent <Button>(); } base.Awake(); }
public void CancelMission(MissionButton button, Mission mission) { Mission cancelledMission = _playerActiveMissions.Find(x => x == mission); if (cancelledMission != null) { _cancelMission.Raise(new CancelMissionEA(cancelledMission)); button.UpdateStyle(GetStyleForMission(mission)); } }
public void AcceptMission(MissionButton button, Mission mission) { Mission acceptedMission = _availableMissions.Find(x => x == mission); if (acceptedMission != null) { _acceptMission.Raise(new AcceptMissionEA(acceptedMission)); button.UpdateStyle(GetStyleForMission(mission)); } }