Exemplo n.º 1
0
        private Task GetTask(TaskCluster taskCluster)
        {
            var playerTask = tasksService.PlayerTasks.Find(t => t.taskClusterId == taskCluster.id);

            if (playerTask != null)
            {
                return(taskCluster.tasks.Find(t => t.number == playerTask.currentTaskNumber));
            }

            return(taskCluster.tasks[0]);
        }
Exemplo n.º 2
0
        public void SetTask(TaskCluster taskCluster, Task task, long taskAmountDone)
        {
            taskTitle.text       = $"{taskCluster.name} {NumberUtil.ToRoman(task.number)}";
            taskDescription.text = TaskDescription(task.taskType, task.taskAmount);
            task.reward.ForEach(item =>
            {
                var lootItem = Instantiate(lootItemPrefab, rewardsCanvas);
                lootItem.SetItem(item, 125f);
            });
            if (taskAmountDone >= task.taskAmount)
            {
                background.color = claimableBackgroundColor;
                border.gameObject.SetActive(true);
                progressAmountText.text = $"{NumberUtil.RoundAmount(task.taskAmount)}";

                progressBar.offsetMax = new Vector2(0, progressBar.offsetMax.y);
                var pos = progressAmountTextCanvas.localPosition;
                pos.x = progress.rect.width;
                progressAmountTextCanvas.localPosition = pos;
            }
            else
            {
                background.color = neutralBackgroundColor;
                border.gameObject.SetActive(false);
                progressAmountText.text = $"{NumberUtil.RoundAmount(taskAmountDone)}";

                var max            = progress.rect.width;
                var donePercentage = Convert.ToSingle(taskAmountDone) / task.taskAmount;
                var right          = max - max * donePercentage;
                progressBar.offsetMax = new Vector2(-right, progressBar.offsetMax.y);

                var pos = progressAmountTextCanvas.localPosition;
                pos.x = max * donePercentage;
                progressAmountTextCanvas.localPosition = pos;
            }
        }
Exemplo n.º 3
0
 public void ClaimTask(TaskCluster cluster, Action <PlayerActionResponse> onSuccess = null)
 {
     serverAPI.DoPost($"/tasks/claim/{cluster.id}", null, onSuccess);
 }