// Use this for initialization (must Awake, since start of GameLoop will set states)
    void Awake()
    {
        state      = State.SELECT_OBJECTIVE;
        intercepts = null;

        time_to_moon_phys = TIME_TO_MOON_SEC / GravityScaler.GetGameSecondPerPhysicsSecond();

        if (targets.Length == 0)
        {
            Debug.LogError("No targets configured");
        }
        // Player is spaceship 1, others are objectives

        // take first ship to tbe the player
        target = targets[0];


        // Need to configure objective chooser
        SetObjectiveOptions(targets);

        SetState(state);

        // add a trajectory intercepts component (it need to handle markers so it has
        // a monobehaviour base class).
        // The pair of spaceships to be checked will be selected dynamically
        trajIntercepts = gameObject.AddComponent <TrajectoryIntercepts>();
        trajIntercepts.interceptSymbol  = interceptMarker;
        trajIntercepts.rendezvousSymbol = rendezvousMarker;

        spaceshipGO = spaceshipCtrl.transform.parent.gameObject;
        // optional
        spaceshipOrbit = spaceshipGO.GetComponent <OrbitUniversal>();

        // only record the elements that are active at the start of the scene
        orbitPredictors = new List <OrbitPredictor>();
        foreach (OrbitPredictor op in  (OrbitPredictor[])Object.FindObjectsOfType(typeof(OrbitPredictor)))
        {
            if (op.gameObject.activeInHierarchy)
            {
                orbitPredictors.Add(op);
                if (op.transform.parent == spaceshipGO.transform)
                {
                    shipOrbitPredictor = op;
                }
            }
        }
        if (shipOrbitPredictor == null)
        {
            Debug.LogError("Did not find orbit predictor for ship");
        }

        orbitRenderers = new List <OrbitRenderer>();
        foreach (OrbitRenderer or in (OrbitRenderer[])Object.FindObjectsOfType(typeof(OrbitRenderer)))
        {
            if (or.gameObject.activeInHierarchy)
            {
                orbitRenderers.Add(or);
            }
        }
    }
Exemple #2
0
    // Use this for initialization (must Awake, since start of GameLoop will set states)
    void Awake()
    {
        state      = State.SELECT_OBJECTIVE;
        intercepts = null;

        if (targets.Length == 0)
        {
            Debug.LogError("No targets configured");
        }
        // Player is spaceship 1, others are objectives

        // take first ship to tbe the player
        target = targets[0];


        // Need to configure objective chooser
        SetObjectiveOptions(targets);

        SetState(state);

        // add a trajectory intercepts component (it need to handle markers so it has
        // a monobehaviour base class).
        // The pair of spaceships to be checked will be selected dynamically
        trajIntercepts = gameObject.AddComponent <TrajectoryIntercepts>();
        trajIntercepts.interceptSymbol  = interceptMarker;
        trajIntercepts.rendezvousSymbol = rendezvousMarker;

        // only record the elements that are active at the start of the scene
        orbitPredictors = new List <OrbitPredictor>();
        foreach (OrbitPredictor op in  (OrbitPredictor[])Object.FindObjectsOfType(typeof(OrbitPredictor)))
        {
            if (op.gameObject.activeInHierarchy)
            {
                orbitPredictors.Add(op);
            }
        }
        orbitRenderers = new List <OrbitRenderer>();
        foreach (OrbitRenderer or in (OrbitRenderer[])Object.FindObjectsOfType(typeof(OrbitRenderer)))
        {
            if (or.gameObject.activeInHierarchy)
            {
                orbitRenderers.Add(or);
            }
        }
    }