Advertisement
Denisimus

Untitled

Feb 10th, 2022
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.22 KB | None | 0 0
  1.  public class ItemElement : MonoBehaviour, IElementСell
  2.     {
  3.         public static ItemElement instance;
  4.  
  5.         [SerializeField] private UserPerson userPerson;
  6.         [SerializeField] private IconsList iconsList;
  7.         [SerializeField] private Button button;
  8.  
  9.         private GameObject _hamster;
  10.         private API.Models.UserGetData.Person _person;
  11.  
  12.         private string _unityIdentifyWeapon,
  13.             _personId,
  14.             _personUnityIdentify,
  15.             _unityIdentifyArmor,
  16.             _unityIdentifyHelmet,
  17.             _unityIdentifySkin;
  18.  
  19.         private bool _isSelected;
  20.  
  21.  
  22.         private void Awake()
  23.         {
  24.             if (instance == null)
  25.             {
  26.                 instance = this;
  27.             }
  28.             else if (instance != null)
  29.             {
  30.                 Debug.Log("Instance already exists, destroying object!");
  31.                 Destroy(this);
  32.             }
  33.         }
  34.  
  35.         public void NewScoreElement(API.Models.UserGetData.UserPerson userPerson)
  36.         {
  37.             _hamster = GameObject.Find("Hamster");
  38.             string status = userPerson.status;
  39.             Debug.Log(" NewScoreElement ");
  40.             Debug.Log(" ItemElement person_name = " + userPerson.person.person_name);
  41.             Debug.Log(" ItemElement status = " + status);
  42.  
  43.  
  44.             _isSelected = CheckIsSelected(status);
  45.             _person = userPerson.person;
  46.             _personUnityIdentify = _person.unity_identify;
  47.  
  48.             Image imageSkin = gameObject.transform.Find("icon").GetComponent<Image>();
  49.             iconsList.SetIconItem(imageSkin, _personUnityIdentify);
  50.  
  51.             button.onClick.AddListener(delegate()
  52.             {
  53.                 Debug.Log(" ItemElement button.onClick _personUnityIdentify = " + _personUnityIdentify);
  54.  
  55.                 this.userPerson.person = _person;
  56.                 SelectedPersonSafeLoad.instance.SafeSelectedPerson(_person);
  57.                 _personId = _person.id.ToString();
  58.                 Debug.Log(" ItemElement button.onClick _personId = " + _personId);
  59.  
  60.                 UserService.getInstance().SetDefaultUserPerson(_personId);
  61.  
  62.                 if (!_isSelected)
  63.                 {
  64.                     //TODO  выбор какоя кнопка нажата;
  65.                     SelectPerson();
  66.                 }
  67.             });
  68.         }
  69.  
  70.         public bool CheckIsSelected(string status)
  71.         {
  72.             var s = status;
  73.             Debug.Log(" ItemElement ckeakIfSelected status = " + s);
  74.  
  75.             if (s.Equals("1"))
  76.             {
  77.                 Debug.Log(" ItemElement cImageSelekt SetActive(true)");
  78.                 return true;
  79.             }
  80.  
  81.             return false;
  82.         }
  83.  
  84.         // private void SetIcon(string nameOfSelectedCategory)
  85.         // {
  86.         //     foreach (GameObject avatar in GameObject.FindGameObjectsWithTag(nameOfSelectedCategory))
  87.         //     {
  88.         //         Image imageAvatar = avatar.gameObject.GetComponent<Image>();
  89.         //         personScinsList.SetIconItem(imageAvatar, _personUnityIdentify);
  90.         //     }
  91.         // }
  92.  
  93.         public void SelectPerson()
  94.         {
  95.             CustomisationManager.Instance.ActiveSelectPersonInMenu(_person);
  96.         }
  97.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement