Example #1
0
 public void SetInventoryCard(InventoryCard item)
 {
     ItemID           = item.ItemId;
     NameText.text    = string.Format("{0}({1})", item.Name, item.Amount);
     curItem          = item;
     ImgSource.sprite = Resources.Load <Sprite>(Canvaser.Instance.AddBrackets(item.Name));
 }
Example #2
0
 /// <summary>
 /// Card text can be hard to read, this will show it in an easier to read panel
 /// </summary>
 public void ShowText(InventoryCard cardToShow)
 {
     if (textPanel != null)
     {
         textPanel.SetActive(true);
         displayCard.Init(cardToShow.thisCard);
     }
 }
Example #3
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     if (!isInDeck)
     {
         cloneToPlace = Instantiate(this, transform.position, Quaternion.identity, GameObject.Find("Deck Building").transform);
         cloneToPlace.Init(thisCard);
     }
     else
     {
     }
 }
Example #4
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (!isInDeck)
        {
            PointerEventData pointerData = new PointerEventData(EventSystem.current);

            pointerData.position = Input.mousePosition; // use the position from controller as start of raycast instead of mousePosition.

            List <RaycastResult> results = new List <RaycastResult>();
            EventSystem.current.RaycastAll(pointerData, results);

            if (results.Exists(e => e.gameObject.GetComponent <InventorySlot>()))
            {
                foreach (var thing in results)
                {
                    var slot = thing.gameObject.transform.GetComponent <InventorySlot>();
                    if (slot != null && !slot.locked)
                    {
                        cloneToPlace.transform.position = slot.transform.position + (Vector3.forward * -.1f);
                        cloneToPlace.AddToDeck(slot);
                    }
                    else if (slot != null && slot.locked)
                    {
                        Destroy(cloneToPlace.gameObject);
                    }
                }
            }
            else
            {
                Destroy(cloneToPlace.gameObject);
            }
        }
        else
        {
            RemoveFromDeck();

            Destroy(gameObject);
        }

        cloneToPlace = null;
    }
Example #5
0
    public Workshop(List <Mesh> meshes, Robot previewRobot, string robotName, List <Part> humanParts, Part[] robotParts, long credits, Color colorScheme, bool enableCreditsSpentAnimation)
    {
        MESHES            = meshes;
        this.previewRobot = previewRobot;
        this.robotName    = robotName;
        this.humanParts   = humanParts;
        this.credits      = credits;
        this.colorScheme  = colorScheme;
        this.enableCreditsSpentAnimation = enableCreditsSpentAnimation;
        goToField = false;
        GameObject widgetsPanel = GameObject.Find("WidgetsPanel");

        foreach (Transform child in widgetsPanel.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        GameObject partsPanel = GameObject.Find("PartsPanel");

        foreach (Transform child in partsPanel.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        MASK = GameObject.Find("Workshop").transform.Find("WorkshopMask").gameObject;
        MASK.SetActive(false);
        BATTLE_BUTTON = GameObject.Find("BattleButton");
        ACTIVE_BATTLE_BUTTON_COLOR = BATTLE_BUTTON.GetComponent <UnityEngine.UI.Image>().color;
        this.robotParts            = new List <Part>();
        if (robotParts != null && robotParts.Length > 0)
        {
            this.robotParts.AddRange(robotParts);
            robot = new Robot("", true, true, this.robotParts.ToArray());
            CONFIGURATION_CARD = new ConfigurationCard(robotName, credits, robot.getDurability(), robot.getRemainingDurability(), robot.getRobotStatStrings(), robot.getWeight() > robot.getMaxForce(), this.robotParts.ToArray(), colorScheme, enableCreditsSpentAnimation);
            CONFIGURATION_CARD.enable();
            INVENTORY_CARD = new InventoryCard(this.credits, this.humanParts.ToArray(), this.robotParts.ToArray());
            INVENTORY_CARD.enable();
        }
        partWithPreviewedTexture = null;
    }
Example #6
0
 public void SetCard(InventoryCard card, string SuitName)
 {
     //set card image by costume ID
     Cards[card.Position - 1].gameObject.SetActive(card.Amount > 0);
     Cards[card.Position - 1].GetComponent <Image>().sprite = Resources.Load <Sprite>(SuitName + " (" + card.Position + ")");
 }