예제 #1
0
 public virtual bool removePart(Part.slot slot)
 {
     if (!this.parts.ContainsKey(slot))
     {
         throw new KeyNotFoundException("unit " + this + " does not contain slot " + slot);
     }
     if (null != this.parts[slot])
     {
         this.parts[slot].setOwner(null);
         this.parts[slot] = null;
         return(true);
     }
     return(false);
 }
예제 #2
0
 public virtual bool addPartAs(Part part, Part.slot slot)
 {
     if (!part.slots.Contains(slot))
     {
         throw new KeyNotFoundException("part " + part + " does not contain slot " + slot);
     }
     if (!this.parts.ContainsKey(slot))
     {
         throw new KeyNotFoundException("unit " + this + " does not contain slot " + slot);
     }
     if (this.parts[slot] == null)
     {
         this.parts[slot] = part;
         part.setOwner(this);
         return(true);
     }
     return(false);
 }
예제 #3
0
    private void ActivatePartsPanel(ScrollPanel scroll, Part.slot slot)
    {
        int i = 0;

        foreach (Part p in masterInventory.getParts(slot))
        {
            GameObject newButton = (GameObject)Instantiate(partButtonPrefab);
            newButton.transform.SetParent(scroll.contentPanel);
            newButton.transform.localScale = new Vector3(1, 1, 1);

            RectTransform buttonTransform = newButton.GetComponent <RectTransform>();
            buttonTransform.anchorMin        = new Vector2(.03f, 1f);
            buttonTransform.anchorMax        = new Vector2(0.97f, 1f);
            buttonTransform.anchoredPosition = new Vector2(0, (-0.55f - i) * buttonHeight);
            buttonTransform.sizeDelta        = new Vector2(scroll.contentPanel.rect.width * 0.90f, buttonHeight);
            buttonTransform.tag = dynamicTag;

            Button         buttonComponent = newButton.GetComponent <Button>();
            PartButtonLink PB = new PartButtonLink(p, buttonComponent);
            buttonComponent.onClick.AddListener(() => selectPart(PB.part));

            buttonTransform.Find("Part Name").GetComponent <Text>().text = p.displayName;
            if (null != p.owner)
            {
                buttonTransform.Find("Owner Panel").GetComponentInChildren <Text>().text = p.owner.displayName;
            }
            else
            {
                buttonTransform.Find("Owner Panel").gameObject.SetActive(false);
            }

            i++;
        }

        if (Mathf.Abs(i * buttonHeight) > Mathf.Abs(scroll.viewport.rect.y))
        {
            scroll.contentPanel.sizeDelta = new Vector2(scroll.contentPanel.rect.x, Mathf.Abs((i + 0.55f) * buttonHeight) - Mathf.Abs(scroll.viewport.rect.y));
        }

        thirdPanel.Find("Top Panel").gameObject.SetActive(true);

        thirdScroll.scrollPanel.gameObject.SetActive(true);
    }
예제 #4
0
 public partOwnership(Part.slot slot, String partId)
 {
     this.slot   = slot;
     this.partId = partId;
 }
예제 #5
0
 public override bool addPartAs(Part part, Part.slot slot)
 {
     return(base.addPartAs(part, slot));
 }
예제 #6
0
 public static Part getPart(Guid guid, Part.slot slot)
 {
     return(allParts[slot].Find(p => p.partId == guid));
 }
예제 #7
0
 public static List <Part> getParts(Part.slot slot)
 {
     return(allParts[slot]);
 }
예제 #8
0
 public SlotButtonLink(Part.slot s, Button b)
 {
     slot   = s;
     button = b;
 }
예제 #9
0
 public void selectSlot(Part.slot s)
 {
     this.activeSlot = s;
     selectPanel(thirdPanel);
     thirdEdgeButton.interactable = true;
 }