literally half of the game
This commit is contained in:
parent
1590b5faa6
commit
b842289076
77 changed files with 11904 additions and 72 deletions
|
|
@ -5,16 +5,21 @@ using UnityEngine;
|
|||
[CreateAssetMenu(fileName = "New Task", menuName = "Task")]
|
||||
public class Task : ScriptableObject
|
||||
{
|
||||
[Serializable]
|
||||
public class ItemRequirment
|
||||
{
|
||||
public Item item;
|
||||
public int amount;
|
||||
}
|
||||
[Header("Identification")]
|
||||
public string taskName;
|
||||
public string taskID;
|
||||
public string description;
|
||||
[Header("Requirements")]
|
||||
public int deadline; //in days from started
|
||||
public bool completed;
|
||||
public ItemRequirment[] requirements;
|
||||
public Dictionary<Item, int> itemProgress = new();
|
||||
|
||||
public InventoryManager.ItemAmount[] itemRequirements;
|
||||
public Enemy[] enemyRequirements;
|
||||
[Header("Rewards")]
|
||||
public InventoryManager.ItemAmount[] itemRewards;
|
||||
public int moneyReward;
|
||||
|
||||
public void FailTask()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class TaskManager : MonoBehaviour
|
||||
|
|
@ -18,9 +20,18 @@ public class TaskManager : MonoBehaviour
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public List<Task> activeTasks = new();
|
||||
|
||||
public Task[] taskList; //list of all tasks in the game
|
||||
public List<Task> activeTasks = new(); //it doesn't need to be serialized wtf are you talking about
|
||||
public int maxTasksActive;
|
||||
public Task startingTask;
|
||||
[Header("UI")]
|
||||
[SerializeField] private TaskUIObject templateTaskUI;
|
||||
public Transform taskGrid;
|
||||
public TextMeshProUGUI taskNameUI;
|
||||
public TextMeshProUGUI taskDescriptionUI;
|
||||
public Dictionary<Task, TaskUIObject> allTaskUIObjects = new();
|
||||
|
||||
public bool AddTask(Task taskToAdd)
|
||||
{
|
||||
if (activeTasks.Count >= maxTasksActive)
|
||||
|
|
@ -28,6 +39,56 @@ public class TaskManager : MonoBehaviour
|
|||
return false;
|
||||
}
|
||||
activeTasks.Add(taskToAdd);
|
||||
AddTaskUIObject(taskToAdd);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//AddTask(startingTask);
|
||||
}
|
||||
|
||||
public void CompleteTask(Task taskToComplete)
|
||||
{
|
||||
//remove items from inventory aswell. also need to
|
||||
//activeTasks.Remove(taskToComplete);
|
||||
Debug.Log($"{taskToComplete.taskName} COMPLETED");
|
||||
foreach (InventoryManager.ItemAmount itemReward in taskToComplete.itemRewards)
|
||||
{
|
||||
InventoryManager.instance.AddItem(itemReward.item, itemReward.amount);
|
||||
}
|
||||
InventoryManager.instance.AddMoney(taskToComplete.moneyReward);
|
||||
}
|
||||
|
||||
public void CheckInventory()
|
||||
{
|
||||
foreach (Task task in activeTasks)
|
||||
{
|
||||
bool skip = false;
|
||||
foreach (InventoryManager.ItemAmount itemRequirment in task.itemRequirements)
|
||||
{
|
||||
if (InventoryManager.instance.storedItems[itemRequirment.item] < itemRequirment.amount) //doesn't track enemies killed yet but i haven't added combat yet
|
||||
{
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!skip)
|
||||
{
|
||||
CompleteTask(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTaskUIObject(Task requestedTask)
|
||||
{
|
||||
TaskUIObject newTaskUIObject = Instantiate(templateTaskUI, taskGrid);
|
||||
allTaskUIObjects[requestedTask] = newTaskUIObject;
|
||||
newTaskUIObject.SetTask(requestedTask);
|
||||
}
|
||||
public void SetTaskUI(Task requestedTask)
|
||||
{
|
||||
taskNameUI.text = requestedTask.taskName;
|
||||
taskDescriptionUI.text = requestedTask.description;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
Assets/Scripts/Task/TaskUIObject.cs
Normal file
17
Assets/Scripts/Task/TaskUIObject.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TaskUIObject : MonoBehaviour
|
||||
{
|
||||
public Task taskToShow;
|
||||
public TextMeshProUGUI taskTitle;
|
||||
public Button thisButton;
|
||||
public void SetTask(Task requestedTask)
|
||||
{
|
||||
taskToShow = requestedTask;
|
||||
taskTitle.text = requestedTask.taskName;
|
||||
thisButton.onClick.RemoveAllListeners();
|
||||
thisButton.onClick.AddListener(() => TaskManager.instance.SetTaskUI(taskToShow)); //unsure if it should be on here or the new task ui function
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Task/TaskUIObject.cs.meta
Normal file
2
Assets/Scripts/Task/TaskUIObject.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 853eb37676d17e28f8b73e4434f633e7
|
||||
Loading…
Add table
Add a link
Reference in a new issue