示例#1
0
    //判断条件是否满足
    public void Check(TaskEventArgs e)
    {
        TaskCondition tc;

        for (int i = 0; i < taskConditions.Count; i++)
        {
            tc = taskConditions[i];
            if (tc.id == e.id)
            {
                tc.nowAmount += e.amount;
                if (tc.nowAmount < 0)
                {
                    tc.nowAmount = 0;
                }
                if (tc.nowAmount >= tc.targetAmount)
                {
                    tc.isFinish = true;
                }
                else
                {
                    tc.isFinish = false;
                }

                taskItem.Modify(e.id, tc.nowAmount);
            }
        }

        for (int i = 0; i < taskConditions.Count; i++)
        {
            if (!taskConditions[i].isFinish)
            {
                taskItem.Finish(false);
                return;
            }
        }
        taskItem.Finish(true);
        e.taskID = taskID;

        TaskManager.Instance.FinishTask(e);
    }