Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ItemElement : MonoBehaviour, IElementСell
- {
- public static ItemElement instance;
- [SerializeField] private UserPerson userPerson;
- [SerializeField] private IconsList iconsList;
- [SerializeField] private Button button;
- private GameObject _hamster;
- private API.Models.UserGetData.Person _person;
- private string _unityIdentifyWeapon,
- _personId,
- _personUnityIdentify,
- _unityIdentifyArmor,
- _unityIdentifyHelmet,
- _unityIdentifySkin;
- private bool _isSelected;
- private void Awake()
- {
- if (instance == null)
- {
- instance = this;
- }
- else if (instance != null)
- {
- Debug.Log("Instance already exists, destroying object!");
- Destroy(this);
- }
- }
- public void NewScoreElement(API.Models.UserGetData.UserPerson userPerson)
- {
- _hamster = GameObject.Find("Hamster");
- string status = userPerson.status;
- Debug.Log(" NewScoreElement ");
- Debug.Log(" ItemElement person_name = " + userPerson.person.person_name);
- Debug.Log(" ItemElement status = " + status);
- _isSelected = CheckIsSelected(status);
- _person = userPerson.person;
- _personUnityIdentify = _person.unity_identify;
- Image imageSkin = gameObject.transform.Find("icon").GetComponent<Image>();
- iconsList.SetIconItem(imageSkin, _personUnityIdentify);
- button.onClick.AddListener(delegate()
- {
- Debug.Log(" ItemElement button.onClick _personUnityIdentify = " + _personUnityIdentify);
- this.userPerson.person = _person;
- SelectedPersonSafeLoad.instance.SafeSelectedPerson(_person);
- _personId = _person.id.ToString();
- Debug.Log(" ItemElement button.onClick _personId = " + _personId);
- UserService.getInstance().SetDefaultUserPerson(_personId);
- if (!_isSelected)
- {
- //TODO выбор какоя кнопка нажата;
- SelectPerson();
- }
- });
- }
- public bool CheckIsSelected(string status)
- {
- var s = status;
- Debug.Log(" ItemElement ckeakIfSelected status = " + s);
- if (s.Equals("1"))
- {
- Debug.Log(" ItemElement cImageSelekt SetActive(true)");
- return true;
- }
- return false;
- }
- // private void SetIcon(string nameOfSelectedCategory)
- // {
- // foreach (GameObject avatar in GameObject.FindGameObjectsWithTag(nameOfSelectedCategory))
- // {
- // Image imageAvatar = avatar.gameObject.GetComponent<Image>();
- // personScinsList.SetIconItem(imageAvatar, _personUnityIdentify);
- // }
- // }
- public void SelectPerson()
- {
- CustomisationManager.Instance.ActiveSelectPersonInMenu(_person);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement