Exemple #1
0
    void Start()
    {
        if (!GetComponent <AudioSource>())
        {
            gameObject.AddComponent <AudioSource>();
            audioSource = GetComponent <AudioSource>();
        }
        else
        {
            audioSource = GetComponent <AudioSource>();
        }
        mTrans = transform;
        mStats = GameShip.Find(mTrans);

        initialVelocity      = 60;
        maxPitch             = 5;
        maxAimDeviationAngle = 1;

        // Calculate the cannon's maximum range
        mMaxRange = CalculateMaxRange();

        if (mStats != null)
        {
            // Ship stats found -- use it as root node
            mColliders = mStats.GetComponentsInChildren <Collider>();
        }
        else
        {
            // No ship stats present -- see if there is a rigidbody that can be used as root
            Rigidbody rb = mTrans.GetComponent <Rigidbody>();
            mColliders = (rb != null) ? rb.GetComponentsInChildren <Collider>() : GetComponentsInChildren <Collider>();
        }
    }
Exemple #2
0
    /// <summary>
    /// Cache the transform and the ship controlling this cannon.
    /// </summary>

    void Start()
    {
        mTrans = transform;
        mStats = GameShip.Find(mTrans);

        // Calculate the cannon's maximum range
        mMaxRange = CalculateMaxRange();

        if (mStats != null)
        {
            // Ship stats found -- use it as root node
            mColliders = mStats.GetComponentsInChildren <Collider>();
        }
        else
        {
            // No ship stats present -- see if there is a rigidbody that can be used as root
            Rigidbody rb = Tools.GetRigidbody(mTrans);
            mColliders = (rb != null) ? rb.GetComponentsInChildren <Collider>() : GetComponentsInChildren <Collider>();
        }
    }
Exemple #3
0
	/// <summary>
	/// Cache the transform and the ship controlling this cannon.
	/// </summary>

	void Start ()
	{
		mTrans = transform;
		mStats = GameShip.Find(mTrans);

		// Calculate the cannon's maximum range
		mMaxRange = CalculateMaxRange();

		if (mStats != null)
		{
			// Ship stats found -- use it as root node
			mColliders = mStats.GetComponentsInChildren<Collider>();
		}
		else
		{
			// No ship stats present -- see if there is a rigidbody that can be used as root
			Rigidbody rb = ToolCalculations.GetRigidbody(mTrans);
			mColliders = (rb != null) ? rb.GetComponentsInChildren<Collider>() : GetComponentsInChildren<Collider>();
		}
	}