示例#1
0
    // Use this for initialization
    void Start()
    {
        totalPacketSize = 20;

        if (sources.Length > 0)
        {
            packetSize = Mathf.FloorToInt(totalPacketSize / sources.Length);
        }
        else
        {
            packetSize = totalPacketSize;
        }
        heldAmount  = 0;
        tick        = 0;
        tickMax     = 50;
        capacity    = 20;
        crystalSize = new UpgradableStat("crystalSize");
        if (isWell)
        {
            crystalSize.level = 0;
        }
        SetCrystalType();
        crystalRefinement = new UpgradableStat("crystalRefinement");
        if (!isWell)
        {
            upgradableStats.Add(crystalSize);
            upgradableStats.Add(crystalRefinement);
        }
        waitList = new Queue();
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     speed = new UpgradableStat("Speed");
     max   = new UpgradableStat("Max");
     upgradableStats.Add(speed);
     upgradableStats.Add(max);
 }
示例#3
0
 public override void Customize(UpgradableStat target)
 {
     labelText     = gameObject.transform.Find("Label").GetComponent <Text>();
     costText      = gameObject.transform.Find("UpgradeButton/CostLabel").GetComponent <Text>();
     levelText     = gameObject.transform.Find("Level").GetComponent <Text>();
     upgradeButton = gameObject.transform.GetComponentInChildren <Button>();
     Debug.Log("Customizing Upgradable Stat: " + target.upgradeName);
     targetStat = target;
     Debug.Log(labelText);
     labelText.text = target.displayName;
     upgradeButton.onClick.AddListener(Upgrade);
     ResetDisplay();
 }
示例#4
0
 public virtual void Customize(UpgradableStat target)
 {
 }
示例#5
0
    private void CreateElementsDisplay()
    {
        // For the display layout we want to put the children in a line at the bottom
        // and leave room for upgradable stats and bonuses in the middle.
        UIElement newUIElement;
        Button    newUIElementButton;

        // Children First.
        // Let's make a line across the bottom of the screen
        RectTransform navRect    = navigationCanvas.GetComponent <RectTransform>();
        float         lineWidth  = navRect.rect.width * 0.8f;
        float         spaceWidth = lineWidth / currentTarget.children.Count;
        float         xPos;

        float height = navRect.rect.height * 0.3f;

        for (int i = 0; i < currentTarget.children.Count; i++)
        {
            MagicItem child = currentTarget.children[i];
            //newUIElement = Instantiate(child.buttonPrefab).GetComponent<UIElement>();
            newUIElement = Instantiate(buttonPrefab).GetComponent <UIElement>();
            uiElements.Add(newUIElement);
            newUIElement.transform.SetParent(navigationCanvas.transform, false);
            newUIElement.name = "UI-" + child.name;
            newUIElement.Customize(child);

            newUIElementButton = newUIElement.GetComponent <Button>();
            newUIElementButton.onClick.AddListener(() => ChangeTarget(child));
            newUIElementButton.onClick.AddListener(() => AudioManager.instance.Play("ButtonClick"));

            xPos = 0 - (lineWidth / 2) + (spaceWidth * i) + (spaceWidth / 2);
            newUIElement.transform.localPosition = new Vector3(xPos, -height, 0f);
        }

        // Now we need to make the Inspector.
        //int totalInspectorItems;

        // Note: Currently just doing upgrades, in a radial pattern
        // This needs to be upgraded to show bonuses, upgrades, and display
        // items in some kind of grid layout.
        float         theta = (2 * Mathf.PI / currentTarget.upgradableStats.Count);
        float         yPos;
        RectTransform inspectorRect = inspectionCanvas.GetComponent <RectTransform>();
        float         distance      = Mathf.Min(inspectorRect.rect.width, inspectorRect.rect.height) / 8;

        for (int i = 0; i < currentTarget.upgradableStats.Count; i++)
        {
            Debug.Log("Has upgrade:" + currentTarget.upgradableStats[i].upgradeName);
            UpgradableStat upgradable = currentTarget.upgradableStats[i];
            //newUIElement = Instantiate(currentTarget.upgradePrefab).GetComponent<UIElement>();
            newUIElement = Instantiate(upgradePrefab).GetComponent <UIElement>();
            uiElements.Add(newUIElement);
            newUIElement.transform.SetParent(inspectionCanvas.transform, false);
            newUIElement.name = "Uprade-" + upgradable.upgradeName;
            newUIElement.Customize(upgradable);

            if (currentTarget.upgradableStats.Count > 1)
            {
                xPos = Mathf.Sin(theta * i);
                yPos = Mathf.Cos(theta * i);
                newUIElement.transform.localPosition = new Vector3(xPos * distance, yPos * distance, 0);
            }
        }
    }
示例#6
0
 public virtual void StatUpgraded(UpgradableStat stat)
 {
 }
示例#7
0
 public override void StatUpgraded(UpgradableStat stat)
 {
     SetCrystalType();
 }