Esempio n. 1
0
    /// <summary>
    /// in 'Awake' we do things that need to be run once at the
    /// very beginning. NOTE: as of Unity 4, gameobject hierarchy
    /// can not be altered in 'Awake'
    /// </summary>
    protected override void Awake()
    {
        base.Awake();

        if (m_ProjectileSpawnPoint == null)
        {
            m_ProjectileSpawnPoint = gameObject;                // NOTE: may also be set by derived classes
        }
        m_ProjectileDefaultSpawnpoint = m_ProjectileSpawnPoint;

        // if firing delegates haven't been set by a derived or external class yet, set them now
        if (GetFirePosition == null)
        {
            GetFirePosition = delegate()    { return(FirePosition); }
        }
        ;
        if (GetFireRotation == null)
        {
            GetFireRotation = delegate()    { return(m_ProjectileSpawnPoint.transform.rotation); }
        }
        ;
        if (GetFireSeed == null)
        {
            GetFireSeed = delegate()                { return(Random.Range(0, 100)); }
        }
        ;

        m_CharacterController = m_ProjectileSpawnPoint.transform.root.GetComponentInChildren <CharacterController>();

        // reset the next allowed fire time
        m_NextAllowedFireTime = Time.time;
        ProjectileSpawnDelay  = Mathf.Min(ProjectileSpawnDelay, (ProjectileFiringRate - 0.1f));
        if (ShellPrefab != null)
        {
            m_ActualShellScale = ShellPrefab.transform.localScale * ShellScale;
        }

        HaveFireMessage = !string.IsNullOrEmpty(FireMessage);

        // SNIPPET: if you see problems with pooled bullets in multiplayer, you
        // can uncomment this to make the vp_PoolManager instance ignore this
        // shooter's bullet prefabs in multiplayer
        //if (vp_Gameplay.IsMultiplayer && (vp_PoolManager.Instance != null))
        //	vp_PoolManager.Instance.AddIgnoredPrefab(ProjectilePrefab);
    }
Esempio n. 2
0
    /// <summary>
    /// in 'Awake' we do things that need to be run once at the
    /// very beginning. NOTE: as of Unity 4, gameobject hierarchy
    /// can not be altered in 'Awake'
    /// </summary>
    protected override void Awake()
    {
        base.Awake();

        if (m_ProjectileSpawnPoint == null)
        {
            m_ProjectileSpawnPoint = gameObject;                // NOTE: may also be set by derived classes
        }
        m_ProjectileDefaultSpawnpoint = m_ProjectileSpawnPoint;

        // if firing delegates haven't been set by a derived or external class yet, set them now
        if (GetFirePosition == null)
        {
            GetFirePosition = delegate()    { return(FirePosition); }
        }
        ;
        if (GetFireRotation == null)
        {
            GetFireRotation = delegate()    { return(m_ProjectileSpawnPoint.transform.rotation); }
        }
        ;
        if (GetFireSeed == null)
        {
            GetFireSeed = delegate()                { return(Random.Range(0, 100)); }
        }
        ;

        m_CharacterController = m_ProjectileSpawnPoint.transform.root.GetComponentInChildren <CharacterController>();

        // reset the next allowed fire time
        m_NextAllowedFireTime = Time.time;
        ProjectileSpawnDelay  = Mathf.Min(ProjectileSpawnDelay, (ProjectileFiringRate - 0.1f));
        if (ShellPrefab != null)
        {
            m_ActualShellScale = ShellPrefab.transform.localScale * ShellScale;
        }

        HaveFireMessage = !string.IsNullOrEmpty(FireMessage);
    }
Esempio n. 3
0
	/// <summary>
	/// in 'Awake' we do things that need to be run once at the
	/// very beginning. NOTE: as of Unity 4, gameobject hierarchy
	/// can not be altered in 'Awake'
	/// </summary>
	protected override void Awake()
	{
		
		base.Awake();

		if (m_ProjectileSpawnPoint == null)
			m_ProjectileSpawnPoint = gameObject;	// NOTE: may also be set by derived classes

		m_ProjectileDefaultSpawnpoint = m_ProjectileSpawnPoint;

		// if firing delegates haven't been set by a derived or external class yet, set them now
		if (GetFirePosition == null)	GetFirePosition = delegate()	{	return FirePosition; };
		if (GetFireRotation == null)	GetFireRotation = delegate()	{	return m_ProjectileSpawnPoint.transform.rotation;	};
		if (GetFireSeed == null)		GetFireSeed = delegate()		{	return Random.Range(0, 100);	};

		m_CharacterController = m_ProjectileSpawnPoint.transform.root.GetComponentInChildren<CharacterController>();

		// reset the next allowed fire time
		m_NextAllowedFireTime = Time.time;
		ProjectileSpawnDelay = Mathf.Min(ProjectileSpawnDelay, (ProjectileFiringRate - 0.1f));

	}