Example #1
0
    public void GalaxuHUD()
    {
        if (target && !targetHUD)
        {
            if (c != null)
            {
                Destroy(c);
            }

            Universe u = Manager.GetComponent <UniverseManager>().universe;

            for (int i = 0; i < UniverseManager.everyGalaxyCanvas.Length; i++)
            {
                if (u.spawnedGalaxies[i])
                {
                    Collider targetCollider = UniverseManager.everyGalaxyCanvas[i].GetComponent <Collider>();

                    if (targetCollider == target)
                    {
                        float a = u.galaxyData[i].ageInBillions;

                        if (a == 0)
                        {
                            double r = random.NextDouble();
                            a = 1 + ((float)r * (6 - 1));
                            a = (float)System.Math.Round(a, 2);
                        }

                        // Top
                        morph.text = "Morphology: " + u.galaxyData[i].GetMorph;

                        // Middle a
                        age.text = a + " billion years old";

                        // Middle b
                        size.text = u.galaxyData[i].MWfactor + " the mass of our Galaxy";

                        // Bottom
                        lbt.text = System.Math.Round(u.galaxyData[i].lookBackTime, 2) + " billion years back in time";
                    }
                }
            }

            galaxyCanvas.transform.position = target.transform.position + new Vector3(0, -1, 0);
            galaxyCanvas.transform.LookAt(transform);
            galaxyCanvas.transform.rotation  = transform.rotation;
            galaxyCanvas.transform.rotation *= Quaternion.Euler(0, 180f, 0);
            c = Instantiate(galaxyCanvas);
            c.transform.localScale = c.transform.localScale / 170;
            c.transform.LookAt(transform);

            targetHUD = true;

            c.transform.rotation = Quaternion.LookRotation(c.transform.position - transform.position);
        }
    }