Beispiel #1
0
        public void init(Message msg)
        {
            var param = Yaga.Helpers.CastHelper.Cast <CustomerAPI.InitCustParams>(msg.parametrs);

            bool start_coroutine = customers.Count == 0;

            int i = 0;

            foreach (var conf in param.configs)
            {
                var go = Instantiate(ResourcesController.get_instance().prefabs_resources.Customer,
                                     ResourcesController.get_instance().CustomersConteiner.transform);

                var customer = go.GetComponent <Customer>();

                customer.Init(conf.need_product, conf.wait_time, conf.cash, param.successable);

                customers.Add(go.GetComponent <Customer>());
                ++i;
            }

            sim_customers_amount = param.sim_customers_amount;
            min_time_wait        = param.min_time_wait;
            max_time_wait        = param.max_time_wait;
            randomize            = param.randomize;

            if (start_coroutine)
            {
                StartCoroutine(shadule_customers());
            }
        }
Beispiel #2
0
        public void Update()
        {
            timer -= Time.deltaTime;

            timer_view.TickDown(customer.wait_time, Time.deltaTime);

            if (timer < 1 / 3.0f * customer.def_wait_time && customer.cat_success_state == 2)
            {
                customer.cat_success_state = 3;

                customer.entity.customer_sprite.sprite =
                    ResourcesController.get_instance().product_resources.get_customer_sprite(customer.type, customer.cat_success_state - 1);
            }
            else if (timer < 2 / 3.0f * customer.def_wait_time && customer.cat_success_state == 1)
            {
                customer.cat_success_state = 2;

                customer.entity.customer_sprite.sprite =
                    ResourcesController.get_instance().product_resources.get_customer_sprite(customer.type, customer.cat_success_state - 1);
            }

            if (timer <= 0 && !customer.successable)
            {
                customer.LeaveBad();
            }
        }
        public IEnumerator ShowPanel()
        {
            yield return(new WaitForEndOfFrame());

            if (levelsController.cur_level_conf.tutors.Count > 0)
            {
                if (levelsController.cur_level_conf.tutors[0].type == Tutor.TutorType.INFO)
                {
                    tutorController.ShowTutor2(levelsController.cur_level_conf.tutors[0]);
                }
            }

            foreach (var goal in levelsController.cur_level_conf.non_product_goals)
            {
                var go   = Instantiate(ResourcesController.get_instance().prefabs_resources.GoalItemView, goals_conteiner);
                var view = go.GetComponent <GoalItemView>();
                view.Init(GoalType.NON_PRODUCTS, goal.value, Product.ProductType.NONE, goal.goal);
            }

            foreach (var goal in levelsController.cur_level_conf.quantitative_goals)
            {
                var          go   = Instantiate(ResourcesController.get_instance().prefabs_resources.GoalItemView, goals_conteiner);
                GoalItemView view = go.GetComponent <GoalItemView>();
                view.Init(GoalType.PRODUCTS, goal.amount, goal.product, NonProductsGoal.NON);
            }

            header.text = "Level " + (levelsController.cur_level_conf.id + 1);
            goals_panel.SetActive(true);
        }
Beispiel #4
0
        public void Init(ProductType type, float t)
        {
            product_type = type;

            product_icon.sprite = ResourcesController.get_instance().product_resources.get_provider_by_type(type);

            time = t;
        }
Beispiel #5
0
        public void StartState()
        {
            unit.timer.SetActive(true);

            unit.product_icon.SetActive(true);
            unit.product_icon.GetComponent <SpriteRenderer>().sprite =
                ResourcesController.get_instance().product_resources.get_lock_by_type(unit.cur_type);
        }
Beispiel #6
0
        public void StartState()
        {
            unit.ready_icon.SetActive(true);
            unit.product_icon.SetActive(true);
            unit.product_icon.GetComponent <SpriteRenderer>().sprite =
                ResourcesController.get_instance().product_resources.get_big_by_type(unit.result_product);

            unit.timer.SetActive(false);
        }
Beispiel #7
0
 public void Init(List <ProductType> rcp, ProductType res_product, float p_time)
 {
     recipe         = rcp;
     def_recipe     = new List <ProductType>(rcp);
     result_product = res_product;
     process_time   = p_time;
     unit_sprite.GetComponent <SpriteRenderer>().sprite =
         ResourcesController.get_instance().product_resources.get_production_unit_sprite_by_type(res_product);
 }
Beispiel #8
0
        public void StartState()
        {
            MessageBus.Instance.SendMessage(new Message(CustomerAPI.Messages.BAD_CUSTOMER,
                                                        new CustomerAPI.NeedProductParametrs(customer.need_product, customer.gameObject)));

            ResourcesController.get_instance().AddIndex(customer.cur_place_index);

            customer.ShowNeedArea(false);
            customer.transform.DOMoveX(customer.transform.position.x - 20.0f, 2.0f); //.onComplete = () => { customer.StartWait(); };
        }
Beispiel #9
0
        public void StartState()
        {
            unit.timer.SetActive(false);

            unit.product_icon.GetComponent <SpriteRenderer>().sprite =
                ResourcesController.get_instance().product_resources.get_big_by_type(unit.cur_type);

            MessageBus.Instance.SendMessage(new Message(ProductionFieldAPI.Messages.READY,
                                                        new ProductionFieldAPI.ReadyParams(unit.cur_type)));
        }
Beispiel #10
0
        public void StartState()
        {
            customer.ShowNeedArea(true);
            customer.entity.timer.SetActive(true);
            customer.entity.cost.text = "$" + (int)customer.cash;
            customer.entity.product_small_icon.GetComponent <SpriteRenderer>().sprite =
                ResourcesController.get_instance().product_resources.get_small_by_type(customer.need_product);

            MessageBus.Instance.SendMessage(new Message(CustomerAPI.Messages.CUSTOMER_START_WAITING,
                                                        new CustomerAPI.WaitnigParams(customer.cur_place_index, customer.need_product)));

            customer.entity.customer_sprite.sprite =
                ResourcesController.get_instance().product_resources.get_customer_sprite(customer.type, 0);
        }
Beispiel #11
0
        public ProcessState(GameObject go, float t)
        {
            field     = go;
            unit      = field.GetComponent <ProductionFieldUnit>();
            timer     = t;
            wait_time = t;

            unit.product_icon.GetComponent <SpriteRenderer>().sprite =
                ResourcesController.get_instance().product_resources.get_big_by_type(unit.cur_type);


            timer_view = unit.timer.GetComponent <Utilits.Timer>();
            timer_view.InitFull();
        }
Beispiel #12
0
        public bool GiveProduct(ProductType product)
        {
            unit.products_count++;

            unit.product_places[unit.products_count - 1].place.SetActive(true);
            unit.product_places[unit.products_count - 1].product.GetComponent <SpriteRenderer>().sprite =
                ResourcesController.get_instance().product_resources.get_small_by_type(product);

            //add coins

            if (unit.products_count == unit.max_products)
            {
                unit.Leave();
            }

            return(true);
        }
        public void init(Message msg)
        {
            var param = Yaga.Helpers.CastHelper.Cast <ProductionFieldAPI.InitPFParams>(msg.parametrs);

            int i = 0;

            foreach (var conf in param.configs)
            {
                var go = Instantiate(ResourcesController.get_instance().prefabs_resources.ProductionFieldUnit,
                                     ResourcesController.get_instance().ProductionFieldUnitsConteiner.transform);

                go.transform.position = ResourcesController.get_instance().production_fuild_slots[i].position;

                fields.Add(go.GetComponent <ProductionFieldUnit>());
                ++i;
            }
        }
Beispiel #14
0
        public void Update()
        {
            wait_anim -= Time.deltaTime;
            if (wait_anim <= 0 && !done)
            {
                customer.entity.customer_sprite.sprite =
                    ResourcesController.get_instance().product_resources.get_customer_sprite(customer.type, 0);

                MessageBus.Instance.SendMessage(new Message(CustomerAPI.Messages.SUCCESS_CUSTOMER,
                                                            new CustomerAPI.NeedProductParametrs(customer.need_product, customer.gameObject, customer.cash)));

                customer.ShowNeedArea(false);
                customer.transform.DOMoveX(customer.transform.position.x - 20.0f, 2.0f);//.onComplete = () => { customer.StartWait(); };

                done = true;
            }
        }
Beispiel #15
0
        public void Init(GoalType goal_t, int v, ProductType t, NonProductsGoal g)
        {
            type        = t;
            goal_type   = goal_t;
            start_value = v;
            non_product = g;
            value.text  = v.ToString();

            if (goal_t == GoalType.NON_PRODUCTS)
            {
                goal_icon.sprite = ResourcesController.get_instance().product_resources.get_by_non_product_type(g);
            }
            else
            {
                goal_icon.sprite = ResourcesController.get_instance().product_resources.get_big_by_type(t);
            }
        }
        public void init(Message msg)
        {
            var param = Yaga.Helpers.CastHelper.Cast <ProductProviderAPI.InitPPParams>(msg.parametrs);

            int i = 0;

            foreach (var conf in param.configs)
            {
                var go = Instantiate(ResourcesController.get_instance().prefabs_resources.ProductProvider,
                                     ResourcesController.get_instance().ProvidersContainer.transform);

                go.transform.position = ResourcesController.get_instance().product_provider_slots[i].position;

                var provider = go.GetComponent <ProductProvider>();
                provider.Init(conf.product, conf.production_time);

                providers.Add(provider);
                ++i;
            }
        }
Beispiel #17
0
        public void init(Message msg)
        {
            var param = Yaga.Helpers.CastHelper.Cast <ProductionUnitAPI.InitPUParams>(msg.parametrs);

            int i = 0;

            foreach (var conf in param.configs)
            {
                var go = Instantiate(ResourcesController.get_instance().prefabs_resources.ProductionUnit,
                                     ResourcesController.get_instance().ProductionUnitsContainer.transform);

                go.transform.position = ResourcesController.get_instance().production_unit_slots[i].position;

                var unit = go.GetComponent <ProductionUnit>();
                unit.Init(conf.recipe, conf.result_product, conf.process_time);

                units.Add(go.GetComponent <ProductionUnit>());
                ++i;
            }
        }
Beispiel #18
0
        public void StartState()
        {
            //unit.ready_icon.SetActive(false);

            unit.product_icon.SetActive(true);
            unit.product_icon.GetComponent <SpriteRenderer>().sprite =
                ResourcesController.get_instance().product_resources.get_lock_by_type(unit.result_product);

            foreach (var slot in unit.recipe_slots)
            {
                slot.SetActive(false);
            }

            unit.timer.SetActive(false);

            for (int i = 0; i < unit.recipe.Count; i++)
            {
                unit.recipe_slots[i].SetActive(true);
                unit.recipe_slot_icons[i].GetComponent <SpriteRenderer>().sprite =
                    ResourcesController.get_instance().product_resources.get_small_by_type(unit.recipe[i]);
            }
        }
Beispiel #19
0
        void ShowTutor()
        {
            busy = true;

            Time.timeScale = 0.2f;

            TutorItem conf = tutor_items[0];

            var mask = Instantiate(mask_prefub, parent.transform, false);

            mask.name = "mask_" + UnityEngine.Random.Range(1000, 9999).ToString();
            mask.transform.localScale = new Vector3(1, 1, 1);
            mask.SetActive(true);
            var mask_comp = mask.GetComponentInChildren <SpriteMaskController>();

            mask_comp.tutor_event_name = conf.name;
            mask_comp.count            = conf.clicks;
            mask_comp.tutor_aim        = conf.aim;

            mask.transform.position = ResourcesController.get_instance().GetPositionByIndexAndType(conf.aim, conf.position_index);

            //(3.6 - 0.75, 5.5)
            if (conf.aim == TutorAim.CUSTOMER)
            {
                mask.transform.position = new Vector3(mask.transform.position.x + 2.85f, mask.transform.position.y + 5.5f, -1);
            }
            else
            {
                mask.transform.position = new Vector3(mask.transform.position.x, mask.transform.position.y, -1);
            }

            if (tutor_items[0].text_id != string.Empty)
            {
                description.text = TextManager.getText(tutor_items[0].text_id);
                info_panel.SetActive(true);
            }

            tutor_items.RemoveAt(0);
        }
Beispiel #20
0
        public void StartState()
        {
            customer.cur_place_index = ResourcesController.get_instance().get_customer_position_index();

            if (customer.cur_place_index == 1)
            {
                customer.Down.SetActive(false);
                customer.entity = customer.Up.GetComponent <CustomerEntity>();
            }
            else
            {
                customer.Up.SetActive(false);
                customer.entity = customer.Down.GetComponent <CustomerEntity>();
            }

            customer.entity.customer_sprite.sprite =
                ResourcesController.get_instance().product_resources.get_customer_sprite(customer.type, 0);

            customer.ShowNeedArea(false);

            customer.transform.DOMoveX(ResourcesController.get_instance().customer_slots[customer.cur_place_index].position.x
                                       , 2.0f).onComplete = () => { customer.StartWait(); };
        }
Beispiel #21
0
        public IEnumerator init()
        {
            yield return(new WaitForSeconds(0.05f));

            GameStatistics.instance.SendStat("start_stargame_tm",
                                             StarTasksController.instance.get_cur_index());

            cur_level = new Level(level_id);
            data      = new LevelData(cur_level_conf.level_time_seconds, cur_level_conf.customers.Count);

            MessageBus.Instance.SendMessage(new Message(ProductProviderAPI.Messages.INIT_PRODUCT_PROVIDERS,
                                                        new ProductProviderAPI.InitPPParams(cur_level_conf.product_providers)));

            MessageBus.Instance.SendMessage(new Message(ProductionFieldAPI.Messages.INIT_PRODUCTION_FIELDS,
                                                        new ProductionFieldAPI.InitPFParams(cur_level_conf.production_fields)));

            MessageBus.Instance.SendMessage(new Message(ProductionUnitAPI.Messages.INIT_PRODUCTION_UNITS,
                                                        new ProductionUnitAPI.InitPUParams(cur_level_conf.production_units)));

            MessageBus.Instance.SendMessage(new Message(CustomerAPI.Messages.INIT_CUSTOMERS,
                                                        new CustomerAPI.InitCustParams(cur_level_conf.customers, cur_level_conf.simultaneously_customers_amount,
                                                                                       cur_level_conf.wait_time_until_next_min, cur_level_conf.wait_time_until_next_max, cur_level_conf.randomize, level_id == 0)));

            foreach (var goal in cur_level_conf.non_product_goals)
            {
                switch (goal.goal)
                {
                case NonProductsGoal.MONEY:
                    cur_level.win_conditions.Add(() =>
                    {
                        return(data.coins >= goal.value);
                    });
                    break;

                case NonProductsGoal.SUCCESS_CUSTOMERS:
                    cur_level.win_conditions.Add(() =>
                    {
                        return(data.success_customers >= goal.value);
                    });
                    break;

                case NonProductsGoal.AVOID_BAD_CUSTOMERS:
                    cur_level.win_conditions.Add(() =>
                    {
                        return(data.bad_customers == 0 && data.remainig_customers_count == 0);
                    });

                    cur_level.lose_conditions.Add(() =>
                    {
                        return(data.bad_customers > 0);
                    });
                    break;
                }

                var go = Instantiate(ResourcesController.get_instance().prefabs_resources.GoalItemView,
                                     ResourcesController.get_instance().GoalItemViewsConteiner.transform);
                var view = go.GetComponent <GoalItemView>();
                view.Init(GoalType.NON_PRODUCTS, goal.value, Product.ProductType.NONE, goal.goal);
            }


            foreach (var goal in cur_level_conf.quantitative_goals)
            {
                cur_level.win_conditions.Add(() =>
                {
                    return(data.products_amount.ContainsKey(goal.product) && data.products_amount[goal.product] >= goal.amount);
                });

                var go = Instantiate(ResourcesController.get_instance().prefabs_resources.GoalItemView,
                                     ResourcesController.get_instance().GoalItemViewsConteiner.transform);
                GoalItemView view = go.GetComponent <GoalItemView>();
                view.Init(GoalType.PRODUCTS, goal.amount, goal.product, NonProductsGoal.NON);
            }

            MessageBus.Instance.SendMessage(new Message(ContinuePanel.ContinuePanelController.Messages.INIT,
                                                        new ContinuePanel.ContinuePanelController.InitParam(cur_level_conf.restriction, continue_price)));

            switch (cur_level_conf.restriction)
            {
            case Restriction.CUSTOMERS:
                var go = Instantiate(ResourcesController.get_instance().prefabs_resources.CustomersRestrictionView,
                                     ResourcesController.get_instance().RestrictionViewConteiner.transform);
                CustomersRestrictionView view = go.GetComponent <CustomersRestrictionView>();
                view.Init(cur_level_conf.customers.Count);

                cur_level.win_conditions.Add(() =>
                {
                    return(data.remainig_customers_count == 0);
                });

                cur_level.lose_conditions.Add(() =>
                {
                    return(data.remainig_customers_count == 0);
                });

                break;

            case Restriction.TIME:
                Instantiate(ResourcesController.get_instance().prefabs_resources.TimerRestrictionView,
                            ResourcesController.get_instance().RestrictionViewConteiner.transform);

                cur_level.win_conditions.Add(() =>
                {
                    return(data.time <= 0);
                });
                cur_level.lose_conditions.Add(() =>
                {
                    return(data.time <= 0);
                });

                break;
            }

            Instantiate(ResourcesController.get_instance().prefabs_resources.CoinsView,
                        ResourcesController.get_instance().RestrictionViewConteiner.transform);

            if (cur_level_conf.tutors.Count > 0)
            {
                List <TutorItem> tutors = new List <TutorItem>();

                for (int i = 0; i < cur_level_conf.tutors.Count; ++i)
                {
                    tutors.Add(new TutorItem(cur_level_conf.tutors[i].type,
                                             cur_level_conf.tutors[i].aim_ready,
                                             cur_level_conf.tutors[i].aim,
                                             new List <Product.ProductType>(cur_level_conf.tutors[i].product),
                                             cur_level_conf.tutors[i].position_index,
                                             cur_level_conf.tutors[i].text_id,
                                             cur_level_conf.tutors[i].clicks,
                                             cur_level_conf.tutors[i].name));
                }

                MessageBus.Instance.SendMessage(new Message(TutorAPI.Messages.INIT,
                                                            new TutorAPI.InitParams(new List <TutorItem>(tutors))));
            }


            StartCoroutine(Tick());
            StartCoroutine(CheckWin());
        }
Beispiel #22
0
 public void StartState()
 {
     ResourcesController.get_instance().AddIndex(customer.cur_place_index);
     wait_anim = 0.4f;
 }