Esempio n. 1
0
        private static Vector3 averageStarLocations(uint[] hdIDs)
        {
            if (hdIDs.Length == 0)
            {
                return(Vector3.zero);
            }

            Vector3 sumVector = Vector3.zero;

            foreach (uint hdId in hdIDs)
            {
                if (!Stars.StarParser.HD_idToIndex.ContainsKey(hdId))
                {
                    continue;
                }

                int            index = Stars.StarParser.HD_idToIndex[hdId];
                Stars.StarData star  = Stars.StarParser.Instance.Stars[index];
                if (star.GameObjectRepresentation != null)
                {
                    Vector3 position = star.GameObjectRepresentation.transform.position;
                    sumVector += position;
                }
            }

            sumVector /= hdIDs.Length;

            return(sumVector);
        }
Esempio n. 2
0
        private static void attachParents(uint[] hdIDs, Transform jewelcase)
        {
            if (hdIDs.Length == 0)
            {
                return;
            }

            foreach (uint hdId in hdIDs)
            {
                if (!Stars.StarParser.HD_idToIndex.ContainsKey(hdId))
                {
                    continue;
                }

                int            index = Stars.StarParser.HD_idToIndex[hdId];
                Stars.StarData star  = Stars.StarParser.Instance.Stars[index];

                if (star.GameObjectRepresentation != null)
                {
                    star.GameObjectRepresentation.transform.parent = jewelcase;
                }
            }
        }
Esempio n. 3
0
        private static void setupAsterismGrabbers()
        {
            GameObject starRoot = new GameObject("StarRoot");

            for (int i = 0; i < AsterismData.Length; i++)
            {
                Asterism asterism = AsterismData[i];
                Vector3  centroid = averageStarLocations(asterism.HD_ids);

                GameObject newRoot   = new GameObject();
                GameObject rest      = new GameObject();
                GameObject jewelcase = new GameObject();

                newRoot.name = asterism.name + "_root";
                newRoot.transform.position = centroid;
                newRoot.transform.rotation = Quaternion.identity;

                rest.name                    = "rest";
                rest.transform.parent        = newRoot.transform;
                rest.transform.localPosition = Vector3.zero;
                rest.transform.localRotation = Quaternion.identity;
                rest.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);

                jewelcase.name                    = "jewelcase";
                jewelcase.transform.parent        = newRoot.transform;
                jewelcase.transform.localPosition = Vector3.zero;
                jewelcase.transform.localRotation = Quaternion.identity;
                jewelcase.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                PullToHold pullscript = jewelcase.AddComponent <PullToHold>();
                pullscript.asterismKey = i;
                pullscript.rest        = rest.transform;
                pullscript.maxSpeed    = 20.0f;

                newRoot.transform.parent = starRoot.transform;
                asterism.root            = newRoot;
                asterism.rest            = rest;
                asterism.mover           = jewelcase;

                System.Collections.Generic.HashSet <uint> used = new System.Collections.Generic.HashSet <uint>();

                GameObject constellationLabel = GameObject.Instantiate(Stars.StarUpdater.Instance.ConstellationLabelPrototype) as GameObject;
                constellationLabel.SetActive(true);
                ConstellationLabel labelBehavior = constellationLabel.GetComponent <ConstellationLabel>();

                if (asterism.root != null)
                {
                    labelBehavior.transform.parent = asterism.root.transform;
                }

                labelBehavior.Label = asterism.name;
                labelBehavior.transform.localPosition = (asterism.root.transform.position.normalized * 500.0f);
                asterism.label = labelBehavior;
                labelBehavior.LabelComp.color = new Color(1.0f, 1.0f, 1.0f, Stars.StarUpdater.Instance.LabelOpacity * 0.8f);

                Stars.StarUpdater.Instance.m_constellationLabels.Add(labelBehavior);

                foreach (uint hdId in asterism.HD_ids)
                {
                    if (!Stars.StarParser.HD_idToIndex.ContainsKey(hdId))
                    {
                        continue;
                    }

                    int            index = Stars.StarParser.HD_idToIndex[hdId];
                    Stars.StarData star  = Stars.StarParser.Instance.Stars[index];

                    star.AsterismIndex = i;
                    Stars.StarParser.Instance.Stars[index] = star;
                    if (star.GameObjectRepresentation != null)
                    {
                        star.GameObjectRepresentation.name             = hdId.ToString();
                        star.GameObjectRepresentation.transform.parent = jewelcase.transform;
                        if (star.Label != "")
                        {
                            if (used.Contains(star.HD_id))
                            {
                                continue;
                            }

                            Stars.StarUpdater.Instance.GenerateStarLabel(star, star.GameObjectRepresentation.transform);
                            used.Add(star.HD_id);
                        }
                    }
                }

                AsterismData[i] = asterism;
            }
        }