private void Start()
    {
        if (scoreText == null)
        {
            scoreText = GameObject.Find("Score Text").GetComponent <TextMeshProUGUI>();
        }

        if (exteriorPlayer == null)
        {
            exteriorPlayer = GameObject.FindObjectOfType <ExteriorShip>();
        }
        exteriorPlayer.shipHitEvent.AddListener(PlayerShipHit);
        // todo subscrib to events

        if (interiorPlayer == null)
        {
            interiorPlayer = GameObject.FindObjectOfType <InteriorPlayer>();
        }
        // todo subscrib to events

        ExteriorManager exteriorManager = GameObject.FindObjectOfType <ExteriorManager>();

        if (exteriorManager != null)
        {
            exteriorManager.GetSpawnManager().EnemyBlownUpEvent.AddListener(OnEnemyBlownUp);
        }
        else
        {
            Debug.Log("ScoreManager: Unable to find game object with type 'ExteriorManager' to add events listeners to");
        }

        UpdatePastMissionsScore();

        UpdateScoreText();
    }
    private void Awake()
    {
        _rigidbody2D    = GetComponent <Rigidbody2D>();
        _audioSource    = GetComponent <AudioSource>();
        _spriteRenderer = GetComponent <SpriteRenderer>();

        if (exteriorManager == null)
        {
            exteriorManager = GameObject.FindObjectOfType <ExteriorManager>();
        }
        if (interiorManager == null)
        {
            interiorManager = GameObject.FindObjectOfType <InteriorManager>();
        }
        if (exteriorBoundsCamera == null)
        {
            GameObject exteriorBoundsObj = GameObject.Find("ExteriorCamera");
            if (exteriorBoundsObj != null)
            {
                exteriorBoundsCamera = exteriorBoundsObj.GetComponent <Camera>();
            }
        }

        shipHitEvent             = new UnityGameObjectEvent();
        exteriorShipUpdatedEvent = new ExteriorShipEvent();
        exteriorShipMoveEvent    = new ExteriorShipEvent();

        //currentHitPoints = maxHitPoints; // disabled, so can set starting health in editor.

        // calc bounds

        if (exteriorBoundsCamera != null)
        {
            xMin = exteriorBoundsCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).x + boundsPadding;
            xMax = exteriorBoundsCamera.ViewportToWorldPoint(new Vector3(1, 0, 0)).x - boundsPadding;

            yMin = exteriorBoundsCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).y + boundsPadding;
            yMax = exteriorBoundsCamera.ViewportToWorldPoint(new Vector3(0, 1, 0)).y - boundsPadding;
        }
    }
Exemple #3
0
    private void Awake()
    {
        _rigidbody2D    = GetComponent <Rigidbody2D>();
        _audioSource    = GetComponent <AudioSource>();
        _spriteRenderer = GetComponent <SpriteRenderer>();

        if (exteriorManager == null)
        {
            exteriorManager = GameObject.FindObjectOfType <ExteriorManager>();
        }
        if (interiorManager == null)
        {
            interiorManager = GameObject.FindObjectOfType <InteriorManager>();
        }

        if (shipHitEvent == null)
        {
            shipHitEvent = new UnityEvent();
        }

        //currentHitPoints = maxHitPoints; // disabled, so can set starting health in editor.
    }
Exemple #4
0
 private void Awake()
 {
     ExteriorManager.exteriorManager = this;
 }