예제 #1
0
    public void Construct(StarSystemController targetStarSystem, SignalDispatcher signalDispatcher, LocalPlayerManager localPlayerManager)
    {
        _targetStarSystem   = targetStarSystem;
        _signalDispatcher   = signalDispatcher;
        _localPlayerManager = localPlayerManager;

        GetComponentsInChildren <Text>()[0].text = _targetStarSystem.StarName;

        StarSystemData sysData = _targetStarSystem.GetComponent <StarSystemData>();

        GetComponentsInChildren <Text>()[1].text = sysData.OrigX + ", " + sysData.OrigY;
        GetComponentsInChildren <Text>()[2].text = "Harvard Class " + sysData.StarClass.Split('h')[1].ToUpper();
        if (sysData.IsDataKnown)
        {
            GetComponentsInChildren <Text>()[3].text  = "Planets: " + (sysData.PlanetsUnknown ? "More than " : "") + sysData.PlanetsKnown.ToString();
            GetComponentsInChildren <Text>()[4].text  = "Gravity: " + sysData.Gravity;
            GetComponentsInChildren <Text>()[5].text  = "Atmosphere: " + sysData.Atmosphere;
            GetComponentsInChildren <Text>()[6].text  = "Water: " + sysData.Water + "%";
            GetComponentsInChildren <Text>()[7].text  = "Climate: " + sysData.Climate;
            GetComponentsInChildren <Text>()[8].text  = "Terrain: " + sysData.Terrain;
            GetComponentsInChildren <Text>()[9].text  = "Development: " + sysData.Development;
            GetComponentsInChildren <Text>()[10].text = "Flag: " + sysData.HasFlag;
        }
        else
        {
            for (int x = 3; x <= 10; x++)
            {
                GetComponentsInChildren <Text>()[x].text = "";
            }
        }

        GetComponentInChildren <Button>().onClick.AddListener(() => CaptureSystem());
    }
    public override void Select()
    {
        StarSystemController currentSystem = transform.parent.GetComponent <StarSystemController>();

        Collider[] hits = Physics.OverlapSphere(transform.parent.position, 150f);
        for (int hit = 0; hit < hits.Length; hit++)
        {
            StarSystemController hitSystem = hits[hit].GetComponent <StarSystemController>();

            if (hitSystem == currentSystem)
            {
                continue;
            }

            if (hitSystem)
            {
                if (Vector3.Distance(transform.parent.position, hitSystem.transform.position) <= 150f)
                {
                    GameObject lineHolder = new GameObject();
                    _lineList.Add(lineHolder);
                    lineHolder.transform.parent = transform;
                    LineRenderer lineRenderer = lineHolder.AddComponent <LineRenderer>();
                    lineRenderer.material        = new Material(Shader.Find("Particles/Additive"));
                    lineRenderer.widthMultiplier = 1f;

                    if (hitSystem.GetComponent <FactionController>().CurrentFaction != currentSystem.GetComponent <FactionController>().CurrentFaction)
                    {
                        lineRenderer.startColor      = Color.red;
                        lineRenderer.endColor        = Color.red;
                        lineRenderer.widthMultiplier = 2f;
                    }

                    lineRenderer.SetPosition(0, transform.parent.position);
                    lineRenderer.SetPosition(1, hitSystem.transform.position);

                    _jumpable.Add(hitSystem.StarName);
                }
            }
        }

        _uiManager.RegimentSelected(GetComponent <RegimentChit>().Regiment, _jumpable);
    }