Beispiel #1
0
    IEnumerator Start()
    {
        Attribute attribute = new Attribute();

        attribute.CostMp = 5;

        Skill.Skill windy  = new Skill.Skill();
        Entity      sakura = new Entity();

        sakura.Name = "小樱";
        sakura.Mp   = 10;
        Entity enemy = new Entity();


        windy.Init(sakura, enemy, attribute);
        //检验流程
        bool isvalid = windy.IsValid(new MpVerify());

        if (!isvalid)
        {
            windy.Interrupt(new InterruptValid());
        }


        Debug.Log("准备 吟唱");
        Task.TimeCondition cond = new Task.TimeCondition(5f);
        Task.Task          task = new Task.Task("吟唱动画", cond);

        yield return(StartCoroutine(windy.Sing(task)));

        Debug.Log("吟唱 结束");
    }
 private static void RunApplication(Container container)
 {
     try
     {
         var app = new Task.Task();
         //app.InitializeComponent();
         var mainWindow = container.GetInstance <MainWindow>();
         app.Run(mainWindow);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #3
0
        public void Fire(Skill skill)
        {
            //to-do吟唱 吟唱时间可以根据表格来
            TimeCondition singCond = new TimeCondition(0.5f);
            SkillTask     singTask = new SkillTask("吟唱任务", singCond);

            TaskManager.Instance().AddTask(singTask);
            //伤害计算
            DamageCondtion dmgCond = new DamageCondtion(skill, delegate(int result) { HandleCast(skill, result); }, EventsType.Skill_EndDmg);
            SkillTask      dmgTask = new SkillTask("伤害检查", dmgCond);

            TaskManager.Instance().AddTask(dmgTask);
            //启动任务队列
            TaskManager.Instance().Start(">>>技能伤害计算流程");
        }
Beispiel #4
0
        /// <summary>
        /// 处理施法
        /// </summary>
        /// <param name="skill"></param>
        /// <param name="result"></param>
        private void HandleCast(Skill skill, int result)
        {
            //释放特效
            SkillTask emitTask = new SkillTask("释放", new CastCondition(skill, 0.5f));

            Task.TaskManager.Instance().AddTask(emitTask);

            //打击效果
            SkillTask hitTask = new SkillTask("打击效果", new HitCondition(skill, 1));

            Task.TaskManager.Instance().AddTask(hitTask);

            //启动任务队列
            TaskManager.Instance().Start(">>>技能施法流程", delegate()
            {
                skill.End();
            });
        }
Beispiel #5
0
    IEnumerator Start()
    {
        Task.Task task1 = new Task.Task("第一个任务 时间任务,间隔两秒", new TimeCondition(1.0f));
        TaskManager.Instance().AddTask(task1);
        Task.Task task2 = new Task.Task("第二个任务 次数任务,3", new TimesCondition(3));
        Task.Task task3 = new Task.Task("第三个任务 点击按钮", new TirggerCondition(btn));
        TaskManager.Instance().AddTask(task2);
        TaskManager.Instance().AddTask(task3);

        curTask = TaskManager.Instance().Next();
        while (curTask != null)
        {
            yield return(curTask);

            Debug.Log(curTask.m_Name + " 已经做完了");
            curTask = TaskManager.Instance().Next();
        }
    }
Beispiel #6
0
    IEnumerator Start()
    {
        //检验流程
        bool isvalid = sk.IsValid(new MpVerify());

        if (!isvalid)
        {
            sk.Interrupt(new InterruptValid());
        }

        Debug.Log("准备 吟唱");
        Task.TimeCondition cond = new Task.TimeCondition(5f);
        cond.Start();
        Task.Task task = new Task.Task("吟唱动画", cond);

        yield return(StartCoroutine(sk.Sing(task)));

        Debug.Log("吟唱 结束");
    }
Beispiel #7
0
    public IEnumerator Cast()
    {
        //释放
        ICast     emit     = new EffectEmit().Handle(this);
        SkillTask emitTask = new SkillTask("释放", new Task.TimeCondition(1f));

        Task.TaskManager.Instance().AddTask(emitTask);

        //命中
        ICast     hit     = new EffectHit().Handle(this);
        SkillTask hitTask = new SkillTask("命中", new Task.TimeCondition(1f));

        Task.TaskManager.Instance().AddTask(hitTask);

        //伤害结算和飘字
        SkillTask task = Task.TaskManager.Instance().Next();

        while (task != null)
        {
            yield return(task);

            task = Task.TaskManager.Instance().Next();
        }
    }
        void AddItem(Task.Task task)
        {
            var obj = (GameObject)GameObject.Instantiate(Resources.Load("Main/TaskItem"), tasks_container.transform, false);

            if (task.icon_name != null)
            {
                obj.transform.Find("ic").GetComponent <Image>().sprite = Resources.Load <Sprite>(task.icon_name);
            }

            var task_item = obj.GetComponent <TaskItem>();

            task_items.Add(task_item);

            task_item.text.text  = task.description;
            task_item.task_index = task.index;

            task_item.btn_speed_up.GetComponent <UnityEngine.UI.Button>()
            .onClick.AddListener(() =>
            {
                Message msg   = new Message();
                msg.Type      = MainMenuMessageType.SPEED_UP_TASK;
                msg.parametrs = new StartTaskParametrs(task.index,
                                                       task.speed_up_price, Vector3.zero);

                MessageBus.Instance.SendMessage(msg);
                Close();
            });

            if (task.data.started)
            {
                if (task.speed_up_price <= 0)
                {
                    task_item.SetNoBtn();
                }
                else
                {
                    task_item.SetBtnSpeedUp(task.time_wait, task.speed_up_price);
                }
            }
            else
            {
                if (task.time_wait > 0)
                {
                    task_item.SetBtnStarsAndTime(task.stars_price,
                                                 task.time_wait);

                    task_item.btn_star_time.
                    GetComponent <UnityEngine.UI.Button>().onClick.
                    AddListener(() =>
                    {
                        if (move_stars.Count == 0 && stars_to_start.Count == 0)
                        {
                            Message msg   = new Message();
                            msg.Type      = MainMenuMessageType.START_TASK;
                            msg.parametrs = new StartTaskParametrs(task.index,
                                                                   task.stars_price, task_item.btn_star_time.transform.position);

                            MessageBus.Instance.SendMessage(msg);
                            //Close();
                        }
                    });
                }
                else
                {
                    task_item.SetBtnFinish();

                    if (task.stars_price == 0)
                    {
                        task_item.btn_finish.
                        GetComponent <UnityEngine.UI.Button>().onClick.
                        AddListener(() =>
                        {
                            if (move_stars.Count == 0 && stars_to_start.Count == 0)
                            {
                                Message msg   = new Message();
                                msg.Type      = MainMenuMessageType.START_TASK;
                                msg.parametrs = new StartTaskParametrs(task.index,
                                                                       task.stars_price, task_item.btn_star.transform.position);

                                MessageBus.Instance.SendMessage(msg);
                                //Close();
                            }
                        });
                    }
                    else
                    {
                        task_item.SetBtnStar(task.stars_price);

                        task_item.btn_star.
                        GetComponent <UnityEngine.UI.Button>().onClick.
                        AddListener(() =>
                        {
                            if (move_stars.Count == 0 && stars_to_start.Count == 0)
                            {
                                Message msg   = new Message();
                                msg.Type      = MainMenuMessageType.START_TASK;
                                msg.parametrs = new StartTaskParametrs(task.index,
                                                                       task.stars_price, task_item.btn_star.transform.position);

                                MessageBus.Instance.SendMessage(msg);
                                //Close();
                            }
                        });
                    }
                }
            }

            obj.transform.localScale    = new Vector3(1, 1, 1);
            obj.transform.localPosition = new Vector3(490, 0, 0);
            //obj.SetActive(false);

            if (tasksController.GetTaskInfo(task.index).data.ready_show&&
                !tasksController.GetTaskInfo(task.index).data.idle)
            {
                obj.SetActive(false);
            }
        }
        public override void ExtendedUpdate()
        {
            if (stars_to_start.Count > 0)
            {
                star_emit_timer -= Time.deltaTime;
                if (star_emit_timer <= 0)
                {
                    star_emit_timer = 0.2f;

                    move_stars.Add(stars_to_start.Dequeue());
                }
            }

            foreach (var s in move_stars)
            {
                var dist     = Vector3.Distance(star_proto.transform.position, dest);
                var cur_dust = Vector3.Distance(star_proto.transform.position, s.transform.position);
                if (Vector3.Distance(s.transform.position, dest) < 0.1)
                {
                    move_stars.Remove(s);
                    Destroy(s);
                    continue;
                }
                var pos = Vector3.Lerp(star_proto.transform.position, dest, ((cur_dust) / dist) + Time.deltaTime);
                s.transform.position = pos;
            }

            if (seted_btn && move_stars.Count == 0 && stars_to_start.Count == 0)
            {
                msg_kash.Type = MainMenuMessageType.STARTED_TASK;
                MessageBus.Instance.SendMessage(msg_kash);
                Close();
                seted_btn = false;
            }

            foreach (TaskItem item in task_items)
            {
                Task.Task task_info =
                    tasksController.GetTaskInfo(item.task_index);

                //if (task_info.data.show_finish_in_pb)
                //{
                //    item.gameObject.SetActive(false);
                //    task_items.Remove(item);
                //}

                if (task_info.data.done)
                {
                    item.btn_speed_up.SetActive(false);

                    item.check_done.SetActive(true);

                    //task_items.Remove(item);
                }

                else if (task_info.data.started)
                {
                    if (task_info.time_wait <= 0)
                    {
                        item.SetNoBtn();
                    }
                    else
                    {
                        task_info.Sales();

                        item.SetBtnSpeedUp(task_info.time_wait,
                                           task_info.speed_up_price);
                    }
                }
            }

            if (need_up_pb && taskList.activeSelf)
            {
                float new_value = pb.GetComponent <RectTransform>().sizeDelta.x + Time.deltaTime * 30;

                if (new_value >= extended_pb_value)
                {
                    new_value  = extended_pb_value;
                    need_up_pb = false;

                    Message msg = new Message();
                    msg.Type      = MainMenuMessageType.DONE_TASK_IN_PB;
                    msg.parametrs = new UpdateInt(cur_index);
                    MessageBus.Instance.SendMessage(msg);

                    finishing_order.RemoveAt(0);
                }

                float tmp = pb.GetComponent <RectTransform>().sizeDelta.y;
                pb.GetComponent <RectTransform>().sizeDelta =
                    new Vector2(new_value, tmp);
            }
            else if (finishing_order.Count > 0)
            {
                need_up_pb = true;

                pb_text.text = ((int)((tasksController.GetDoneTaskInChapterCount() /
                                       (float)DataController.instance.chapter_data.GetMissionsInCurChapter()) * 100)).ToString() + "%";
                extended_pb_value = (tasksController.GetDoneTaskInChapterCount() /
                                     (float)DataController.instance.chapter_data.GetMissionsInCurChapter()) * pb_max_width;

                cur_index = finishing_order[0];
            }
        }
Beispiel #10
0
 public IEnumerator Sing(Task.Task task)
 {
     yield return(task);
 }