예제 #1
0
    public ConfigurationCard(string robotName, long credits, double durability, double remainingDurability, string[] robotStatStrings, bool maxForceExceeded, Part[] parts, Color colorScheme, bool enableCreditsSpentAnimation)
    {
        this.robotName           = robotName;
        this.credits             = credits;
        this.durability          = durability;
        this.remainingDurability = remainingDurability;
        this.robotStatStrings    = robotStatStrings;
        this.maxForceExceeded    = maxForceExceeded;
        this.parts       = new List <Part>();
        attachments      = new List <Attachment>();
        this.colorScheme = colorScheme;
        this.enableCreditsSpentAnimation = enableCreditsSpentAnimation;
        foreach (Part part in parts)
        {
            if (!(part is Attachment))
            {
                this.parts.Add(part);
            }
            else
            {
                this.attachments.Add((Attachment)part);
            }
        }
        mode = InventoryCard.MODES.VIEW_PART_STATS;
        MASKED_ROBOT_WIDGET = GameObject.Find("Workshop").transform.Find("MaskedRobotWidget").gameObject;
        MASKED_ROBOT_WIDGET.SetActive(false);
        partBeingPreviewed            = null;
        partToEquipt                  = null;
        PERFORMANCE_METRIC_CALCULATOR = new PerformanceMetricCalculator();
        SCROLL_VIEW = GameObject.Find(CONFIGURATION_CARD_NAME);
        GameObject partsContainerGameObject = GameObject.Find(WIDGETS_CONTAINER_NAME);

        WIDGETS_CONTAINER = partsContainerGameObject.GetComponent <RectTransform>();
        SCROLL_RECT       = SCROLL_VIEW.GetComponent <ScrollRect>();
        WIDGETS_PANEL     = GameObject.Find(WIDGETS_PANEL_NAME).GetComponent <RectTransform>();
        SCROLLBAR_OBJECT  = GameObject.Find(WIDGETS_CARD_NAME).transform.Find(CONFIGURATION_SCROLLBAR_NAME).gameObject;
        SCROLLBAR         = SCROLLBAR_OBJECT.GetComponent <Scrollbar>();
        SCROLLBAR_OBJECT.SetActive(false);
        SCROLL_RECT.vertical        = false;
        robotWidget                 = GameObject.Find(CONFIGURATION_CARD_NAME).transform.Find(ROBOT_WIDGET_NAME).gameObject;
        robotWidgetLabel            = robotWidget.transform.Find(ROBOT_WIDGET_LABEL_NAME).gameObject;
        robotWidgetLabelPlaceholder = robotWidgetLabel.transform.Find("Text Area").Find(ROBOT_WIDGET_LABEL_PLACEHOLDER_NAME).gameObject;
        robotWidgetLabelPlaceholder.GetComponent <TextMeshProUGUI>().enabled = false;
        robotWidgetLabelText          = robotWidgetLabel.transform.Find("Text Area").Find(ROBOT_WIDGET_LABEL_TEXT_NAME).gameObject;
        robotWidgetDurabilityBar      = robotWidget.transform.Find(ROBOT_WIDGET_DURABILITY_BAR_NAME).gameObject;
        robotWidgetDurabilityBarLabel = robotWidget.transform.Find(ROBOT_WIDGET_DURABILITY_BAR_LABEL_NAME).gameObject;
        robotWidgetStats = robotWidget.transform.Find(ROBOT_WIDGET_STATS_NAME).gameObject;
        WORKSHOP_CREDIT  = GameObject.Find("WorkshopCredit");
        updateCredits();
        WORKSHOP_CREDITS_SPENT = GameObject.Find("Workshop").transform.Find("WorkshopCreditsSpent").gameObject;
        WORKSHOP_CREDITS_SPENT_HOME_POSITION = WORKSHOP_CREDITS_SPENT.transform.localPosition;
        WORKSHOP_CREDITS_SPENT.SetActive(false);
        WORKSHOP_CREDIT.GetComponent <TextMeshProUGUI>().color = colorScheme;
        initialize();
    }
예제 #2
0
    public InventoryCard(long credits, Part[] humanParts, Part[] robotParts)
    {
        this.credits                 = credits;
        this.humanParts              = humanParts;
        this.robotParts              = robotParts;
        mode                         = MODES.VIEW_PART_STATS;
        partBeingPreviewed           = null;
        partBeingEquipt              = null;
        currentPartFilter            = DEFAULT_PART_FILTER;
        MASKED_INVENTORY_PART_BUTTON = GameObject.Find("Workshop").transform.Find("MaskedInventoryPartButton").gameObject;
        MASKED_INVENTORY_PART_BUTTON.SetActive(false);
        INVENTORY_SORT = GameObject.Find("InventorySort");
        currentSort    = DEFAULT_SORT;
        PERFORMANCE_METRIC_CALCULATOR = new PerformanceMetricCalculator();
        SCROLL_VIEW = GameObject.Find(INVENTORY_CARD_NAME);
        GameObject partsContainerGameObject = GameObject.Find(PARTS_CONTAINER_NAME);

        PARTS_CONTAINER  = partsContainerGameObject.GetComponent <RectTransform>();
        SCROLL_RECT      = SCROLL_VIEW.GetComponent <ScrollRect>();
        PARTS_PANEL      = GameObject.Find(PARTS_PANEL_NAME).GetComponent <RectTransform>();
        SCROLLBAR_OBJECT = GameObject.Find(INVENTORY_CARD_NAME).transform.Find(INVENTORY_SCROLLBAR_NAME).gameObject;
        SCROLLBAR        = SCROLLBAR_OBJECT.GetComponent <Scrollbar>();
        SCROLLBAR_OBJECT.SetActive(false);
        SCROLL_RECT.vertical = false;
        partButtons          = new List <GameObject>();
        partInfo             = GameObject.Find("Workshop").transform.Find(PART_INFO_NAME).gameObject;
        partType             = partInfo.transform.Find(PART_TYPE_NAME).gameObject;
        durabilityBar        = partInfo.transform.Find(DURABILITY_BAR_NAME).gameObject;
        durabilityBarLabel   = partInfo.transform.Find(DURABILITY_BAR_LABEL_NAME).gameObject;
        partStats            = partInfo.transform.Find(PART_STATS_NAME).gameObject;
        partInfo.SetActive(false);
        partStatsList = new List <GameObject>();
        initialize();
        PART_TABS = new List <GameObject>();
        foreach (Transform childTransform in GameObject.Find("InventoryTabs").transform.Find("InventoryTabMask"))
        {
            if (childTransform.gameObject.name.Contains(PART_TAB_SUFFIX))
            {
                PART_TABS.Add(childTransform.gameObject);
            }
        }
        updateSorting();
    }
예제 #3
0
    public MyRobotsCard(Robot[] myRobots, Part[] humanRobotParts, long credits, Color colorScheme)
    {
        this.myRobots = new List <Robot>();
        this.myRobots.AddRange(myRobots);
        this.humanRobotParts = new List <Part>();
        this.humanRobotParts.AddRange(humanRobotParts);
        this.credits                 = credits;
        this.colorScheme             = colorScheme;
        robotBeingPreviewed          = null;
        robotBeingPicked             = null;
        robotsToRemove               = new List <Robot>();
        selectedRobotIndicesToRemove = new List <int>();
        newRobot       = null;
        mode           = MODES.VIEW_MY_ROBOTS_STATS;
        MY_ROBOTS_SORT = GameObject.Find("MyRobotsSort");
        currentSort    = DEFAULT_SORT;
        SCROLL_VIEW    = GameObject.Find(MY_ROBOTS_CARD_NAME);
        GameObject storeContainerGameObject = GameObject.Find(MY_ROBOTS_CONTAINER_NAME);

        MY_ROBOTS_CONTAINER = storeContainerGameObject.GetComponent <RectTransform>();
        SCROLL_RECT         = SCROLL_VIEW.GetComponent <ScrollRect>();
        MY_ROBOTS_PANEL     = GameObject.Find(MY_ROBOTS_PANEL_NAME).GetComponent <RectTransform>();
        SCROLLBAR_OBJECT    = GameObject.Find(MY_ROBOTS_CARD_NAME).transform.Find(MY_ROBOTS_SCROLLBAR_NAME).gameObject;
        SCROLLBAR           = SCROLLBAR_OBJECT.GetComponent <Scrollbar>();
        SCROLLBAR_OBJECT.SetActive(false);
        SCROLL_RECT.vertical          = false;
        myRobotsButtons               = new List <GameObject>();
        myRobotsInfo                  = GameObject.Find("MyRobots").transform.Find(MY_ROBOTS_INFO_NAME).gameObject;
        myRobotsName                  = myRobotsInfo.transform.Find(MY_ROBOTS_NAME).gameObject;
        myRobotsStats                 = myRobotsInfo.transform.Find(MY_ROBOTS_STATS_NAME).gameObject;
        robotWidgetDurabilityBar      = myRobotsInfo.transform.transform.Find("DurabilityBar").gameObject;
        robotWidgetDurabilityBarLabel = myRobotsInfo.transform.transform.Find("DurabilityBarLabel").gameObject;
        myRobotsInfo.SetActive(false);
        NEW_ROBOT_BUTTON = GameObject.Find("NewRobot");
        NEW_ROBOT_BUTTON.GetComponent <UnityEngine.UI.Image>().color = this.colorScheme;
        REMOVE_ROBOTS_BUTTON        = GameObject.Find("MyRobots").transform.Find("RemoveRobots").gameObject;
        CANCEL_REMOVE_ROBOTS_BUTTON = GameObject.Find("MyRobots").transform.Find("CancelRemoveRobots").gameObject;
        if (myRobots.Length == 0)
        {
            REMOVE_ROBOTS_BUTTON.SetActive(false);
        }
        CANCEL_REMOVE_ROBOTS_BUTTON.SetActive(false);
        MY_ROBOTS_CREDIT = GameObject.Find("MyRobotsCredit");
        MY_ROBOTS_CREDIT.GetComponent <TextMeshProUGUI>().color = this.colorScheme;
        updateCredits();
        myRobotsStatsList = new List <GameObject>();
        foreach (Robot robot in this.myRobots)
        {
            GameObject robotButton = GameObject.Instantiate(Resources.Load("Prefabs/RobotButton") as GameObject);
            Texture2D  robotIcon   = robot.getHead().getIcon();
            if (robotIcon != null)
            {
                robotButton.transform.Find("Icon").GetComponent <UnityEngine.UI.Image>().sprite = Sprite.Create(robotIcon, new Rect(0, 0, robotIcon.width, robotIcon.height), new Vector2(0.5f, 0.5f), 100);
            }
            robotButton.GetComponent <RectTransform>().localScale = Vector3.one;
            robotButton.transform.localPosition = new Vector3(robotButton.transform.localPosition.x, robotButton.transform.localPosition.y, 0);
            robotButton.transform.Find("NameLabel").GetComponent <TextMeshProUGUI>().text = robot.getName();
            robotButton.transform.SetParent(MY_ROBOTS_PANEL);
            robotButton.transform.localPosition = new Vector3(robotButton.transform.localPosition.x, robotButton.transform.localPosition.y, 0);
            robotButton.transform.Find("SelectionIndicator").gameObject.SetActive(false);
            myRobotsButtons.Add(robotButton);
        }
        if (this.myRobots.Count > 0)
        {
            updateSorting();
        }
    }