Ejemplo n.º 1
0
    public void OpenEditor(GameObject editable)
    {
        //break out?
        gameInfo = GameObject.FindObjectOfType <GameInfo>();
        if (gameInfo.currentlyMouseAiming)
        {
            Close();
            return;
        }
        if (!metaInventory)
        {
            metaInventory = GameObject.FindObjectOfType <MetaInventory>();
        }
        //activate cursor
        Cursor.visible = true;

        //get editable
        obj = editable.transform.parent.gameObject;
        if (editable.GetComponent <EditRotation>())
        {
            //activate mouseaim if...
            mouseAimButton.SetActive(true);
            eRot = editable.GetComponent <EditRotation>();
            elements[4].SetActive(true);
        }
        else
        {
            mouseAimButton.SetActive(false);
            eRot = null;
            //so that you never end up doing it for something else
        }
        //make the title of the ui the obj name
        string objName = obj.name;

        //if it has a (, remove everything after that (
        if (objName.Contains("("))
        {
            int loc = objName.IndexOf("(");
            //substring does the trick
            objName   = objName.Substring(0, loc);
            name.text = objName;
        }
        else
        {
            name.text = objName;
        }

        if (obj.GetComponent <Miner>())
        {
            //set type
            typeSelected = 1;
            //set up layout for miner obj
            miner = obj.GetComponent <Miner>();
            s1.gameObject.SetActive(true);
            s1.maxValue = 1000;
            s1.value    = miner.launchForce;
            s1T.text    = "Launch Force: " + s1.value.ToString();
        }
        if (obj.GetComponent <LauncherController>())
        {
            //set type
            typeSelected = 2;
            //set up layout for launcher obj
            launcher = obj.GetComponent <LauncherController>();
            s1.gameObject.SetActive(true);
            s1.maxValue = 1000;
            s1.value    = launcher.launchForce;
            s1T.text    = "Launch Force: " + s1.value.ToString();
            //set up second slider for interval
            s2.gameObject.SetActive(true);
            s2.maxValue = 2;
            s2.minValue = 0.25f;
            s2.value    = launcher.coolDown;
            s2T.text    = "Fire Interval: " + s2.value.ToString();
        }
        if (obj.GetComponent <OreController>())
        {
            typeSelected = 3;
            ore          = obj.GetComponent <OreController>();
            MidInfoT.gameObject.SetActive(true);
            if (ore.eternal)
            {
                MidInfoT.text = "Quantity: Eternal" + " Hardness: " + ore.hardness;
            }
            else
            {
                MidInfoT.text = "Quantity: " + ore.currentQuantity.ToString() + System.Environment.NewLine + "Hardness: " + ore.hardness;
            }
            MidInfoT.color = ore.GetComponent <SpriteRenderer>().color;

            bottomButton.gameObject.SetActive(true);
            if (ore.eternal)
            {
                print("ore is eternal");
                bottomButton.interactable = true;
                bottomButtonText.text     = "Destroy Ore";
            }
            else if (metaInventory.eternalizers > 0)
            {
                bottomButton.interactable = true;
                bottomButtonText.text     = "Mount MOED";
            }
            else
            {
                bottomButton.interactable = false;
                bottomButtonText.text     = "No MOED's";
            }
        }
        if (obj.GetComponent <Crafting>())
        {
            //set up crafter ui
            typeSelected = 4;
            crafterPanel.SetActive(true);
            craft = obj.GetComponent <Crafting>();
            MidInfoT.gameObject.SetActive(true);
            UIButtonArray car = crafterPanel.GetComponent <UIButtonArray>();
            foreach (Button b in car.buttons)
            {
                ///THIS
                ///MEANS
                ///THAT
                ///ALL
                ///BUTTONS
                ///MUST BE NAMED
                ///P R O P E R L Y !!!
                //print(b.name + " : " + craft.recipe.name);
                if (b.name == craft.recipe.name)
                {
                    car.BClick(b);
                }
            }
        }
        if (obj.GetComponent <UnPackager>())
        {
            typeSelected = 5;
        }
        if (obj.GetComponent <Packager>())
        {
            Packager pack = obj.GetComponent <Packager>();
            typeSelected = 6;
            s1.gameObject.SetActive(true);
            s1.maxValue = 100;
            s1.minValue = 10;
            s1.value    = pack.maxItems;
            s1T.text    = "Maximum Items: " + Mathf.RoundToInt(s1.value).ToString();
        }
        else if (obj.GetComponent <Splitter>())
        {
            split        = obj.GetComponent <Splitter>();
            typeSelected = 7;
            MidInfoT.gameObject.SetActive(true);
            MidInfoT.text  = "Set a filter ->";
            MidInfoT.color = new Color(0, 255, 255, 255);
            filterPanel.gameObject.SetActive(true);
            //setup filter panel
            UIButtonArray ar = filterPanel.GetComponent <UIButtonArray>();
            foreach (Button b in ar.buttons)
            {
                ///THIS
                ///MEANS
                ///THAT
                ///ALL
                ///BUTTONS
                ///MUST BE NAMED
                ///P R O P E R L Y !!!
                if (b.name == split.typeName)
                {
                    ar.BClick(b);
                }
                else
                {
                    if (b.name == "Empty filter" && split.typeName == "")
                    {
                        ar.BClick(b);
                    }
                }
            }
        }
        else if (obj.GetComponent <Pump>())
        {
            pump = obj.GetComponent <Pump>();
            MidInfoT.gameObject.SetActive(true);
            typeSelected = 8;
        }
        else if (obj.GetComponent <Core>())
        {
            typeSelected = 9;
            core         = obj.GetComponent <Core>();
            int lv = core.level;
            MidInfoT.gameObject.SetActive(true);
            MidInfoT.text = "Level " + lv.ToString();
        }
        else if (obj.GetComponent <RocketBase>())
        {
            typeSelected = 10;
            rocket       = obj.GetComponent <RocketBase>();
            MidInfoT.gameObject.SetActive(true);
            rocketPanel.SetActive(true);
            rIronSlider.slider.maxValue = rocket.maxIron;
            rCopSlider.slider.maxValue  = rocket.maxCopper;
            rFuelSlider.slider.maxValue = rocket.maxFuel;
            MidInfoT.text = "Needs rocket fuel";
            //set max
            rIronSlider.SetSliderParameters(rocket.maxIron);
            rCopSlider.SetSliderParameters(rocket.maxCopper);
            rFuelSlider.SetSliderParameters(rocket.maxFuel);
        }
    }
Ejemplo n.º 2
0
 private void Start()
 {
     metaInventory = GameObject.FindObjectOfType <MetaInventory>();
     totalMax      = maxCopper + maxIron + maxFuel;
     aud           = gameObject.GetComponent <AudioSource>();
 }