Esempio n. 1
0
        private void Start()
        {
            loading = true;
            InitHeroes();

            hero1.AddClickListener(() =>
            {
                var hero = hero1.GetHero();
                if (hero != null)
                {
                    ToggleHero(hero);
                }
            });

            hero2.AddClickListener(() =>
            {
                var hero = hero2.GetHero();
                if (hero != null)
                {
                    ToggleHero(hero);
                }
            });

            hero3.AddClickListener(() =>
            {
                var hero = hero3.GetHero();
                if (hero != null)
                {
                    ToggleHero(hero);
                }
            });

            hero4.AddClickListener(() =>
            {
                var hero = hero4.GetHero();
                if (hero != null)
                {
                    ToggleHero(hero);
                }
            });

            var colorsConfig = configsProvider.Get <ColorsConfig>();

            cancelBtn.SetColor(colorsConfig.buttonDanger);
            cancelBtn.AddClickListener(() => Destroy(gameObject));

            missionBtn.SetColor(colorsConfig.buttonSecondary, colorsConfig.buttonSecondaryInactive);
            missionBtn.AddClickListener(() =>
            {
                missionPopup.SetActive(true);
            });
            missionPopup.SetActive(false);
            missionPopup.GetComponent <Button>().onClick.AddListener(() =>
            {
                missionPopup.SetActive(false);
            });
            missionSlider.onValueChanged.AddListener(value =>
            {
                UpdateMissionCount(Convert.ToInt32(value));
            });
            startMissionBtn.SetColor(colorsConfig.buttonSuccess, colorsConfig.buttonSuccessInactive);
            startMissionBtn.AddClickListener(() =>
            {
                missionRequest.vehicleId = vehicleAvatar.Vehicle.id;
                missionRequest.hero1Id   = hero1.GetHero()?.id;
                missionRequest.hero2Id   = hero2.GetHero()?.id;
                missionRequest.hero3Id   = hero3.GetHero()?.id;
                missionRequest.hero4Id   = hero4.GetHero()?.id;
                startMissionBtn.ShowIndicator();
                missionService.StartMission(missionRequest, data =>
                {
                    Destroy(gameObject);
                });
            });

            startBtn.SetColor(colorsConfig.buttonSuccess, colorsConfig.buttonSuccessInactive);

            signalBus.Subscribe <ResourcesSignal>(ConsumeResourcesSignal);
        }