public void Start()
    {
        if (!invoked)
        {
            invoked = true;
            InvokeRepeating("SecondUpdate", 0, 1.0f);
        }

        hearts_servtimer = new ServeredTimer();
        hearts_servtimer.GetTime("hearts_timer",
                                 (answ) =>
        {
            hearts_timer  = answ.data.time;
            hearts_inited = true;
        },
                                 (answ) =>
        {
            hearts_timer = HEARTS_TIME;
            hearts_servtimer.SetTime("hearts_timer", hearts_timer);
            hearts_inited = true;
        });

        inf_hearts_servtimer = new ServeredTimer();
        inf_hearts_servtimer.GetTime("infinity_heart",
                                     (answ) =>
        {
            inf_hearts_timer  = answ.data.time;
            inf_hearts_inited = true;

            if (inf_hearts_timer > 0)
            {
                DataController.instance.catsPurse.InfinityHearts = true;
            }
        },
                                     (answ) =>
        {
            inf_hearts_inited = false;
        });

        energy_servtimer = new ServeredTimer();
        energy_servtimer.GetTime("energy_timer",
                                 (answ) =>
        {
            energy_timer  = answ.data.time;
            energy_inited = true;
        },
                                 (answ) =>
        {
            energy_timer = ENERGY_TIME;
            energy_servtimer.SetTime("energy_timer", energy_timer);
            energy_inited = true;
        });
    }
        public static Task Init(DataEntity data)
        {
            DialogController dialog = DialogController.GetController();

            int time_wait      = 10 * 60;
            int cur_task_index = 21;

            object[] time_msg_parametr_values = new object[2];
            time_msg_parametr_values[0] = TimerController.GetController().task22_timer;
            var     time_msg_param = new Yaga.CommonMessageParametr(time_msg_parametr_values);
            Message timer_msg      = new Message();

            timer_msg.Type      = MainScene.MainMenuMessageType.TASK_TIME_UPDATE;
            timer_msg.parametrs = time_msg_param;

            Task task = new Task(cur_task_index, 2, time_wait, 1000, TextManager.getTaskName(22), true, false);

            task.data = data.storable_data[task.index];

            task.icon_name = "task_icon_020";

            if (data.storable_data[cur_task_index].started)
            {
                servered_timer.GetTime("Task22",
                                       (answ) =>
                {
                    if (!task.data.done)
                    {
                        task.time_wait = answ.data.time;

                        time_msg_parametr_values[1] = task.time_wait;
                        MessageBus.Instance.SendMessage(timer_msg, true);
                    }
                },
                                       (answ) =>
                {
                    //todo replay request
                });
            }

            task.BeforeCutScene = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.CUT_SCENE_SHOWED;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);
            };

            task.CutSceneCondition = () => { return(data.storable_data[18].done == true); };

            task.Init = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.ADD_NEW_TASK_ITEM;
                msg.parametrs = new Yaga.CommonMessageParametr(task);
                MessageBus.Instance.SendMessage(msg);
            };

            task.BeforeAction = () => {
            };


            task.DoneAction = () =>
            {
                task.in_action = true;

                MainLocationOjects.instance.garden2_staf.SetActiveTrueWithAnimation();

                CatsMoveController.GetController().SetDestination(Cats.Main, "Point 40");
                CatsMoveController.GetController().SetDestination(Cats.Black, "Point 45");
                CameraMoveController.GetController().SetDestinations("CameraTasksTargets", "Saray");

                List <DialogEntity> deList = new List <DialogEntity>();
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(22, 1), DialogType.Main, DialogType.One, DialogEntity.get_id(22, 1)));
                dialog.SetDialogs(deList);
                dialog.SetBtnAction(() =>
                {
                    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);
                    //MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_TASK_LIST);

                    MessageBus.Instance.SendMessage(new Message(BubbleAPI.OPEN,
                                                                new BubbleCreateParametr(
                                                                    CatsMoveController.GetController().main_cat, new List <string>()
                    {
                        TextManager.getText("bubble_game")
                    }, 5)));

                    dialog.CloseDialog();
                });

                MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_MENU);
                dialog.ShowDialog();

                TimerController.GetController().task22_timer.SetActive(false);
                MainLocationOjects.instance.garden2_staf_farm.SetActive(false);
            };

            task.DoneInitAction = () =>
            {
                MainLocationOjects.instance.garden2_staf.SetActive(true);
                MainLocationOjects.instance.garden2_staf_farm.SetActive(false);
            };

            task.TickAction = () =>
            {
                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);
            };

            TaskAction tasc_action_1 = new TaskAction();

            tasc_action_1.action = () =>
            {
                servered_timer.SetTime("Task22", task.time_wait);

                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);

                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);

                //MainLocationOjects.instance.Children_zone.SetActive(true);
                //new cats
            };
            tasc_action_1.condition_action = () => { return(true); };

            task.TaskActions = new List <TaskAction>();
            task.TaskActions.Add(tasc_action_1);

            task.Idle = () =>
            {
                if (task.data.started && !task.data.done && !MainLocationOjects.instance.garden2_staf_farm.activeSelf &&
                    task.data.current_action_index > 0)
                {
                    MainLocationOjects.instance.garden2_staf_farm.SetActive(true);
                }
            };

            task.DoneCondition = () =>
            {
                return(task.time_wait < 0);
            };

            return(task);
        }
    void SecondUpdate()
    {
        if (energy_inited)
        {
            energy_timer -= 1;
            energy_timer -= (int)edelta;

            edelta = 0;

            energy_text.text = Helper.TextHelper.TimeFormatMinutes(energy_timer);

            if (energy_timer < 1)
            {
                if (energy_timer < -ENERGY_TIME)
                {
                    int additional = Mathf.Abs(energy_timer / ENERGY_TIME);

                    if (additional > 0)
                    {
                        DataController.instance.catsPurse.Hearts += additional;
                    }
                }

                energy_timer = ENERGY_TIME - Mathf.Abs(energy_timer) % ENERGY_TIME;
                energy_servtimer.SetTime("energy_timer", energy_timer);
                DataController.instance.catsPurse.Energy += 1;
            }
        }

        if (hearts_inited)
        {
            if (DataController.instance.catsPurse.InfinityHearts)
            {
                if (inf_hearts_inited)
                {
                    inf_hearts_timer -= 1;
                    hearts_text.text  = Helper.TextHelper.TimeFormatMinutes(inf_hearts_timer);

                    if (inf_hearts_timer < 1)
                    {
                        DataController.instance.catsPurse.InfinityHearts = false;
                    }
                }
            }
            else
            {
                hearts_timer -= 1;
                hearts_timer -= (int)hdelta;

                hdelta = 0;

                if (hearts_timer < 1)
                {
                    if (hearts_timer < -HEARTS_TIME)
                    {
                        int additional = Mathf.Abs(hearts_timer / HEARTS_TIME);

                        if (additional > 0)
                        {
                            DataController.instance.catsPurse.Hearts += additional;
                        }
                    }

                    hearts_timer = HEARTS_TIME - Mathf.Abs(hearts_timer) % HEARTS_TIME;
                    hearts_servtimer.SetTime("hearts_timer", hearts_timer);
                    DataController.instance.catsPurse.Hearts += 1;
                }

                hearts_text.text = Helper.TextHelper.TimeFormatMinutes(hearts_timer);
            }
        }
    }
        public static Task Init(DataEntity data)
        {
            DialogController dialog = DialogController.GetController();

            int time_wait      = 15 * 60;
            int cur_task_index = 14;

            object[] time_msg_parametr_values = new object[2];
            time_msg_parametr_values[0] = TimerController.GetController().task15_timer;
            var     time_msg_param = new Yaga.CommonMessageParametr(time_msg_parametr_values);
            Message timer_msg      = new Message();

            timer_msg.Type      = MainScene.MainMenuMessageType.TASK_TIME_UPDATE;
            timer_msg.parametrs = time_msg_param;

            Task task = new Task(cur_task_index, 1, time_wait, 500, TextManager.getTaskName(15), true, false);

            task.data = data.storable_data[task.index];

            task.icon_name = "task_icon_013";

            if (data.storable_data[cur_task_index].started)
            {
                servered_timer.GetTime("Task15",
                                       (answ) =>
                {
                    if (!task.data.done)
                    {
                        task.time_wait = answ.data.time;

                        time_msg_parametr_values[1] = task.time_wait;
                        MessageBus.Instance.SendMessage(timer_msg, true);
                    }
                },
                                       (answ) =>
                {
                    //todo replay request
                });
            }

            task.BeforeCutScene = () =>
            {
                //List<DialogEntity> deList = new List<DialogEntity>();
                //deList.Add(new DialogEntity(
                //    TextManager.getDialogsText(13, 1), DialogType.Black, DialogType.One, DialogEntity.get_id(13, 1)));
                //dialog.SetDialogs(deList);
                //dialog.SetBtnAction(() =>
                //{
                //    dialog.CloseDialog();

                //    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);

                //    MessageBus.Instance.SendMessage(new Message(TutorMaskController.Messages.SHOW_TUTOR_MASK,
                //        new TutorMaskController.TutorMaskParametr(
                //            MainLocationOjects.instance.minigames_btn_footer.transform.position, false, true,
                //            "minigames_btn_footer")));

                //    MessageBus.Instance.SendMessage(new Message(TutorMaskController.Messages.SHOW_TUTOR_MASK,
                //        new TutorMaskController.TutorMaskParametr(
                //            MainLocationOjects.instance.minigames_play_star_btn.GetComponent<RectTransform>().anchoredPosition, true, false,
                //            "minigames_play_star_btn")));

                //    DataController.instance.tasks_storage.content["minigame_reborn_tutor"] = true;
                //    DataController.instance.tasks_storage.Store();

                //    Message msg = new Message();
                //    msg.Type = MainScene.MainMenuMessageType.CUT_SCENE_SHOWED;
                //    msg.parametrs = new UpdateInt(task.index);
                //    MessageBus.Instance.SendMessage(msg);

                //    BoosterPrize prize = new BoosterPrize(BusterType.REBORN, 3);
                //    prize.ActiveAction();

                //    task.in_action = false;
                //});
                //dialog.ShowDialog();

                //MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_TASK_LIST);
                //MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_MENU);
                //task.in_action = true;
            };

            task.CutSceneCondition = () => { return(data.storable_data[13].done == true); };

            task.Init = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.ADD_NEW_TASK_ITEM;
                msg.parametrs = new Yaga.CommonMessageParametr(task);
                MessageBus.Instance.SendMessage(msg);
            };

            task.BeforeAction = () => {
            };


            task.DoneAction = () =>
            {
                task.in_action = true;

                MainLocationOjects.instance.Children_obstruction.SetActive(false);
                MainLocationOjects.instance.Children_boxes.SetActiveTrueWithAnimation();

                List <DialogEntity> deList = new List <DialogEntity>();
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(15, 1), DialogType.Black, DialogType.One, DialogEntity.get_id(15, 1)));
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(15, 2), DialogType.Djeki, DialogType.Black, DialogEntity.get_id(15, 2)));
                dialog.SetDialogs(deList);
                dialog.SetBtnAction(() =>
                {
                    List <DialogEntity> deList2 = new List <DialogEntity>();
                    deList2.Add(new DialogEntity(
                                    TextManager.getDialogsText(15, 3), DialogType.Main, DialogType.Black, DialogEntity.get_id(15, 3)));
                    deList2.Add(new DialogEntity(
                                    TextManager.getDialogsText(15, 4), DialogType.Black, DialogType.Main, DialogEntity.get_id(15, 4)));
                    deList2.Add(new DialogEntity(
                                    TextManager.getDialogsText(15, 5), DialogType.Main, DialogType.Black, DialogEntity.get_id(15, 5)));
                    dialog.SetDialogs(deList2);
                    dialog.SetMissionIcon("task_icon_014");
                    dialog.SetMissionIcon("task_icon_015");
                    dialog.SetMissionIcon("task_icon_016");

                    dialog.SetBtnAction(() =>
                    {
                        task.in_action = false;
                        dialog.CloseDialog();
                        MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);
                        MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_TASK_LIST);
                    });

                    CatsMoveController.GetController().SetDestination(Cats.Jakky, "Point 64");
                    CatsMoveController.GetController().SetDestination(Cats.Main, "Point 76");
                    CatsMoveController.GetController().SetDestination(Cats.Black, "Point 75");

                    CameraMoveController.GetController().SetDestinations("CameraTasksTargets", "Garden_1");
                    //CatsMoveController.GetController().SetDestination(Cats.Black, "CatTasksTargets", "Task15", "BlackTargets2");
                });
                dialog.ShowDialog();

                //CatsMoveController.GetController().SetDestination(Cats.Black, "CatTasksTargets", "Task15", "BlackTargets");
                //CatsMoveController.GetController().SetDestination(Cats.Main, "CatTasksTargets", "Task15", "MainTargets");
                //CatsMoveController.GetController().SetDestination(Cats.Jakky, "CatTasksTargets", "Task15", "JakkyTargets");

                CameraMoveController.GetController().SetDestinations("CameraTasksTargets", "Child_room");

                MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_MENU);

                TimerController.GetController().task15_timer.SetActive(false);
                MainLocationOjects.instance.Children_obstruction_farm.SetActive(false);
            };

            task.DoneInitAction = () =>
            {
                MainLocationOjects.instance.Children_obstruction.SetActive(false);
                MainLocationOjects.instance.Children_obstruction_farm.SetActive(false);
                MainLocationOjects.instance.Children_boxes.SetActive(true);
            };


            task.TickAction = () =>
            {
                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);
            };

            TaskAction tasc_action_1 = new TaskAction();

            tasc_action_1.action = () =>
            {
                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);

                servered_timer.SetTime("Task15", task.time_wait);

                CameraMoveController.GetController().SetDestinations("CameraTasksTargets", "Child_room");

                CatsMoveController.GetController().SetDestination(Cats.Main, "Point 59");
                CatsMoveController.GetController().SetDestination(Cats.Black, "Point 22");

                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);
            };

            tasc_action_1.condition_action = () => { return(true); };

            task.TaskActions = new List <TaskAction>();
            task.TaskActions.Add(tasc_action_1);

            task.Idle = () =>
            {
                if (task.data.started && !task.data.done && !MainLocationOjects.instance.Children_obstruction_farm.activeSelf &&
                    task.data.current_action_index > 0)
                {
                    MainLocationOjects.instance.Children_obstruction_farm.SetActive(true);
                    MainLocationOjects.instance.Children_obstruction.SetActive(false);
                }
            };

            task.DoneCondition = () =>
            {
                return(task.time_wait < 0);
            };

            return(task);
        }
Exemple #5
0
        public static Task Init(DataEntity data)
        {
            DialogController dialog = DialogController.GetController();

            bool show_money_tutor = false;

            int time_wait      = 5 * 60;
            int cur_task_index = 6;

            object[] time_msg_parametr_values = new object[2];
            time_msg_parametr_values[0] = TimerController.GetController().task7_timer;
            var     time_msg_param = new Yaga.CommonMessageParametr(time_msg_parametr_values);
            Message timer_msg      = new Message();

            timer_msg.Type      = MainScene.MainMenuMessageType.TASK_TIME_UPDATE;
            timer_msg.parametrs = time_msg_param;

            bool dialog_end = false;

            Task task = new Task(cur_task_index, 1, time_wait, 0, TextManager.getTaskName(7), true, false);

            task.data = data.storable_data[task.index];

            task.icon_name = "task_icon_005";

            if (data.storable_data[cur_task_index].started)
            {
                servered_timer.GetTime("Task7",
                                       (answ) =>
                {
                    if (!task.data.done)
                    {
                        task.time_wait = answ.data.time;

                        time_msg_parametr_values[1] = task.time_wait;
                        MessageBus.Instance.SendMessage(timer_msg, true);

                        dialog_end = true;
                    }
                },
                                       (answ) =>
                {
                    //task.time_wait = time_wait;

                    //time_msg_parametr_values[1] = task.time_wait;
                    //MessageBus.Instance.SendMessage(timer_msg);
                });
            }



            task.BeforeCutScene = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.CUT_SCENE_SHOWED;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);
            };

            task.CutSceneCondition = () => { return(data.storable_data[4].done == true); };

            task.Init = () =>
            {
                if (!DataController.instance.tasks_storage.content.ContainsKey("show_coins_tutor"))
                {
                    DataController.instance.tasks_storage.content["show_coins_tutor"] = false;
                    DataController.instance.tasks_storage.Store();
                }

                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.ADD_NEW_TASK_ITEM;
                msg.parametrs = new Yaga.CommonMessageParametr(task);
                MessageBus.Instance.SendMessage(msg);
            };

            task.BeforeAction = () => {
                show_money_tutor = true;

                //var subs = new MessageSubscriber();
                //subs.MessageTypes = new string[3] { MainScene.MainMenuMessageType.CLOSE_TASK_LIST, "TASK_ITEM_OPENED",
                //    MainScene.MainMenuMessageType.OPEN_MINI_GAMES };
                //subs.action = (m) =>
                //{
                //    if (m.Type == MainScene.MainMenuMessageType.OPEN_MINI_GAMES)
                //    {
                //        show_money_tutor = false;
                //        return;
                //    }

                //    if (m.Type == MainScene.MainMenuMessageType.CLOSE_TASK_LIST &&
                //    task.data.started)
                //        return;

                //    if (m.Type == "TASK_ITEM_OPENED" &&
                //    !task.data.started)
                //        return;

                //    if(!show_money_tutor && m.Type == MainScene.MainMenuMessageType.CLOSE_TASK_LIST)
                //        return;

                //    if (DataController.instance.gamesRecords.StarMinigameNeed)
                //        return;

                //    if (!(bool)DataController.instance.tasks_storage.content["show_coins_tutor"])
                //    {
                //        DataController.instance.tasks_storage.content["show_coins_tutor"] = true;
                //        DataController.instance.tasks_storage.Store();

                //        List<DialogEntity> deList = new List<DialogEntity>();
                //        deList.Add(new DialogEntity(
                //            TextManager.getDialogsText(7, 3), DialogType.Black, DialogType.Main, DialogEntity.get_id(7, 3)));
                //        dialog.SetDialogs(deList);
                //        dialog.SetBtnAction(() =>
                //        {
                //            dialog.CloseDialog();

                //            MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);
                //            MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_MINI_GAMES);
                //            MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_COINS_GAMES);

                //            MessageBus.Instance.SendMessage(new Message(TutorMaskController.Messages.SHOW_TUTOR_MASK,
                //                    new TutorMaskController.TutorMaskParametr(
                //                        MainLocationOjects.instance.minigames_play_coins_btn.GetComponent<RectTransform>().anchoredPosition, true, true,
                //                        "minigames_play_coins_btn")));
                //        });
                //        MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_TASK_LIST);
                //        dialog.ShowDialog();
                //        MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_MENU);
                //    }
                //};
                //MessageBus.Instance.AddSubscriber(subs);
            };


            task.DoneAction = () =>
            {
                task.in_action = true;

                MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_TASK_LIST);
            };

            task.DoneInitAction = () =>
            {
                MainLocationOjects.instance.trash_pack.SetActive(false);
            };


            task.TickAction = () =>
            {
                if (dialog_end)
                {
                    time_msg_parametr_values[1] = task.time_wait;
                    MessageBus.Instance.SendMessage(timer_msg);
                }
            };


            TaskAction tasc_action_1 = new TaskAction();

            tasc_action_1.action = () =>
            {
                MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_MENU);

                List <DialogEntity> deList = new List <DialogEntity>();
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(7, 1), DialogType.Main, DialogType.One, DialogEntity.get_id(7, 1)));
                dialog.SetDialogs(deList);
                dialog.SetBtnAction(() =>
                {
                    dialog.CloseDialog();
                    //task.in_action = false;

                    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);
                    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_TASK_LIST);
                    //timer

                    task.speed_up_price = (int)(DataController.instance.catsPurse.Coins * 0.9f);

                    MessageBus.Instance.SendMessage(
                        new Message(TutorMaskController.Messages.SHOW_TUTOR_MASK,
                                    new TutorMaskController.TutorMaskParametr(
                                        MainLocationOjects.instance.taks_1_btn.GetComponent <RectTransform>().anchoredPosition, true, true,
                                        "task_list_task1_btn")));

                    time_msg_parametr_values[1] = task.time_wait;
                    MessageBus.Instance.SendMessage(timer_msg);

                    servered_timer.SetTime("Task7", task.time_wait);

                    dialog_end = true;
                });
                dialog.ShowDialog();
                task.in_action = true;

                CatsMoveController.GetController().SetDestination(Cats.Main, "Point 25");
                CatsMoveController.GetController().SetDestination(Cats.Black, "Point 7");

                List <Vector3> points = new List <Vector3>();
                Transform      point  = GameObject.Find("CameraTasksTargets").transform
                                        .Find("Trash_packeg");
                points.Add(point.position);
                CameraMoveController.GetController().SetDestinations(points);
            };
            tasc_action_1.condition_action = () => { return(true); };

            task.CheckActionConditions = () =>
            {
                if (task.data.current_action_index == 0)
                {
                    if (CameraMoveController.GetController().DoesReachDestination())
                    {
                        task.in_action = false;

                        Message msg = new Message();
                        msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                        msg.parametrs = new UpdateInt(task.index);
                        MessageBus.Instance.SendMessage(msg);
                    }
                }

                else if (task.data.current_action_index == 1 && task.time_wait < 0.0f)
                {
                    task.in_action = false;

                    Message msg = new Message();
                    msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                    msg.parametrs = new UpdateInt(task.index);
                    MessageBus.Instance.SendMessage(msg);
                }

                else if (task.data.current_action_index == 2 && GarbageTruckController.GetController().end_garbage_timer <= 0.0f)
                {
                    task.in_action = false;

                    Message msg = new Message();
                    msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                    msg.parametrs = new UpdateInt(task.index);
                    MessageBus.Instance.SendMessage(msg);

                    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);
                }
            };


            TaskAction tasc_action_2 = new TaskAction();

            tasc_action_2.condition_action = () => { return(task.time_wait < 0.0f); };
            tasc_action_2.action           = () =>
            {
                List <Vector3> points = new List <Vector3>();
                Transform      point  = GameObject.Find("CameraTasksTargets").transform
                                        .Find("Trash_packeg");
                points.Add(point.position);
                CameraMoveController.GetController().SetDestinations(points);
                task.in_action = true;
            };

            TaskAction tasc_action_3 = new TaskAction();

            tasc_action_3.condition_action = () => { return(true); };
            tasc_action_3.action           = () =>
            {
                MainLocationOjects.instance.GarbageTruckController.SetActive(true);
                MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_FOOTER);

                task.in_action = true;
            };

            task.TaskActions = new List <TaskAction>();
            task.TaskActions.Add(tasc_action_1);
            task.TaskActions.Add(tasc_action_2);
            task.TaskActions.Add(tasc_action_3);

            task.Idle = () =>
            {
            };

            task.DoneCondition = () =>
            {
                return(task.data.current_action_index >= task.TaskActions.Count);
            };

            return(task);
        }
Exemple #6
0
        public static Task Init(DataEntity data)
        {
            DialogController dialog = DialogController.GetController();

            int time_wait      = 30 * 60;
            int cur_task_index = 12;

            object[] time_msg_parametr_values = new object[2];
            time_msg_parametr_values[0] = TimerController.GetController().task13_timer;
            var     time_msg_param = new Yaga.CommonMessageParametr(time_msg_parametr_values);
            Message timer_msg      = new Message();

            timer_msg.Type      = MainScene.MainMenuMessageType.TASK_TIME_UPDATE;
            timer_msg.parametrs = time_msg_param;

            Task task = new Task(cur_task_index, 1, time_wait, 3000, TextManager.getTaskName(13), true, false);

            task.data = data.storable_data[task.index];

            task.icon_name = "task_icon_011";

            if (data.storable_data[cur_task_index].started)
            {
                servered_timer.GetTime("Task13",
                                       (answ) =>
                {
                    if (!task.data.done)
                    {
                        task.time_wait = answ.data.time;

                        time_msg_parametr_values[1] = task.time_wait;
                        MessageBus.Instance.SendMessage(timer_msg, true);
                    }
                },
                                       (answ) =>
                {
                    //todo replay request
                });
            }

            task.BeforeCutScene = () =>
            {
                //List<DialogEntity> deList = new List<DialogEntity>();
                //deList.Add(new DialogEntity(
                //    TextManager.getDialogsText(13, 1), DialogType.Black, DialogType.One, DialogEntity.get_id(13, 1)));
                //dialog.SetDialogs(deList);
                //dialog.SetBtnAction(() =>
                //{
                //    dialog.CloseDialog();

                //    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);

                //    MessageBus.Instance.SendMessage(new Message(TutorMaskController.Messages.SHOW_TUTOR_MASK,
                //        new TutorMaskController.TutorMaskParametr(
                //            MainLocationOjects.instance.minigames_btn_footer.transform.position, false, true,
                //            "minigames_btn_footer")));

                //    MessageBus.Instance.SendMessage(new Message(TutorMaskController.Messages.SHOW_TUTOR_MASK,
                //        new TutorMaskController.TutorMaskParametr(
                //            MainLocationOjects.instance.minigames_play_star_btn.GetComponent<RectTransform>().anchoredPosition, true, false,
                //            "minigames_play_star_btn")));

                //    DataController.instance.tasks_storage.content["minigame_fly_tutor"] = true;
                //    DataController.instance.tasks_storage.Store();

                //    Message msg = new Message();
                //    msg.Type = MainScene.MainMenuMessageType.CUT_SCENE_SHOWED;
                //    msg.parametrs = new UpdateInt(task.index);
                //    MessageBus.Instance.SendMessage(msg);

                //    BoosterPrize prize = new BoosterPrize(BusterType.FLY, 3);
                //    prize.ActiveAction();

                //    task.in_action = false;
                //});
                //dialog.ShowDialog();

                //MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_TASK_LIST);
                //MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_MENU);
                //task.in_action = true;
            };

            task.CutSceneCondition = () =>
            {
                return(data.storable_data[11].done == true);
            };

            task.Init = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.ADD_NEW_TASK_ITEM;
                msg.parametrs = new Yaga.CommonMessageParametr(task);
                MessageBus.Instance.SendMessage(msg);
            };

            task.BeforeAction = () =>
            {
            };


            task.DoneAction = () =>
            {
                List <Vector3> points_main2 = new List <Vector3>();
                Transform      point        = GameObject.Find("CameraTasksTargets").transform
                                              .Find("Sleeping_room");
                points_main2.Add(point.position);
                CameraMoveController.GetController().SetDestinations(points_main2);

                MainLocationOjects.instance.sleep_room.SetActiveTrueWithAnimation();

                MessageBus.Instance.SendMessage(new Message(BubbleAPI.OPEN,
                                                            new BubbleCreateParametr(
                                                                CatsMoveController.GetController().main_cat, new List <string>()
                {
                    TextManager.getText("bubble_relax")
                }, 5)));

                //MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_TASK_LIST);

                TimerController.GetController().task13_timer.SetActive(false);
                MainLocationOjects.instance.sleep_room_farm.SetActive(false);
            };

            task.DoneInitAction = () =>
            {
                MainLocationOjects.instance.sleep_room.SetActive(true);
                MainLocationOjects.instance.sleep_room_farm.SetActive(false);
            };

            task.CheckActionConditions = () => { };

            task.TickAction = () =>
            {
                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);
            };

            TaskAction tasc_action_1 = new TaskAction();

            tasc_action_1.action = () =>
            {
                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);

                servered_timer.SetTime("Task13", task.time_wait);
                MainLocationOjects.instance.sleep_room_farm.SetActive(true);

                List <Vector3> points_main2 = new List <Vector3>();
                Transform      point        = GameObject.Find("CameraTasksTargets").transform
                                              .Find("Sleeping_room");
                points_main2.Add(point.position);
                CameraMoveController.GetController().SetDestinations(points_main2);

                CatsMoveController.GetController().SetDestination(Cats.Main, "Point 26");

                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);
            };
            tasc_action_1.condition_action = () => { return(true); };


            TaskAction tasc_action_2 = new TaskAction();

            task.TaskActions = new List <TaskAction>();
            task.TaskActions.Add(tasc_action_1);

            task.Idle = () =>
            {
                if (task.data.started && !task.data.done && !MainLocationOjects.instance.sleep_room_farm.activeSelf &&
                    task.data.current_action_index > 0)
                {
                    MainLocationOjects.instance.sleep_room_farm.SetActive(true);
                }
            };

            task.DoneCondition = () =>
            {
                return(task.time_wait < 0);
            };

            return(task);
        }
        public static Task Init(DataEntity data)
        {
            DialogController dialog = DialogController.GetController();

            int time_wait      = 30 * 60;
            int cur_task_index = 17;

            object[] time_msg_parametr_values = new object[2];
            time_msg_parametr_values[0] = TimerController.GetController().task18_timer;
            var     time_msg_param = new Yaga.CommonMessageParametr(time_msg_parametr_values);
            Message timer_msg      = new Message();

            timer_msg.Type      = MainScene.MainMenuMessageType.TASK_TIME_UPDATE;
            timer_msg.parametrs = time_msg_param;

            bool done_dialog = false;

            Task task = new Task(cur_task_index, 1, time_wait, 3000, TextManager.getTaskName(18), true, false);

            task.data = data.storable_data[task.index];

            task.icon_name = "task_icon_016";

            if (data.storable_data[cur_task_index].started)
            {
                servered_timer.GetTime("Task18",
                                       (answ) =>
                {
                    if (!task.data.done)
                    {
                        task.time_wait = answ.data.time;

                        time_msg_parametr_values[1] = task.time_wait;
                        MessageBus.Instance.SendMessage(timer_msg, true);

                        done_dialog = true;
                    }
                },
                                       (answ) =>
                {
                    //todo replay request
                });
            }

            task.BeforeCutScene = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.CUT_SCENE_SHOWED;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);
            };

            task.CutSceneCondition = () => { return(data.storable_data[14].done == true); };

            task.Init = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.ADD_NEW_TASK_ITEM;
                msg.parametrs = new Yaga.CommonMessageParametr(task);
                MessageBus.Instance.SendMessage(msg);
            };

            task.BeforeAction = () => {
            };


            task.DoneAction = () =>
            {
                MainLocationOjects.instance.music.SetActiveTrueWithAnimation();

                List <Vector3> points_main3 = new List <Vector3>();
                Transform      point        = GameObject.Find("CameraTasksTargets")
                                              .transform.Find("Music");
                points_main3.Add(point.position);
                CameraMoveController.GetController().SetDestinations(points_main3);

                MessageBus.Instance.SendMessage(new Message(BubbleAPI.OPEN,
                                                            new BubbleCreateParametr(
                                                                CatsMoveController.GetController().main_cat, new List <string>()
                {
                    TextManager.getText("bubble_books")
                }, 5)));

                //MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_TASK_LIST);

                TimerController.GetController().task18_timer.SetActive(false);
                MainLocationOjects.instance.music_farm.SetActive(false);
            };

            task.DoneInitAction = () =>
            {
                MainLocationOjects.instance.music.SetActive(true);
                MainLocationOjects.instance.music_farm.SetActive(false);
                //new cats
            };

            task.TickAction = () =>
            {
                if (done_dialog)
                {
                    time_msg_parametr_values[1] = task.time_wait;
                    MessageBus.Instance.SendMessage(timer_msg);
                }
            };

            TaskAction tasc_action_1 = new TaskAction();

            tasc_action_1.action = () =>
            {
                List <Vector3> points_main3 = new List <Vector3>();
                Transform      point        = GameObject.Find("CameraTasksTargets")
                                              .transform.Find("Music");
                points_main3.Add(point.position);
                CameraMoveController.GetController().SetDestinations(points_main3);

                List <DialogEntity> deList = new List <DialogEntity>();
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(18, 1), DialogType.Black, DialogType.Main, DialogEntity.get_id(18, 1)));
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(18, 2), DialogType.Main, DialogType.Black, DialogEntity.get_id(18, 2)));
                dialog.SetDialogs(deList);
                dialog.SetBtnAction(() =>
                {
                    dialog.CloseDialog();
                    task.in_action = false;

                    Message msg   = new Message();
                    msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                    msg.parametrs = new UpdateInt(task.index);
                    MessageBus.Instance.SendMessage(msg);

                    servered_timer.SetTime("Task18", task.time_wait);
                    MainLocationOjects.instance.music_farm.SetActive(true);

                    time_msg_parametr_values[1] = task.time_wait;
                    MessageBus.Instance.SendMessage(timer_msg);

                    done_dialog = true;
                });
                dialog.ShowDialog();

                task.in_action = true;
            };
            tasc_action_1.condition_action = () => { return(true); };


            task.TaskActions = new List <TaskAction>();
            task.TaskActions.Add(tasc_action_1);

            task.Idle = () =>
            {
                if (task.data.started && !task.data.done && !MainLocationOjects.instance.music_farm.activeSelf &&
                    task.data.current_action_index > 0)
                {
                    MainLocationOjects.instance.music_farm.SetActive(true);
                }
            };

            task.DoneCondition = () =>
            {
                return(task.time_wait < 0);
            };

            return(task);
        }
        public static Task Init(DataEntity data)
        {
            DialogController dialog = DialogController.GetController();

            int time_wait      = 10 * 60;
            int cur_task_index = 11;

            object[] time_msg_parametr_values = new object[2];
            time_msg_parametr_values[0] = TimerController.GetController().task12_timer;
            var     time_msg_param = new Yaga.CommonMessageParametr(time_msg_parametr_values);
            Message timer_msg      = new Message();

            timer_msg.Type      = MainScene.MainMenuMessageType.TASK_TIME_UPDATE;
            timer_msg.parametrs = time_msg_param;

            Task task = new Task(cur_task_index, 1, time_wait, 1000, TextManager.getTaskName(12), true, false);

            task.data = data.storable_data[task.index];

            task.icon_name = "task_icon_010";

            if (data.storable_data[cur_task_index].started)
            {
                servered_timer.GetTime("Task12",
                                       (answ) =>
                {
                    if (!task.data.done)
                    {
                        task.time_wait = answ.data.time;

                        time_msg_parametr_values[1] = task.time_wait;
                        MessageBus.Instance.SendMessage(timer_msg, true);
                    }
                },
                                       (answ) =>
                {
                    //todo replay request
                });
            }

            task.BeforeCutScene = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.CUT_SCENE_SHOWED;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);
            };

            task.CutSceneCondition = () => { return(data.storable_data[24].done == true); };

            task.Init = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.ADD_NEW_TASK_ITEM;
                msg.parametrs = new Yaga.CommonMessageParametr(task);
                MessageBus.Instance.SendMessage(msg);
            };

            task.BeforeAction = () => {
            };


            bool task_done = false;

            task.DoneAction = () =>
            {
                MainLocationOjects.instance.obstruction_toilet.SetActive(false);

                List <DialogEntity> deList = new List <DialogEntity>();
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(12, 1), DialogType.Main, DialogType.Black, DialogEntity.get_id(12, 1)));
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(12, 2), DialogType.Black, DialogType.Main, DialogEntity.get_id(12, 2)));
                deList.Add(new DialogEntity(
                               TextManager.getDialogsText(12, 3), DialogType.Main, DialogType.Black, DialogEntity.get_id(12, 3)));
                dialog.SetDialogs(deList);
                dialog.SetMissionIcon("task_icon_012");
                dialog.SetBtnAction(() =>
                {
                    task.in_action = false;

                    dialog.CloseDialog();
                    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.SHOW_MAIN_MENU);
                    MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.OPEN_TASK_LIST);
                });
                dialog.ShowDialog();
                MessageBus.Instance.SendMessage(MainScene.MainMenuMessageType.CLOSE_MAIN_MENU);

                CatsMoveController.GetController().SetDestination(Cats.Main, "Point 31");
                CatsMoveController.GetController().SetDestination(Cats.Black, "Point 58");

                TimerController.GetController().task12_timer.SetActive(false);
                MainLocationOjects.instance.obstruction_toilet_farm.SetActive(false);

                task.in_action = true;
            };

            task.DoneInitAction = () =>
            {
                MainLocationOjects.instance.obstruction_toilet.SetActive(false);
                MainLocationOjects.instance.obstruction_toilet_farm.SetActive(false);
            };

            task.TickAction = () =>
            {
                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);
            };

            TaskAction tasc_action_1 = new TaskAction();

            tasc_action_1.action = () =>
            {
                time_msg_parametr_values[1] = task.time_wait;
                MessageBus.Instance.SendMessage(timer_msg);

                servered_timer.SetTime("Task12", task.time_wait);

                List <Vector3> points = new List <Vector3>();
                Transform      point  = GameObject.Find("CameraTasksTargets").transform
                                        .Find("TolietObstructions");
                points.Add(point.position);
                CameraMoveController.GetController().SetDestinations(points);

                CatsMoveController.GetController().SetDestination(Cats.Main, "Point 23");
                CatsMoveController.GetController().SetDestination(Cats.Black, "Point 59");

                MainLocationOjects.instance.obstruction_toilet_farm.SetActive(true);
                MainLocationOjects.instance.obstruction_toilet.SetActive(false);

                task.in_action = true;
            };
            tasc_action_1.condition_action = () => { return(true); };


            TaskAction task_action_2 = new TaskAction();

            task_action_2.condition_action = () => { return(task.time_wait <= 0); };
            task_action_2.action           = () =>
            {
                Message msg = new Message();
                msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                msg.parametrs = new UpdateInt(task.index);
                MessageBus.Instance.SendMessage(msg);
            };

            task.TaskActions = new List <TaskAction>();
            task.TaskActions.Add(tasc_action_1);
            task.TaskActions.Add(task_action_2);

            task.Idle = () =>
            {
                if (task.data.started && !task.data.done && !MainLocationOjects.instance.obstruction_toilet_farm.activeSelf &&
                    task.data.current_action_index > 0)
                {
                    MainLocationOjects.instance.obstruction_toilet_farm.SetActive(true);
                    MainLocationOjects.instance.obstruction_toilet.SetActive(false);
                }
            };

            task.CheckActionConditions = () =>
            {
                if (task.data.current_action_index == 0 && CameraMoveController.GetController().DoesReachDestination())
                {
                    Message msg = new Message();
                    msg.Type      = MainScene.MainMenuMessageType.SOME_ACTION_DONE;
                    msg.parametrs = new UpdateInt(task.index);
                    MessageBus.Instance.SendMessage(msg);
                    task.in_action = false;
                }
            };

            task.DoneCondition = () =>
            {
                return(task.data.current_action_index >= task.TaskActions.Count);
            };

            return(task);
        }