Exemple #1
0
    public void SpawnRewardTick(int amount, TaskBroadcaster tb, EmotionalStateUI emotionUI)
    {
        if (m_taskIconMap.ContainsKey(tb))
        {
            TaskIcon icon = m_taskIconMap[tb];

            RectTransform punishTick = Instantiate <RectTransform>(m_rewardTickPrefab, transform.parent);
            punishTick.position = icon.transform.position + Vector3.up * 30;

            Vector3 start  = punishTick.position;
            Vector3 target = emotionUI.transform.position;
            Vector3 dir    = (start - target + Vector3.up * 20).normalized;
            target += dir * 50.0f;

            Vector3[] path = new Vector3[] { start, Vector3.Lerp(start, target, 0.5f) + Vector3.up * 30.0f, target };

            var seq = DOTween.Sequence();

            seq.Append(punishTick.DOPath(path, 1.0f, PathType.CatmullRom).SetEase(Ease.InCubic));
            seq.Insert(0, punishTick.GetComponent <Image>().DOFillAmount(1.0f, 0.25f));
            seq.InsertCallback(0.9f, () => { emotionUI.Reward(amount, tb); });
            Destroy(punishTick.gameObject, 1.0f);
        }

        //m_emotionalStateUI.Punish(amount, source);
    }
Exemple #2
0
    public void Punish(int amount, TaskBroadcaster source)
    {
        if (m_currentScore == 0)
        {
            return;
        }

        if (m_currentScore > 0 && m_currentScore - amount <= 0)
        {
            Depressed(source);
            return;
        }

        m_currentScore = Mathf.Max(m_currentScore - amount, 0);

        var rt = GetComponent <RectTransform>();

        if (m_currentTweener != null)
        {
            m_currentTweener.Kill(true);
        }

        Vector3 v = new Vector3(Random.Range(-10.0f, -3.0f), Random.Range(-5.0f, -2.0f), 0.0f);

        m_currentTweener = rt.DOPunchPosition(v,
                                              0.7f).OnComplete(() => { transform.position = m_startPos; });
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        SortChildren();

        float x = 5;

        for (int i = 0; i < transform.childCount; i++)
        {
            RectTransform   rt   = (RectTransform)transform.GetChild(i);
            TaskIcon        icon = rt.gameObject.GetComponent <TaskIcon>();
            TaskBroadcaster tb   = icon.TaskBroadcaster;

            icon.TimerBar.fillAmount = Mathf.Clamp01(tb.TotalTime / tb.Task.PunishTime);

            Vector2 target = new Vector2(x, 0);

            rt.anchoredPosition = Vector2.Lerp(rt.anchoredPosition, target, 0.1f);

            if (i < transform.childCount - 1)
            {
                RectTransform   rt2   = (RectTransform)transform.GetChild(i + 1);
                TaskIcon        icon2 = rt2.gameObject.GetComponent <TaskIcon>();
                TaskBroadcaster tb2   = icon2.TaskBroadcaster;

                if (tb.Task.Name == tb2.Task.Name && tb.Task.Grouped && tb2.Task.Grouped)
                {
                    x += 15;
                    continue;
                }
            }

            x += rt.rect.size.x + 5;
        }
    }
Exemple #4
0
    private int Compare(Transform lhs, Transform rhs)
    {
        if (lhs == rhs)
        {
            return(0);
        }
        var test = rhs.gameObject.activeInHierarchy.CompareTo(lhs.gameObject.activeInHierarchy);

        if (test != 0)
        {
            return(test);
        }

        TaskBroadcaster t1 = lhs.GetComponent <TaskIcon>().TaskBroadcaster;
        TaskBroadcaster t2 = rhs.GetComponent <TaskIcon>().TaskBroadcaster;

        int c = t1.Task.Name.CompareTo(t2.Task.Name);

        if (c == 0)
        {
            return(t2.TotalTime.CompareTo(t1.TotalTime));
        }

        return(c);
    }
Exemple #5
0
 public void AddBroadcaster(TaskBroadcaster tb)
 {
     if (!m_broadcasters.Contains(tb))
     {
         m_broadcasters.Add(tb);
         m_taskListUI.BroadcasterAdded(tb);
     }
 }
Exemple #6
0
 public void RemoveBroadcaster(TaskBroadcaster tb)
 {
     if (m_broadcasters.Contains(tb))
     {
         m_broadcasters.Remove(tb);
         m_taskListUI.BroadcasterRemoved(tb);
     }
 }
Exemple #7
0
 public void BroadcasterRemoved(TaskBroadcaster tb)
 {
     if (m_taskIconMap.ContainsKey(tb))
     {
         TaskIcon icon = m_taskIconMap[tb];
         m_taskIconMap.Remove(tb);
         if (icon)
         {
             Destroy(icon.gameObject);
         }
     }
 }
Exemple #8
0
 public void BroadcasterAdded(TaskBroadcaster tb)
 {
     if (!m_taskIconMap.ContainsKey(tb))
     {
         TaskIcon icon = Instantiate <TaskIcon>(m_taskIconPrefab);
         icon.TaskBroadcaster = tb;
         icon.Text.text       = tb.Task.Name;
         icon.Image.sprite    = tb.Task.Icon;
         icon.transform.SetParent(transform);
         icon.transform.GetComponent <RectTransform>().anchoredPosition = new Vector2(GetComponent <RectTransform>().rect.width, 0);
         m_taskIconMap.Add(tb, icon);
     }
 }
Exemple #9
0
    public void Reward(int amount, TaskBroadcaster source)
    {
        if (m_currentScore == 0)
        {
            return;
        }

        m_currentScore = Mathf.Min(m_currentScore + amount, 100);

        var rt = GetComponent <RectTransform>();

        if (m_currentTweener != null)
        {
            m_currentTweener.Kill(true);
        }

        DOTween.Kill(rt);
        m_currentTweener = rt.DOPunchScale(new Vector3(0.1f, 0.1f, 0.1f),
                                           0.7f).OnComplete(() => { });
    }
Exemple #10
0
 // Use this for initialization
 void Start()
 {
     m_tb = GetComponent <TaskBroadcaster>();
     m_growthMultiplier = Random.Range(0.8f, 1.2f);
     m_model.localScale = Vector3.zero;
 }
Exemple #11
0
 public void Reward(int amount, TaskBroadcaster source)
 {
     m_taskListUI.SpawnRewardTick(amount, source, m_emotionalStateUI);
 }
Exemple #12
0
 public void Punish(int amount, TaskBroadcaster source)
 {
     m_taskListUI.SpawnPunishTick(source, m_emotionalStateUI);
 }
Exemple #13
0
 // Use this for initialization
 void Start()
 {
     m_tb = GetComponent <TaskBroadcaster>();
     m_growthMultiplier = Random.Range(0.8f, 1.2f);
 }
Exemple #14
0
 public void Depressed(TaskBroadcaster source)
 {
     m_onDepression.Invoke(source);
 }
Exemple #15
0
 private void Awake()
 {
     m_agent = GetComponent <NavMeshAgent>();
     m_tb    = GetComponent <TaskBroadcaster>();
 }