Example #1
0
    private void Start()
    {
        for (int i = 0; i < energyBallList.transform.childCount; i++)
        {
            GameObject ball = energyBallList.transform.GetChild(i).gameObject;
            _energyBalls.Add(ball);
        }

        for (int i = 0; i < _energyBalls.Count; i++)
        {
            _energyBalls[i].transform.SetParent(null);
            _energyBalls[i].SetActive(false);
        }

        // register for events to update UI
        GameObject shipObj = GameObject.Find("ExteriorShip");

        if (shipObj)
        {
            ExteriorShip exteriorShip = shipObj.GetComponent <ExteriorShip>();
            exteriorShip.exteriorShipUpdatedEvent.AddListener(UpdateEnergyBallUI);
        }
        else
        {
            Debug.Log("ExteriorHUD: Unable to find game object with name 'ExternalShip' to add events listeners to");
        }
    }
    private void Awake()
    {
        InteriorManager.interiorManager = this;

        occupiedDebrisLocations     = new GameObject[interiorLayout.DebrisLocations.Length];
        occupiedSteamLocations      = new GameObject[interiorLayout.SteamVentLocations.Length];
        occupiedHullBreachLocations = new GameObject[interiorLayout.HullBreachLocations.Length];

        if (interiorPlayer == null)
        {
            interiorPlayer = GameObject.FindObjectOfType <InteriorPlayer>();
        }
        if (interiorCamera == null)
        {
            interiorCamera = GameObject.Find("InteriorCamera");
        }
        if (interiorCameraQuad == null)
        {
            interiorCameraQuad = GameObject.Find("InteriorCameraQuad");
        }
        if (interiorShipMap == null)
        {
            interiorShipMap = GameObject.Find("ShipInteriorMap");
        }

        GameObject exteriorShipObj = GameObject.Find("ExteriorShip");

        if (exteriorShip == null && exteriorShipObj != null)
        {
            exteriorShip = exteriorShipObj.GetComponent <ExteriorShip>();
        }

        aSource = GetComponent <AudioSource>();
    }
    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();
    }
    public virtual void InitPips(ExteriorShip ship)
    {
        this.ship = ship;

        this.pips = new ResourcePip[ship.MaxHitPoints];

        PositionPips(ship.MaxHitPoints);

        UpdatePips();
    }
Example #5
0
    public void HandleShipDestroyed(ExteriorShip ship)
    {
        _waveManager.StopWaves();

        GameObject.Find("ShipInteriorWalls").SetActive(false);
        GameObject.Find("ShipInteriorMap").SetActive(false);
        GameObject.Find("Stations").SetActive(false);
        GameObject.Find("Siren").SetActive(false);

        GameManager.gameManager.FailMission();
    }
    private GameObject GetPlayerShip()
    {
        if (playerShip == null)
        {
            ExteriorShip ship = GameObject.FindObjectOfType <ExteriorShip>();
            if (ship != null)
            {
                playerShip = ship.gameObject;
            }
        }

        return(playerShip);
    }
    // Push all interior objects in this direction, to simulate inertia of the ship moving around
    private void AddInertiaVelocityToObjects(ExteriorShip ship)
    {
        Vector2 velocity = ship.lastVelocity;

        Vector2 dir = velocity.normalized;
        float   mag = velocity.magnitude * 0.25f;

        interiorPlayer.PushInDir(dir, mag);

        // Push anything that can be pushed! Really shake things up.
        Pushable[] pushables = GameObject.FindObjectsOfType <Pushable>();
        for (int i = 0; i < pushables.Length; i++)
        {
            pushables[i].PushInDir(dir, mag);
        }
    }
Example #8
0
    public void UpdateEnergyBallUI(ExteriorShip ship)
    {
        int nullBalls = ship.NumEnergyBalls;

        for (int i = 0; i < _energyBalls.Count; i++)
        {
            _energyBalls[i].transform.SetParent(null);
            _energyBalls[i].SetActive(false);
        }

        for (int i = 0; i < nullBalls; i++)
        {
            if (i >= _energyBalls.Count)
            {
                _energyBalls.Add(Instantiate(energyBallPrefab));
            }

            _energyBalls[i].SetActive(true);
            _energyBalls[i].transform.SetParent(energyBallList.transform);
        }
    }
Example #9
0
    private void Awake()
    {
        if (exteriorShip == null)
        {
            exteriorShip = GameObject.Find("ExteriorShip").GetComponent <ExteriorShip>();
        }

        aSource = GetComponent <AudioSource>();

        if (addResourceSFX == null)
        {
            addResourceSFX = Resources.Load("phaserUp4") as AudioClip;
        }
        if (doEffectSFX == null)
        {
            doEffectSFX = Resources.Load("powerUp1") as AudioClip;
        }
        if (disableSFX == null)
        {
            disableSFX = Resources.Load("phaserDown3") as AudioClip;
        }
    }