void ResetMissionDesc()
    {
        UnityTools.DestroyAllChildren(assignableList.content);
        UnityTools.DestroyAllChildren(assignedList.content);

        assignableText.text = "Assignable monsters (" + m_assignedMonsters.Count + ")";
        foreach (Monster monster in m_assignableMonsters)
        {
            Button button = Instantiate(m_UI.listButtonPrefab);
            button.GetComponentInChildren <Text>().text = monster.GetName() + " (" + monster.GetCurrentStrength() + "/" + monster.GetMaxStrength() + ")";
            button.transform.SetParent(assignableList.content);
            button.interactable = m_assignedMonsters.Count < m_mission.maxMonstersCount;

            Monster m = monster;
            button.onClick.AddListener(() =>
            {
                m_assignableMonsters.Remove(m);
                m_assignedMonsters.Add(m);
                ResetMissionDesc();
            });

            if (monster.GetCurrentStrength() != monster.GetMaxStrength())
            {
                // TODO plug an event on heal
                button.interactable = false;
            }
        }

        assignedText.text = "Assigned monsters (" + m_assignedMonsters.Count + "/" + m_mission.maxMonstersCount + ")";
        foreach (Monster monster in m_assignedMonsters)
        {
            Button button = Instantiate(m_UI.listButtonPrefab);
            button.GetComponentInChildren <Text>().text = monster.GetName() + " (" + monster.GetCurrentStrength() + "/" + monster.GetMaxStrength() + ")";
            button.transform.SetParent(assignedList.content);

            Monster m = monster;
            button.onClick.AddListener(() =>
            {
                m_assignedMonsters.Remove(m);
                m_assignableMonsters.Add(m);
                ResetMissionDesc();
            });
        }

        startMissionButton.interactable = m_assignedMonsters.Count != 0;
        startMissionButton.onClick.RemoveAllListeners();
        startMissionButton.onClick.AddListener(() =>
        {
            m_company.StartMission(m_mission, m_assignedMonsters);
            UIWindowManager.Instance().DestroyWindow(transform.GetComponentInParent <UIWindow>());
        });

        missionText.text  = "";
        missionText.text += "Obstacles count: " + m_mission.obstacles.Length + "\n";
        missionText.text += "Maximum monsters: " + m_mission.maxMonstersCount + "\n";
        missionText.text += "Reward: " + m_mission.reward + "$\n";
    }
Esempio n. 2
0
    public void SetContent(RectTransform _content)
    {
        if (_content == null)
        {
            return;
        }

        // CLEAR PREVIOUS CONTENT
        UnityTools.DestroyAllChildren(contentTransform);

        // APPLY NEW CONTENT
        _content.SetParent(contentTransform);
    }
Esempio n. 3
0
    void UpdateContent()
    {
        UnityTools.DestroyAllChildren(monstersList.content);
        foreach (Monster monster in m_mission.GetMonsters())
        {
            Button button = Instantiate(UIManager.Instance().listButtonPrefab);
            button.GetComponentInChildren <Text>().text = monster.GetName() + " (" + monster.GetCurrentStrength() + "/" + monster.GetMaxStrength() + ")";

            button.transform.SetParent(monstersList.content);

            Monster m = monster;
            button.onClick.AddListener(() =>
            {
                m_mission.CommitMonster(m);

                UpdateContent();
            });
        }

        int obstacleIndex = 0;

        UnityTools.DestroyAllChildren(progressBar);
        foreach (Obstacle obstacle in m_mission.GetMission().obstacles)
        {
            Button     button = Instantiate(obstacleButtonPrefab);
            ColorBlock color  = button.colors;
            color.normalColor   = obstacleIndex == m_mission.GetCurrentObstacle() ? Color.white : Color.gray;
            color.disabledColor = obstacleIndex == m_mission.GetCurrentObstacle() ? Color.white : Color.gray;
            button.colors       = color;
            //button.GetComponent<Image>().color = obstacleIndex == m_mission.GetCurrentObstacle() ? Color.white : Color.gray;
            button.transform.SetParent(progressBar);
            ++obstacleIndex;
        }

        UpdateObstacleDesc(m_mission.GetCurrentObstacle());
        UpdateObstacleSelection(m_mission.GetCurrentObstacle());
    }
Esempio n. 4
0
    void GenerateStaffButtons(RectTransform _parent)
    {
        // AGGREGATE ASSIGNABLE STAFF
        List <Staff> assignableStaff = new List <Staff>();

        foreach (Staff staff in m_company.GetStaff())
        {
            bool isAssigned = false;
            for (int i = 0; i < m_staff.Length; ++i)
            {
                if (staff == m_staff[i])
                {
                    isAssigned = true;
                    break;
                }
            }

            if (isAssigned)
            {
                continue;
            }

            if (staff.GetAssignment() == null)
            {
                assignableStaff.Insert(0, staff);
            }
            else
            {
                assignableStaff.Add(staff);
            }
        }

        // GENERATE BUTTONS
        ScrollRect assignable     = _parent.Find("_left/_assignable").GetComponent <ScrollRect>();
        Text       assignableText = _parent.Find("_left/_assignableText").GetComponent <Text>();
        ScrollRect assigned       = _parent.Find("_right/_assigned").GetComponent <ScrollRect>();
        Text       assignedText   = _parent.Find("_right/_assignedText").GetComponent <Text>();

        // ASSIGNABLE
        UnityTools.DestroyAllChildren(assignable.content);
        foreach (Staff staff in assignableStaff)
        {
            Button button     = Object.Instantiate(UIManager.Instance().listButtonPrefab);
            Text   buttonText = button.GetComponentInChildren <Text>();

            buttonText.text = staff.GetName();

            if (staff.GetAssignment() == null)
            {
                buttonText.text += " (Idle)";
            }
            else
            {
                buttonText.text += " (In " + staff.GetAssignment().GetName() + ")";
            }

            Staff s = staff;
            button.onClick.AddListener(() =>
            {
                m_company.AssignStaff(s, this);
            });

            button.transform.SetParent(assignable.content);
        }
        assignableText.text = "Assignable (" + assignableStaff.Count + ")";

        // ASSIGNED
        UnityTools.DestroyAllChildren(assigned.content);
        int assignedCount = 0;

        for (int i = 0; i < m_staff.Length; ++i)
        {
            if (m_staff[i] == null)
            {
                continue;
            }

            ++assignedCount;

            Button button     = Object.Instantiate(UIManager.Instance().listButtonPrefab);
            Text   buttonText = button.GetComponentInChildren <Text>();

            buttonText.text = m_staff[i].GetName();

            Staff s = m_staff[i];
            button.onClick.AddListener(() =>
            {
                m_company.UnassignStaff(s, this);
            });

            button.transform.SetParent(assigned.content);
        }
        assignedText.text = "Assigned (" + assignedCount + "/" + m_staff.Length + ")";
    }