Esempio n. 1
0
    private void CalculateInfo()
    {
        var info = Game.Instance.playerData.EstimateCombine(atomA, atomB, (int)atomAAmo.value, (int)atomBAmo.value);

        if (info.targetAtom == null)
        {
            infoText.text = "That atom can not be created.";
            produceButton.interactable = false;
            atomResultText.text        = Game.Instance.gameData.GetUknown().GetName();
            return;
        }


        //AtomInfo atomInfo = Game.Instance.gameData.FindAtomInfo(info.targetAtom.GetAtomicNumber());
        AtomData atomData = Game.Instance.gameData.FindAtomData(info.targetAtom.GetAtomicNumber());

        if (!atomData.IsDiscovered())
        {
            atomResultText.text    = Game.Instance.gameData.GetUknown().GetName();
            atomResultImage.sprite = Game.Instance.gameData.GetUknownInfo().GetImage();
        }
        else
        {
            atomResultText.text    = info.targetAtom.GetName();
            atomResultImage.sprite = Game.Instance.gameData.FindAtomInfo(info.targetAtom.GetAtomicNumber())
                                     .GetImage();
        }

        atomProduced = info.targetAtom;

        infoText.text = "Max Production: " + info.amo + "\nSuccess: " + info.success * 100 + "% Stability: " + info.stability * 100 + "%"; // Max Production, Success, Stability

        produceButton.interactable = info.amo > 0;
    }
Esempio n. 2
0
    private void CalculateInfo()
    {
        if (atomA.GetAtomicNumber() == 1)  // Hydrogen can not be split
        {
            infoText.text         = "Hydrogen can not be split";
            splitBtn.interactable = false;
            return;
        }
        PlayerData.AtomCollision info;
        if (toHydrogenToggle.isOn)
        {
            info           = new PlayerData.AtomCollision();
            info.success   = 1;
            info.stability = 1;

            Atom atom = atomA;
            int  amo  = (int)atomAAmo.value;
            do
            {
                var infoTemp = Game.Instance.playerData.EstimateSplit(atom, amo);
                atom = infoTemp.targetAtom;
                amo  = infoTemp.amo;
                print("Currently at: " + atom.GetName() + " " + amo);

                info.targetAtom = atom;
                info.amo        = amo;
                info.success   *= infoTemp.success;
                info.stability *= infoTemp.stability;
            } while (atom.GetAtomicNumber() != 1);
        }
        else
        {
            int amo = atomAAmo.value < 0 ? int.MaxValue : (int)atomAAmo.value;
            info = Game.Instance.playerData.EstimateSplit(atomA, amo);
        }

        AtomData atomData = Game.Instance.gameData.FindAtomData(info.targetAtom.GetAtomicNumber());

        if (!atomData.IsDiscovered())
        {
            atomResultText.text    = Game.Instance.gameData.GetUknown().GetName();
            atomResultImage.sprite = Game.Instance.gameData.GetUknownInfo().GetImage();
        }
        else
        {
            atomResultText.text    = info.targetAtom.GetName();
            atomResultImage.sprite = Game.Instance.gameData.FindAtomInfo(info.targetAtom.GetAtomicNumber())
                                     .GetImage();
        }

        //atomResultText.text = info.targetAtom.GetName();
        infoText.text = "Max Production: " + info.amo + "\nSuccess: " + info.success * 100 + "% Stability: " + info.stability * 100 + "%"; // Max Production, Success, Stability

        splitBtn.interactable = info.amo > 0;
    }
Esempio n. 3
0
    public void Absorb(Atom atom, int amo)
    {
        if (amo == 0)
        {
            return;
        }

        AtomData data = FindAtomData(atom.GetAtomicNumber());

        if (data == null)
        {
            return;
        }

        if (!data.IsDiscovered())
        {
            data.SetIsDiscovered(true);
            if (OnAtomDiscover != null)
            {
                OnAtomDiscover(atom, amo);
            }

            if (maxAtom == null || atom.GetAtomicNumber() > maxAtom.GetAtomicNumber())
            {
                maxAtom = atom;
            }
        }
        if (amo + data.GetCurrAmo() < data.GetCurrAmo())
        {
            amo = int.MaxValue - data.GetCurrAmo();
            if (amo == 0)
            {
                return;
            }
        }

        data.Gain(amo);
        if (OnAtomAdd != null)
        {
            OnAtomAdd(atom, amo);
        }
    }
    public void SetDisplay()
    {
        AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber());
        AtomData data = Game.Instance.gameData.FindAtomData(atom.GetAtomicNumber());

        Atom display = atom;

        if (!data.IsDiscovered())
        {
            info    = Game.Instance.gameData.GetUknownInfo();
            display = Game.Instance.gameData.GetUknown();
        }
        else if (!hasBeenDiscovered)
        {
            exclamationImage.gameObject.SetActive(true);
            hasBeenDiscovered = true;

            clickButton.onClick.RemoveAllListeners();
            clickButton.onClick.AddListener(() => {
                MakeOld();
                ElementsPage.Instance.ClickAtom(atom);
                AudioManager.Instance.PlaySound(clickSound);
            });
        }

        // Display Stuff
        atomNumber.text           = display.GetAtomicNumber() == -1 ? "" : "" + display.GetAtomicNumber();
        atomAbbreviationText.text = display.GetAbbreviation();

        Color c = info.GetCategoryColor();

        background.color = c;
        c  *= .6f;
        c.a = 1f;
        lowBackground.color = c;
    }
Esempio n. 5
0
    public void Setup(Atom a)
    {
        atom = a;

        AtomData data = Game.Instance.gameData.FindAtomData(atom.GetAtomicNumber());
        AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber());

        if (!data.IsDiscovered())
        {
            info = Game.Instance.gameData.GetUknownInfo();
            data = Game.Instance.gameData.GetUknownData();
            a    = Game.Instance.gameData.GetUknown();
        }

        // Display
        nameText.text         = a.GetName();
        atomicNumberText.text = "Atomic Number: \n" + (a.GetAtomicNumber() == -1 ? "?" : "" + a.GetAtomicNumber());
        atomImage.sprite      = info.GetImage();

        // Data
        currAmoText.text        = "Current Amo: " + data.GetCurrAmo();
        passiveGainText.text    = "";// "Passive Gain: " + data.GetPassiveGain(); // What to do with this???
        totalCollectedText.text = "Total Atoms: " + data.GetTotalCollected();
        totalUsedText.text      = "Total Used: " + data.GetTotalUsed();

        // Description
        var size = descriptionText.GetPreferredValues(info.GetDescription(), descriptionText.rectTransform.rect.width, Mathf.Infinity);

        size.x = descriptionContent.sizeDelta.x;
        size.y = Mathf.Abs(size.y) + 5;
        descriptionContent.sizeDelta = size;
        //descriptionText.rectTransform.sizeDelta = size;

        descriptionText.text    = info.GetDescription();
        descriptionScroll.value = 1;
        typeText.text           = "Type: " + info.GetCategoryString();
        weightText.text         = "Weight: " + (info.GetWeight() == -1 ? "???" : "" + info.GetWeight());
        densityText.text        = "Density: " + (info.GetDensity() == -1 ? "???" :
                                                 info.GetDensity() + " g/cm<sup>3</sup>");

        // Isotope
        protonsText.text     = "P: " + (info.GetProtons() == -1 ? "?" : "" + info.GetProtons());
        electronsText.text   = "E: " + (info.GetElectrons() == -1 ? "?" : "" + info.GetElectrons());
        neutronsText.text    = "N: " + (info.GetNeutrons() == -1 ? "?" : "" + info.GetNeutrons());
        radioactiveText.text = "Is Radioactive: " + !info.IsStable();// + " " + info.GetHalfLife() + " " + info.GetStability();

        string isotopeString = "Isotopes:\n<size=80%>\t";
        var    isotopes      = info.GetIsotopes();

        if (isotopes.Length > 0)
        {
            isotopeString += isotopes[0] + "\n\t";
        }
        for (int i = 1; i < isotopes.Length /*&& i < 7*/; i++)    // MAximum of 7 isotopes???
        {
            isotopeString += isotopes[i] + "\n\t";
        }
        isotopeText.text = isotopeString;

        // Area
        string placesString = "Places:\n";
        var    places       = info.GetPlacesToBeFound();

        if (places.Length > 0)
        {
            placesString += "  " + places[0] + "\n";
        }
        for (int i = 1; i < places.Length; i++)
        {
            placesString += "  " + places[i] + "\n";
        }
        placesText.text = placesString;

        string originsString = "Origins:\n";
        var    origins       = info.GetOrigins();

        if (origins.Length > 0)
        {
            originsString += "  " + origins[0] + "\n";
        }
        for (int i = 1; i < origins.Length; i++)
        {
            originsString += "  " + origins[i] + "\n";
        }
        originsText.text = originsString;
    }
Esempio n. 6
0
    public void Setup(Atom a)
    {
        atom = a;

        AtomData data = Game.Instance.gameData.FindAtomData(atom.GetAtomicNumber());
        AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber());

        if (!data.IsDiscovered())
        {
            info = Game.Instance.gameData.GetUknownInfo();
            data = Game.Instance.gameData.GetUknownData();
            a    = Game.Instance.gameData.GetUknown();
        }

        // Color
        Color c = info.GetCategoryColor();

        background.color = c;
        c  *= .6f;
        c.a = 1f;
        darkBackground.color = c;

        var sizeDelta = rect == null ? Vector2.zero : rect.sizeDelta;

        // Name Text
        {
            var size = nameText.GetPreferredValues(a.GetName(), Mathf.Infinity, nameText.rectTransform.rect.height);
            size.y  = nameText.rectTransform.sizeDelta.y;
            size.x += 15f;
            if (size.x > sizeDelta.x)
            {
                sizeDelta.x = size.x;
            }

            nameText.text = a.GetName();
        }

        // Curr Amo Text
        {
            string text = "Amount:\n " + data.GetCurrAmo();

            var size = currAmoText.GetPreferredValues(text, Mathf.Infinity, currAmoText.rectTransform.rect.height);
            size.y  = currAmoText.rectTransform.sizeDelta.y;
            size.x += 15f;
            if (size.x > sizeDelta.x)
            {
                sizeDelta.x = size.x;
            }

            currAmoText.text = text;
        }

        // Passive Gain Text
        {
            string text = "(+" + data.GetPassiveGain() + ")";

            var size = passiveGainText.GetPreferredValues(text, Mathf.Infinity, passiveGainText.rectTransform.rect.height);
            size.y  = passiveGainText.rectTransform.sizeDelta.y;
            size.x += 15f;
            if (size.x > sizeDelta.x)
            {
                sizeDelta.x = size.x;
            }

            passiveGainText.text = text;
        }

        rect.sizeDelta = sizeDelta;
        LateUpdate();
    }