예제 #1
0
        public void ToggleSelection(bool _isSelected)
        {
            int crewNumber = ship.crew.transform.childCount;

            for (int i = 0; i < crewNumber; i++)
            {
                GameObject crewmemberGO = ship.crew.transform.GetChild(i).gameObject;
                if (crewmemberGO != this.gameObject)
                {
                    Crewmember crewmember = crewmemberGO.GetComponent <Crewmember>();
                    crewmember.isSelected = false;
                    if (crewmember.toggle != null)
                    {
                        crewmember.toggle.isOn = false;
                    }
                }
            }

            if (toggle != null)
            {
                toggle.isOn = isSelected = _isSelected;
            }
            else
            {
                isSelected = _isSelected;
            }
        }
예제 #2
0
        private void RepairRobots()
        {
            for (int i = 0; i < crewmembers.Count; i++)
            {
                Crewmember crewmember = crewmembers[i].GetComponent <Crewmember>();

                if (crewmember.IsMachine)
                {
                    crewmember.Heal(robotics.powerConsumption * robotics.repairRatio * Time.deltaTime);
                }
            }
        }
예제 #3
0
        private void HealCrewmembers()
        {
            for (int i = 0; i < crewmembers.Count; i++)
            {
                Crewmember crewmember = crewmembers[i].GetComponent <Crewmember>();

                if (!crewmember.IsMachine)
                {
                    crewmember.Heal(medbay.powerConsumption * medbay.healRatio * Time.deltaTime);
                }
            }
        }
예제 #4
0
        public void SetupCrew()
        {
            int currentButtonIndex = 0;

            for (int i = 0; i < playerShip.crew.transform.childCount; i++)
            {
                GameObject crewmemberGO;
                crewmemberGO = playerShip.crew.transform.GetChild(i).gameObject;

                // if the crewmember's gameobject is inactive for some reason, skip to next
                if (crewmemberGO.activeSelf == false)
                {
                    continue;
                }

                Crewmember crewmember = crewmemberGO.GetComponent <Crewmember>();

                GameObject crewmemberButtonGO = this.transform.GetChild(currentButtonIndex).gameObject;

                Image crewmemberIcon = crewmemberButtonGO.transform.GetChild(0).GetComponentInChildren <Image>(true);
                // enable crew icon
                crewmemberIcon.enabled = true;
                // set crew icon
                crewmemberIcon.sprite = crewmember.icon;
                crewmemberIcon.color  = crewmember.GetComponent <SpriteRenderer>().color;

                RectTransform     crewAttPanelRectT = crewmemberButtonGO.transform.Find("CrewAttributesPanel").GetComponent <RectTransform>();
                AttributesUIPanel attUI             = crewAttPanelRectT.GetComponent <AttributesUIPanel>();
                attUI.SetCrewmember(crewmember);

                // set double click
                CustomButton crewmemberButton = crewmemberButtonGO.GetComponent <CustomButton>();
                crewmemberButton.onDoubleTap.AddListener(
                    () => crewAttPanelRectT.gameObject.SetActive(!crewAttPanelRectT.gameObject.activeSelf)
                    );

                crewmemberButton.onDoubleTap?.Invoke();

                UnityEngine.UI.Toggle crewToggle  = crewmemberButtonGO.GetComponent <UnityEngine.UI.Toggle>();
                ToggleColor           toggleColor = crewmemberButtonGO.GetComponent <ToggleColor>();
                // assign toggle to the crewmember's script
                crewmember.toggle = crewToggle;
                // remove all previous functionalities from crew toggle
                crewToggle.onValueChanged.RemoveAllListeners();
                // add functionality to crew toggle
                crewToggle.onValueChanged.AddListener(crewmember.ToggleSelection);
                crewToggle.onValueChanged.AddListener(toggleColor.OnToggleValueChanged);

                // add to crew button index
                currentButtonIndex++;
            }
        }
예제 #5
0
        IEnumerator RepairRoom()
        {
            while (true)
            {
                // activate repairer ui
                pawnRepairUI.progressBar.transform.gameObject.SetActive(true);

                // reset repair ratio
                repairRatio = 0;

                for (int i = 0; i < repairers.Count; i++)
                {
                    Crewmember crewmember = repairers[i].GetComponent <Crewmember>();

                    crewmember.state = State.Working;

                    if (crewmember.IsLearner)
                    {
                        crewmember.crewmemberStats.repairXP += Time.deltaTime;
                    }

                    repairRatio += crewmember.crewmemberStats.repairLevel;
                }

                //Debug.Log("Repairing at " + repairRatio + " ratio.");

                repairFill += repairRatio * Time.deltaTime;

                if (pawnRepairUI != null)
                {
                    pawnRepairUI.progressBarFill.fillAmount = repairFill / repairTime;
                }
                else
                {
                    Debug.LogError("pawnRepairUI is missing for " + repairer.name + ". Was this intended?");
                }

                if (repairFill >= repairTime)
                {
                    repairFill = 0;
                    RepairOneBar();
                }

                if (!IsDamaged)
                {
                    StopRepairProgress(repairer);
                }

                yield return(0);
            }
        }
예제 #6
0
        IEnumerator FixRoomBreach()
        {
            while (true)
            {
                // activate breach fixer ui
                pawnBreachFixerUI.progressBar.transform.gameObject.SetActive(true);

                // reset breach ratio
                breachFixingRatio = 0;

                for (int i = 0; i < breachFixers.Count; i++)
                {
                    Crewmember crewmember = breachFixers[i].GetComponent <Crewmember>();

                    crewmember.state = State.Working;

                    if (crewmember.IsLearner)
                    {
                        crewmember.crewmemberStats.repairXP += Time.deltaTime;
                    }

                    breachFixingRatio += crewmember.crewmemberStats.repairLevel;
                }

                //Debug.Log("Fixing breach at " + breachFixingRatio + " ratio.");

                breachFixingFill += breachFixingRatio * Time.deltaTime;

                if (pawnBreachFixerUI != null)
                {
                    pawnBreachFixerUI.progressBarFill.fillAmount = breachFixingFill / breachFixingTime;
                }
                else
                {
                    Debug.LogError("pawnRepairUI is missing for " + breachFixer.name + ". Was this intended?");
                }

                if (breachFixingFill >= breachFixingTime)
                {
                    breachFixingFill = 0;
                    FixOneBreach();
                }

                if (!IsBreached)
                {
                    StopFixingBreach(breachFixer);
                }

                yield return(0);
            }
        }
예제 #7
0
 public void SetCrewmember(Crewmember crewmember)
 {
     this.crewmember = crewmember;
     SetupPanel();
 }