Ejemplo n.º 1
0
    // Unity Methods and Events
    #region Unity Events and Methods

    /// <summary>
    /// Initialize and Get dependencies
    /// </summary>
    ///
    private void Start()
    {
        if (shieldProjector == null)
        {
            shieldProjector = GetComponentInChildren <ShieldProjector>();
        }

        if (weaponsSystem == null)
        {
            weaponsSystem = gameObject.GetComponent <WeaponsSystem>();
        }

        if (shieldProjector == null)
        {
            shieldProjector = GetComponentInChildren <ShieldProjector>();
        }

        if (playerHUD == null)
        {
            playerHUD = gameObject.GetComponent <PlayerHUDHandler>();
        }

        if (rigidbody == null)
        {
            rigidbody = gameObject.GetComponent <Rigidbody>();
        }

        foreach (Player player in GameObject.FindObjectsOfType <Player>())
        {
            player.FindShip();
        }

        // Set the cameras size and positions
        gunnerCamera.rect = new Rect(0, 0.0f, 1.0f, 0.5f);
        pilotCamera.rect  = new Rect(0, 0.5f, 1.0f, 0.5f);

        gunnerCenter = gunnerslockUI.transform.position;

        boostGauge = myProperties.maxBoostGauge;

        if (!shipHP)
        {
            TryGetComponent(out shipHP);
        }

        if (!audioSource)
        {
            TryGetComponent(out audioSource);
        }

        boostDepleteDelay = myProperties.boostDepleteDelay;
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        if (shipStats == null)
        {
            if (TryGetComponent(out ShipController player))
            {
                shipStats = player.Properties;
            }
            else if (TryGetComponent(out EnemyController enemy))
            {
                shipStats = enemy.Stats;
            }
            else if (TryGetComponent(out FlockAgent flockAgent))
            {
                shipStats = flockAgent.swarm.FlockLeader.Stats;
            }
            else
            {
                Debug.LogError("Couldn't get ship stats");
            }
        }

        currentLife   = MaxLife;
        currentShield = MaxShield;

        ShieldProjector shieldProjector = gameObject.GetComponentInChildren <ShieldProjector>();

        if (shieldProjector)
        {
            // So we can take damage when this shield is hit
            shieldProjector.onShieldHit += OnShieldHit;

            // So we can update the color of the shield when we take damage
            onShieldChange += shieldProjector.UpdateShieldPercent;
        }
    }