Example #1
0
 public virtual void InitTaskWithTaskSO(TaskSO so)
 {
     taskSO         = so;
     scoreReward    = so.scoreReward;
     this.timeGiven = Random.Range(so.minTimeGiven, so.maxTimeGiven);
     timeRemaining  = TimeGiven;
 }
Example #2
0
 void Start()
 {
     uiManager = GetComponent <UIManager>();
     head      = null;
     //uiManager.scrollRect.SetActive(false);
     //uiManager.scrollRect.transform.position = -Vector3.up * 500f;
     uiManager.scrollRect.GetComponent <RectTransform>().DOMoveY(-100f, 0f);
 }
Example #3
0
 public override void InitTaskWithTaskSO(TaskSO so)
 {
     base.InitTaskWithTaskSO(so);
     ((CalculatorTaskSO)so).GenerateQuestion(this);
     this.timeGiven     = Random.Range(so.minTimeGiven, so.maxTimeGiven);
     this.timeRemaining = TimeGiven;
     taskPanel          = ShipPanel.Calculator;
 }
Example #4
0
 public override void InitTaskWithTaskSO(TaskSO so)
 {
     base.InitTaskWithTaskSO(so);
     RateOfChange = ((TemperatureTaskSO)so).RateOfChange;
     CurrentTemp  = ((TemperatureTaskSO)so).StartingTemperature;
     TargetMin    = ((TemperatureTaskSO)so).TargetMin;
     TargetMax    = ((TemperatureTaskSO)so).TargetMax;
 }
Example #5
0
    //this function sets the new head to act on, and updates the graph based on this head being completed!
    public void setNewHead(TaskSO t)
    {
        if (t.timeToAppear > 0)
        {
            return;
        }
        if (Array.IndexOf(t.tags, "end") > -1)
        {
            showingSentance = false;
        }

        if (!t.complete && t.achievementText != null && t.achievementText != "")
        {
            //generates new achievement button
            GameObject newAchievement = Instantiate(achievementPanelPrefab);
            newAchievement.transform.SetParent(achievementContainerPanel.transform);
            newAchievement.GetComponentInChildren <TMP_Text>().text = t.achievementText;
            newAchievement.GetComponent <Image>().color             = colorFromRGB(178, 255, 214);
            newAchievement.transform.localScale = Vector3.one;
            Canvas.ForceUpdateCanvases();
            newAchievement.transform.DOShakeScale(1f, 0.5f);
            Destroy(newAchievement, 5f);
        }

        if (allChildrenComplete(t))
        {
            Debug.Log("All paths exhuasted on this node");
            return;
        }


        t.complete = true;
        taskToIsDoneDict[t].GetComponentInChildren <TMP_Text>().text = t.title;
        if (taskToButtonDict.ContainsKey(t))
        {
            taskToButtonDict[t].GetComponent <Image>().color = colorFromRGB(170, 120, 166);
        }
        updateCompleteness(t, 0f);

        generateTaskPopup(t.children, Input.mousePosition);

        if (t.children.Count != 0)
        {
            if (t.children[0].tags.Length > 0)
            {
                Debug.Log(t.children[0].tags[0]);
            }
            if (Array.IndexOf(t.children[0].tags, "start") > -1)
            {
                showingSentance = true;
                t.complete      = true;
                generateAutoTree(t.children[0]);
                return;
            }
        }
        //depth first search
    }
Example #6
0
 public override void InitTaskWithTaskSO(TaskSO so)
 {
     base.InitTaskWithTaskSO(so);
     needsApproving = ((SignOffTaskSO)so).needApproval;
     timeToApprove  = Random.Range(((SignOffTaskSO)so).timeToApproveMin,
                                   ((SignOffTaskSO)so).timeToApproveMax);
     todaysSignature = TodaysSignature.GetInstance().signature;
     taskPanel       = ShipPanel.Signature;
 }
Example #7
0
    private void Start()
    {
        uiManager = GameObject.Find("gameManager").GetComponent <UIManager>();

        head = new GameObject().AddComponent <TextToTreeParser>().generateTree(filePath);

        uiManager.generateCheckList(head, uiManager.UICompletionPanel.transform);
        StartCoroutine(animCo());
    }
Example #8
0
 public void FillInteractionPanel()
 {
     // TODO write a handler that return the text for the subtitle
     storyTitle.StringReference = m_Story.Title;
     if (m_Story.Tasks.Count > 0)
     {
         TaskSO task = m_Story.Tasks.FirstOrDefault(o => !o.IsDone) ?? m_Story.Tasks[0];
         storySubTitle.StringReference = task.Description;
     }
 }
Example #9
0
    public void updateCompleteness(TaskSO head, float delay)
    {
        if (head == null)
        {
            return;
        }

        //special case for clicking off of a tree to another partially complete node.
        if (head.parent != null && head.children.Count != 0)
        {
            foreach (TaskSO t in head.parent.children)
            {
                if (t == head)
                {
                    continue;
                }

                if (taskToButtonDict.ContainsKey(t))
                {
                    foreach (TaskSO childOfSibling in t.children)
                    {
                        deleteSubTree(childOfSibling, 0f);
                    }
                }
            }
        }


        //if all of the children are completed in the node you just selected, check to
        //see if the parent is now compelte
        if (allChildrenComplete(head))
        {
            //recurses up the parents, and sets them to green if they are all compelte
            if (taskToButtonDict.ContainsKey(head))
            {
                taskToButtonDict[head].GetComponent <Image>().color = colorFromRGB(180, 214, 211);
            }



            if (head.children.Count != 0)
            {
                //if it is complete, that means that all of the children are complete
                //so we can delete the children
                foreach (TaskSO child in head.children)
                {
                    //
                    deleteNode(child, delay);
                }
            }


            updateCompleteness(head.parent, delay + disapearDelay);
        }
    }
Example #10
0
    public override void InitTaskWithTaskSO(TaskSO so)
    {
        base.InitTaskWithTaskSO(so);
        ShootingTaskSO stso = (ShootingTaskSO)so;

        timeToCharge       = stso.timeToCharge;
        totalChargableTime = stso.totalPossibleCharge;
        timeCharged        = 0f;
        timeGiven          = stso.maxTimeGiven;
        taskPanel          = ShipPanel.Weapons;
    }
Example #11
0
    //called one time on mouse down
    //creates, positions, and adds buttons with corresponding tasks



    public void generateCheckList(TaskSO head, Transform parent)
    {
        GameObject newCheckListItem = Instantiate(UICompletionChildPrefab, parent);

        newCheckListItem.GetComponentInChildren <TMP_Text>().text = "?????";
        newCheckListItem.transform.localScale = Vector3.one;
        taskToIsDoneDict.Add(head, newCheckListItem);
        foreach (TaskSO child in head.children)
        {
            generateCheckList(child, newCheckListItem.transform);
        }
    }
Example #12
0
 //rename this
 IEnumerator test(TaskSO t)
 {
     if (Array.IndexOf(t.tags, "end") > -1)
     {
         yield return(null);
     }
     else
     {
         setNewHead(t);
         yield return(null);
     }
 }
Example #13
0
    public void achievementAnimation(TaskSO t, GameObject objectAdded, Vector3 start, Vector3 end, float time)
    {
        Image i = Instantiate(achievementAnimImagePrefab).GetComponent <Image>();

        i.sprite = t.icon;

        i.transform.SetParent(canvas.transform);
        i.transform.position = start;
        i.gameObject.transform.localScale = Vector3.one;
        Tween anim = i.transform.DOMove(end, time);

        Destroy(i.gameObject, anim.Duration());
    }
Example #14
0
 public IEnumerator showText(TaskSO task)
 {
     if (task.hasBeenVisited)
     {
         yield return(0f);
     }
     task.hasBeenVisited = true;
     while (task.timeToAppear > 0)
     {
         task.timeToAppear -= Time.deltaTime;
         yield return(0);
     }
     if (taskToButtonDict.ContainsKey(task))
     {
         taskToButtonDict[task].GetComponentInChildren <TMP_Text>().text = task.title;
     }
 }
Example #15
0
    public void deleteNode(TaskSO node, float delay)
    {
        //if (_head == null) {
        //    return;
        //}
        if (node == null)
        {
            return;
        }

        if (!taskToButtonDict.ContainsKey(node))
        {
            return;
        }

        GameObject boxToDestroy = null;

        if (taskToButtonDict[node] != null)
        {
            boxToDestroy = taskToButtonDict[node].transform.parent.gameObject;
        }

        Vector3 targetPos;

        if (!taskToButtonDict.ContainsKey(node.parent))
        {
            targetPos = taskToButtonDict[node].transform.position - transform.up * 100f;
        }
        else
        {
            targetPos = taskToButtonDict[node.parent].transform.position;
        }

        taskToButtonDict.Remove(node);



        //s.Append(box.transform.DOMoveY(5f, 0.5f));
        if (boxToDestroy != null)
        {
            Sequence s = DOTween.Sequence();
            s.Append(boxToDestroy.transform.DOMove(targetPos, disapearDelay).SetDelay(delay));
            s.Insert(0f, boxToDestroy.transform.DOScale(Vector3.zero, disapearDelay).SetDelay(delay));
            Destroy(boxToDestroy, s.Duration());
        }
    }
Example #16
0
    public bool allChildrenComplete(TaskSO task)
    {
        if (task.children.Count == 0)
        {
            return(task.complete);
        }
        bool allComplete = true;

        foreach (TaskSO t in task.children)
        {
            if (!allChildrenComplete(t))
            {
                allComplete = false;
            }
        }

        return(allComplete);
    }
Example #17
0
    public void deleteSubTree(TaskSO t, float delay)
    {
        if (t == null)
        {
            return;
        }


        foreach (TaskSO child in t.children)
        {
            if (taskToButtonDict.ContainsKey(child))
            {
                deleteSubTree(child, delay);
            }
        }

        deleteNode(t, testDelay);
    }
Example #18
0
    public GameObject createButton(TaskSO task, Transform parent)
    {
        GameObject _newButton = Instantiate(taskButton);

        _newButton.transform.SetParent(parent, true);
        IEnumerator co = showText(task);

        StartCoroutine(co);

        _newButton.transform.Find("taskImage").gameObject.GetComponent <Image>().sprite = task.icon;


        if (task.timeToAppear <= 0)
        {
            _newButton.GetComponentInChildren <TMP_Text>().text = task.title;
        }

        if (!taskToButtonDict.ContainsKey(task))
        {
            taskToButtonDict.Add(task, _newButton);
            //when you are creating a new button
            if (task.complete)
            {
                taskToButtonDict[task].GetComponent <Image>().color = colorFromRGB(180, 214, 211);
                if (task.children.Count != 0)
                {
                    if (!allChildrenComplete(task))
                    {
                        taskToButtonDict[task].GetComponent <Image>().color = colorFromRGB(170, 120, 166);
                    }
                }
            }
        }

        _newButton.GetComponent <RectTransform>().localScale = Vector3.one;

        //_newButton.GetComponent<RectTransform>().DOAnchorPos(originalPos, 1f);
        _newButton.GetComponent <Button>().onClick.AddListener(delegate { setNewHead(task); });

        return(_newButton);
    }
Example #19
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (!UIactive)
            {
                uiManager.scrollRect.GetComponent <RectTransform>().DOMoveY(100f, 1f);
            }
            else
            {
                uiManager.scrollRect.GetComponent <RectTransform>().DOMoveY(-100f, 1f);
            }
            UIactive = !UIactive;
        }
        if (Input.GetMouseButtonDown(0))
        {
            if (uiManager.showingSentance)
            {
                return;
            }


            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), -Vector2.up, Mathf.Infinity, 1 << LayerMask.NameToLayer("clickable"));
            if (hit.collider != null)
            {
                uiManager.deleteSubTree(head, 0f);
                head = hit.collider.gameObject.GetComponent <Task>().head;
                uiManager.setNewHead(head);
                //uiManager.generateAutoTree(head);
            }
            else
            {
                uiManager.deleteSubTree(head, 0f);
            }
        }
    }
Example #20
0
    private void bfs(TaskSO _head)
    {
        Queue <TaskSO>   q            = new Queue <TaskSO>();
        HashSet <TaskSO> visitedNodes = new HashSet <TaskSO>();

        visitedNodes.Add(_head);
        q.Enqueue(_head);
        while (q.Count != 0)
        {
            TaskSO v = q.Dequeue();
            //v is the current vertex and we are going to add all of
            //its children to the queue
            foreach (TaskSO child in v.children)
            {
                if (!visitedNodes.Contains(child))
                {
                    q.Enqueue(child);
                    visitedNodes.Add(child);
                }
            }
        }
    }
Example #21
0
    public Task AddTaskWithSO(TaskSO so)
    {
        if (ongoingTasks.Count >= maxTasks)
        {
            return(null);
        }
        Task task =
            so.Create();

        task.InitTaskWithTaskSO(so);
        ongoingTasks.Add(task);
        GameObject         cell       = Instantiate(taskCellPrefab, HUDCanvasManager.instance.TasksCanvasGroup.transform);
        TaskCellController controller = cell.GetComponent <TaskCellController>();

        task.cellController             = controller;
        controller.taskNameText.text    = so.taskName;
        controller.timerSlider.maxValue = task.TimeGiven;
        controller.timerSlider.value    = task.TimeRemaining;
        controller.SetupWithTask(task);
        //controller.hotkeyText = "";

        return(task);
    }
Example #22
0
    //rename this
    IEnumerator snhCo(TaskSO t)
    {
        yield return(new WaitForSeconds(0.5f));

        yield return(StartCoroutine(test(t)));

        if (Array.IndexOf(t.tags, "end") > -1)
        {
            showingSentance = false;
            yield return(null);
        }
        else
        {
            foreach (TaskSO child in t.children)
            {
                yield return(StartCoroutine(snhCo(child)));
            }
        }



        yield return(null);
    }
Example #23
0
    //simon u dumb ass this is s******g the bed because of the other
    //animation coroutines prob not working super great with this
    //you can prob fix this by passing a flag to not generate the coroutines?? idk it should work

    public void generateAutoTree(TaskSO t)
    {
        StartCoroutine(snhCo(t));
    }
    public TaskSO generateTree(string _fileName)
    {
        TaskSO root = ScriptableObject.CreateInstance <TaskSO>();

        root.parent = null;

        reader = new StreamReader("Assets/Resources/textFiles/" + _fileName);

        int    tabCount       = 0;
        TaskSO currentParent  = root;
        TaskSO mostRecentNode = root;

        // loop through every line of the text file
        while ((line = reader.ReadLine()) != null)
        {
            tabCount = line.Split('\t').Length - 1; // get the tab count of this line
            line     = line.Replace("\t", "");      // get rid of all tabs after getting the tab count

            // logic to update current parent based on change in tab count
            if (tabCount > previousTabCount)
            { // case for if a new child grouping has been introduced
                currentParent = mostRecentNode;
            }
            else if (tabCount < previousTabCount)
            { // case for if a child grouping has just been ended (special case, can go back multiple tabs)
                int tabDifference = (previousTabCount - tabCount);

                // update the current parent for however many tabs back the next line is
                for (int i = 0; i < tabDifference; i++)
                {
                    currentParent = currentParent.parent;
                }
            }

            // split the lines of the text file into each component
            string[] info = line.Split('|');

            // update all information for the new TaskSO from the text file
            mostRecentNode        = ScriptableObject.CreateInstance <TaskSO>();
            mostRecentNode.parent = currentParent;
            currentParent.children.Add(mostRecentNode);
            int    index  = Mathf.Max(info[0].IndexOf("."), 0);
            string modded = info[0].Substring(0, index);
            mostRecentNode.icon = Resources.Load <Sprite>(modded);
            if (mostRecentNode.icon == null)
            {
                Texture2D newTex = Texture2D.blackTexture;

                mostRecentNode.icon = Sprite.Create(newTex, new Rect(0.0f, 0.0f, newTex.width, newTex.height), new Vector2(0.5f, 0.5f), 100.0f);
            }
            mostRecentNode.title = info[1];

            if (info.Length > 2)
            {
                mostRecentNode.achievementText = info[2];
            }

            if (info.Length > 3)
            {
                if (info[3] == "S")
                {
                    mostRecentNode.timeToAppear = 6;
                }
                else if (info[3] == "M")
                {
                    mostRecentNode.timeToAppear = 15;
                }
                else if (info[3] == "L")
                {
                    mostRecentNode.timeToAppear = 30;
                }
            }
            else
            {
                mostRecentNode.timeToAppear = 0;
            }
            if (info.Length > 4)
            {
                mostRecentNode.tags = info[4].Split(',');
                for (int i = 0; i < mostRecentNode.tags.Length; i++)
                {
                    mostRecentNode.tags[i] = mostRecentNode.tags[i].Replace(" ", "");
                }
            }

            TaskSO getAllParentsTime = mostRecentNode;
            while (getAllParentsTime = getAllParentsTime.parent)
            {
                mostRecentNode.timeToAppear += getAllParentsTime.timeToAppear;
            }

            previousTabCount = tabCount; // update the previous tab count to the tab count of the line just specified
        }

        root.timeToAppear = 0f;
        return(root);
    }