Пример #1
0
    private void ParseAtoms()
    {
        string atom_pattern = @"^(?<x>[0-9 .-]{10})(?<y>[0-9 .-]{10})(?<z>[0-9 .-]{10}) (?<Symbol>[A-z* ]{3})(?<MassDiff>[0-9 -]{2})(?<Charge>[0-9 ]{3})(?:[0-9 .-]{3}){10}$";

        for (int i = 0; i < _numOfAtoms; i++)
        {
            Match      result     = GetMatch(atom_pattern);
            AtomDetail atomDetail = new AtomDetail();
            atomDetail.atomSymbol = result.Groups["Symbol"].Value.Trim();
            atomDetail.position   = new Vector3(Convert.ToSingle(result.Groups["x"].Value),
                                                Convert.ToSingle(result.Groups["y"].Value),
                                                Convert.ToSingle(result.Groups["z"].Value));
            atomDetail.charge = Convert.ToInt32(result.Groups["Charge"].Value);
            _atomDetailList.Add(atomDetail);
        }
    }
Пример #2
0
    public void Fill(AtomDetail dt, PlanetDetail p, ref int plugged, ref int added, ref int possible)
    {
        var path = Application.dataPath + "/Resources/" + p.id;

        if (!Directory.Exists(path))
        {
            return;
        }

        var s  = Directory.GetFiles(path);
        var sL = new List <string> (s);

        for (int i = sL.Count - 1; i >= 0; i--)
        {
            if (sL [i].Contains(".meta"))
            {
                sL.RemoveAt(i);
            }
        }
        s      = sL.ToArray();
        added += s.Length;
        foreach (var c in dt.images)
        {
            if (!string.IsNullOrEmpty(c.path))
            {
                plugged++;
                continue;
            }
            if (string.IsNullOrEmpty(c.wikiLink))
            {
                Debug.LogWarning("NOT VALID: " + p.name + "/" + dt.head);

                continue;
            }
            possible++;
            string sp;
            if (LocateImage(c.wikiLink, p.id, s, out sp))
            {
                c.path = sp;
                plugged++;
            }
        }
    }
Пример #3
0
    private void ParseBonds()
    {
        string bond_pattern = @"^(?<BondFrom>[0-9 ]{3})(?<BondTo>[0-9 ]{3})(?<BondType>[0-9 ]{3})(?:[0-9 -]{3}){4}$";

        for (int i = 0; i < _numOfBonds; i++)
        {
            // Bound Value - 1: To convert from count base to index base
            Match      result     = GetMatch(bond_pattern);
            int        element    = Convert.ToInt32(result.Groups["BondFrom"].Value) - 1;
            AtomDetail atomDetail = _atomDetailList[element];

            if (atomDetail.bond == null)
            {
                atomDetail.bond     = new List <int>();
                atomDetail.bondType = new List <BondType>();
            }

            atomDetail.bond.Add(Convert.ToInt32(result.Groups["BondTo"].Value) - 1);
            atomDetail.bondType.Add((BondType)Convert.ToUInt32(result.Groups["BondType"].Value));

            _atomDetailList.RemoveAt(element);
            _atomDetailList.Insert(element, atomDetail);
        }
    }