protected AudioClip m_LastPlayedSound = null;                       // used to make sure we don't place the same sound twice in a row


    /// <summary>
    /// cache all the necessary properties here
    /// </summary>
    protected virtual void Awake()
    {
        m_Player     = GameObject.FindObjectOfType(typeof(vp_FPPlayerEventHandler)) as vp_FPPlayerEventHandler;
        m_Camera     = GameObject.FindObjectOfType(typeof(vp_FPCamera)) as vp_FPCamera;
        m_Controller = GameObject.FindObjectOfType(typeof(vp_FPController)) as vp_FPController;
        m_Audio      = gameObject.AddComponent <AudioSource>();   // add a new audio source for this class to use
    }
    /// <summary>
    /// tries to add an ammo clip to the player
    /// </summary>
    protected override bool TryGive(vp_FPPlayerEventHandler player)
    {
        if (player.Dead.Active)
        {
            return(false);
        }

        // try to give the player a clip. this will fail if we have max clips
        if (!base.TryGive(player))
        {
            // if inventory is full but current weapon is out of ammo, we can
            // make room for the clip by doing an auto-reload
            if (TryReloadIfEmpty(player))
            {
                // if that succeeded there is now room in the inventory:
                // try to add the clip again
                base.TryGive(player);
                return(true);
            }
            return(false);
        }

        // if the first 'TryGive' succeeded, auto-reload if needed
        TryReloadIfEmpty(player);

        return(true);
    }
	/// <summary>
	/// 
	/// </summary>
	protected virtual void Awake()
	{

		if (GetComponent<vp_FPWeapon>())
		{
			Debug.LogError("Error: (" + this + ") Hierarchy error. This component should sit above any vp_FPWeapons in the gameobject hierarchy.");
			return;
		}

		// store the first player event handler found in the top of our transform hierarchy
		m_Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));

		// add the gameobjects of any weapon components to the weapon list
		foreach (vp_FPWeapon w in GetComponentsInChildren<vp_FPWeapon>(true))
		{
			m_Weapons.Insert(m_Weapons.Count, w);
		}

		if (m_Weapons.Count == 0)
		{
			Debug.LogError("Error: (" + this + ") Hierarchy error. This component must be added to a gameobject with vp_FPWeapon components in child gameobjects.");
			return;
		}

		// sort the weapons alphabetically
		IComparer comparer = new WeaponComparer();
		m_Weapons.Sort(comparer.Compare);

		StartWeapon = Mathf.Clamp(StartWeapon, 0, m_Weapons.Count);

	}
Exemple #4
0
 void Awake()
 {
     if (fpController == null)
     {
         fpController = GetComponentInChildren <vp_FPController>();
     }
     if (fpCamera == null)
     {
         fpCamera = GetComponentInChildren <vp_FPCamera>();
     }
     if (fpPlayerEventHandler == null)
     {
         fpPlayerEventHandler = GetComponentInChildren <vp_FPPlayerEventHandler>();
     }
     if (fpInput == null)
     {
         fpInput = GetComponentInChildren <vp_FPInput>();
     }
     if (fpHUD == null)
     {
         fpHUD = GetComponentInChildren <vp_SimpleHUD>();
     }
     if (fpCrosshair == null)
     {
         fpCrosshair = GetComponentInChildren <vp_SimpleCrosshair>();
     }
 }
Exemple #5
0
    /// <summary>
    /// This method just does some checking to see if the object is in the mask
    /// and if so if it has a vp_FPPlayerEventHandler component and then returns
    /// the data
    /// </summary>
    protected virtual Dictionary <string, object> GetDataForCollider(Collider col)
    {
        // check if collider is in layermask
        if ((LayerMask.value & 1 << col.gameObject.layer) == 0)
        {
            return new Dictionary <string, object>()
                   {
                       { m_IsPlayerKey, false }
                   }
        }
        ;

        // check if player component exists
        vp_FPPlayerEventHandler player = col.gameObject.GetComponent <vp_FPPlayerEventHandler>();

        if (player == null)
        {
            return new Dictionary <string, object>()
                   {
                       { m_IsPlayerKey, false }
                   }
        }
        ;;

        // send data. includes player.
        return(new Dictionary <string, object>()
        {
            { m_IsPlayerKey, true }, { m_PlayerKey, player }
        });
    }
}
Exemple #6
0
    protected virtual void Awake()
    {
        vp_FPWeaponHandler.cs = this;
        if (base.GetComponent <vp_FPWeapon>())
        {
            Debug.LogError("Error: (" + this + ") Hierarchy error. This component should sit above any vp_FPWeapons in the gameobject hierarchy.");
            return;
        }
        this.m_Player = (vp_FPPlayerEventHandler)base.transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));
        vp_FPWeapon[] componentsInChildren = base.GetComponentsInChildren <vp_FPWeapon>(true);
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            vp_FPWeapon item = componentsInChildren[i];
            this.m_Weapons.Insert(this.m_Weapons.Count, item);
        }
        if (this.m_Weapons.Count == 0)
        {
            Debug.LogError("Error: (" + this + ") Hierarchy error. This component must be added to a gameobject with vp_FPWeapon components in child gameobjects.");
            return;
        }
        IComparer @object = new vp_FPWeaponHandler.WeaponComparer();

        this.m_Weapons.Sort(new Comparison <vp_FPWeapon>(@object.Compare));
        this.StartWeapon = Mathf.Clamp(this.StartWeapon, 0, this.m_Weapons.Count);
    }
Exemple #7
0
    public static int guiDepth = 0;                  // define  a static gui depth variable in all other gui classes and use in OnGui() as shown ahead



    void Awake()
    {
        FPS_Player     = this.gameObject;
        m_Player       = FPS_Player.transform.GetComponent <vp_FPPlayerEventHandler>();
        m_Input        = FPS_Player.transform.GetComponent <vp_FPInput>();
        isInPauseState = false;
    }
 public override void OnAwake()
 {
     if (agent == null)
     {
         agent = gameObject.GetComponent <vp_FPPlayerEventHandler>();
     }
 }
Exemple #9
0
    /// <summary>
    ///
    /// </summary>
    protected virtual void Awake()
    {
        if (GetComponent <vp_FPWeapon>())
        {
            Debug.LogError("Error: (" + this + ") Hierarchy error. This component should sit above any vp_FPWeapons in the gameobject hierarchy.");
            return;
        }

        // store the first player event handler found in the top of our transform hierarchy
        m_Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));

        // add the gameobjects of any weapon components to the weapon list
        foreach (vp_FPWeapon w in GetComponentsInChildren <vp_FPWeapon>(true))
        {
            m_Weapons.Insert(m_Weapons.Count, w);
        }

        if (m_Weapons.Count == 0)
        {
            Debug.LogError("Error: (" + this + ") Hierarchy error. This component must be added to a gameobject with vp_FPWeapon components in child gameobjects.");
            return;
        }

        // sort the weapons alphabetically
        IComparer comparer = new WeaponComparer();

        m_Weapons.Sort(comparer.Compare);

        StartWeapon = Mathf.Clamp(StartWeapon, 0, m_Weapons.Count);
    }
Exemple #10
0
    protected AudioClip m_LastPlayedSound = null;                       // used to make sure we don't place the same sound twice in a row


    /// <summary>
    /// cache all the necessary properties here
    /// </summary>
    protected virtual void Awake()
    {
        m_Player     = transform.root.GetComponentInChildren <vp_FPPlayerEventHandler>();
        m_Camera     = transform.root.GetComponentInChildren <vp_FPCamera>();
        m_Controller = transform.root.GetComponentInChildren <vp_FPController>();
        m_Audio      = gameObject.AddComponent <AudioSource>();   // add a new audio source for this class to use
    }
	/// <summary>
	/// tries to add an ammo clip to the player
	/// </summary>
	protected override bool TryGive(vp_FPPlayerEventHandler player)
	{

		if (player.Dead.Active)
			return false;

		for (int v = 0; v < GiveAmount; v++)
		{

			// try to give the player a clip. this will fail if we have max clips
			if (!base.TryGive(player))
			{
				// if inventory is full but current weapon is out of ammo, we can
				// make room for the clip by doing an auto-reload
				if (TryReloadIfEmpty(player))
				{
					// if that succeeded there is now room in the inventory:
					// try to add the clip again
					base.TryGive(player);
					return true;
				}
				return false;
			}

		}

		// if the first 'TryGive' succeeded, auto-reload if needed
		TryReloadIfEmpty(player);

		return true;

	}
Exemple #12
0
    /// <summary>
    /// try to interact with this object
    /// </summary>
    public override bool TryInteract(vp_FPPlayerEventHandler player)
    {
        if (Platform == null)
        {
            return(false);
        }

        if (m_Player == null)
        {
            m_Player = player;
        }

        if (Time.time < m_Timeout)
        {
            return(false);
        }

        PlaySound();

        Platform.SendMessage("GoTo", Platform.TargetedWaypoint == 0 ? 1 : 0, SendMessageOptions.DontRequireReceiver);

        m_Timeout = Time.time + SwitchTimeout;

        m_IsSwitched = !m_IsSwitched;

        return(true);
    }
    /// <summary>
    ///
    /// </summary>
    protected virtual void OnFail(Transform recipient)
    {
        vp_FPPlayerEventHandler localPlayer = recipient.transform.root.GetComponentInChildren <vp_FPPlayerEventHandler>();

        if (localPlayer != null)
        {
            if (localPlayer.Dead.Active)
            {
                return;
            }
        }

        if (!m_AlreadyFailed &&
            (m_Sound.PickupFailSound != null) &&
            (!vp_Gameplay.IsMultiplayer || (vp_Gameplay.IsMultiplayer && (recipient.GetComponent <vp_FPPlayerEventHandler>() != null)))
            )
        {
            Audio.pitch = m_Sound.FailSoundSlomo ? Time.timeScale : 1.0f;
            Audio.PlayOneShot(m_Sound.PickupFailSound);
        }
        m_AlreadyFailed = true;

        string msg = "";

        if ((m_PickedUpAmount < 2) || (ItemType == typeof(vp_UnitBankType)) || (ItemType.BaseType == typeof(vp_UnitBankType)))
        {
            msg = string.Format(m_Messages.FailSingle, m_Item.Type.IndefiniteArticle, m_Item.Type.DisplayName, m_Item.Type.DisplayNameFull, m_Item.Type.Description, Amount.ToString());
        }
        else
        {
            msg = string.Format(m_Messages.FailMultiple, m_Item.Type.IndefiniteArticle, m_Item.Type.DisplayName, m_Item.Type.DisplayNameFull, m_Item.Type.Description, Amount.ToString());
        }

        vp_GlobalEvent <Transform, string> .Send("HUDText", recipient, msg);
    }
Exemple #14
0
    /// <summary>
    /// this is triggered when an object enters the collider and
    /// InteractType is set to trigger
    /// </summary>
    protected virtual void OnTriggerEnter(Collider col)
    {
        // only do something if the trigger is of type Trigger
        if (InteractType != vp_InteractType.Trigger)
        {
            return;
        }

        // see if the colliding object was a valid recipient
        foreach (string s in RecipientTags)
        {
            if (col.gameObject.tag == s)
            {
                goto isRecipient;
            }
        }
        return;

isRecipient:

        m_Player = col.gameObject.GetComponent <vp_FPPlayerEventHandler>();

        if (m_Player == null)
        {
            return;
        }

        // calls the TryInteract method which is hopefully on the inherited class
        TryInteract(m_Player);
    }
    /// <summary>
    /// 
    /// </summary>
    protected virtual void Awake()
    {
        m_Audio = audio;

        // store the first player event handler found in the top of our transform hierarchy
        m_Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));
    }
	/// <summary>
	/// 
	/// </summary>
	protected virtual void Awake()
	{
		
		m_Player = GetComponent<vp_FPPlayerEventHandler>(); // cache the player event handler
		m_Camera = GetComponentInChildren<vp_FPCamera>(); // cache vp_FPCamera
		
	}
Exemple #17
0
 void Awake()
 {
     if (!m_Player)
     {
         m_Player = transform.GetComponent <vp_FPPlayerEventHandler>();
     }
 }
Exemple #18
0
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go == null)
            {
                Finish();
                return;
            }

            _player = go.GetComponent <vp_FPPlayerEventHandler>();

            if (_player == null)
            {
                Finish();
                return;
            }

            getHealth();

            if (!everyFrame)
            {
                Finish();
            }
        }
Exemple #19
0
    /// <summary>
    /// this method quickly determines if the colliding object is a
    /// player that we will do something about. a dictionary is used to
    /// remember past players so we don't have to scan their hierarchy
    /// for an event handler every time
    /// </summary>
    protected bool GetPlayer(Collider col)
    {
        // see if this is a valid player object, or auto-approve
        // if it has been recently validated
        if (!m_KnownPlayers.ContainsKey(col))
        {
            if (col.gameObject.layer != vp_Layer.LocalPlayer)
            {
                return(false);
            }

            vp_FPPlayerEventHandler player = col.transform.root.GetComponent <vp_FPPlayerEventHandler>();
            if (player == null)
            {
                return(false);
            }

            m_KnownPlayers.Add(col, player);
        }

        if (!m_KnownPlayers.TryGetValue(col, out m_PlayerToPush))
        {
            return(false);
        }

        m_PlayerCollider = col;

        return(true);
    }
        private void Awake()
        {
                        #if UltimateFPSIsPresent
            // Tag the GameObject as 'Player' if it is not already
            gameObject.tag = Tags.player;
            player         = GetComponent <Player>();

            // Assign the UFPS components, and report warnings if they are not present
            fpCamera             = GetComponentInChildren <vp_FPCamera>();
            fpController         = GetComponentInChildren <vp_FPController>();
            fpInput              = GetComponentInChildren <vp_FPInput>();
            fpPlayerEventHandler = GetComponentInChildren <vp_FPPlayerEventHandler>();
            simpleHUD            = GetComponentInChildren <vp_SimpleHUD>();
            simpleCrosshair      = GetComponentInChildren <vp_SimpleCrosshair>();
            _audioListener       = GetComponentInChildren <AudioListener>();

            if (fpController == null)
            {
                ACDebug.LogWarning("Cannot find UFPS script 'vp_FPController' anywhere on '" + gameObject.name + "'.");
            }
            if (fpInput == null)
            {
                ACDebug.LogWarning("Cannot find UFPS script 'vp_FPInput' anywhere on '" + gameObject.name + "'.");
            }
            if (fpCamera == null)
            {
                ACDebug.LogWarning("Cannot find UFPS script 'vp_FPCamera' anywhere on '" + gameObject.name + "'.");
            }
            if (KickStarter.settingsManager != null && KickStarter.settingsManager.movementMethod != MovementMethod.FirstPerson)
            {
                ACDebug.Log("The Ultimate FPS integration script requires the Settings Manager's 'Movement method' is set to 'First Person'");
            }
                        #endif
        }
Exemple #21
0
    /// <summary>
    ///
    /// </summary>
    protected virtual void Awake()
    {
        m_Audio = audio;

        // store the first player event handler found in the top of our transform hierarchy
        m_Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));
    }
Exemple #22
0
    /// <summary>
    /// looks for a player and if the player is dead
    /// mark it as so and stop attacking
    /// </summary>
    protected virtual void CheckPlayerUpdate()
    {
        if (m_PlayerDead)
        {
            return;
        }

        if (!m_EventHandler.Attacking.Active)
        {
            return;
        }

        if (m_EventHandler.HostileTarget.Get() == null)
        {
            return;
        }

        vp_FPPlayerEventHandler player = vp_AIManager.GetPlayer(m_EventHandler, m_EventHandler.HostileTarget.Get());

        if (player == null)
        {
            return;
        }

        if (player.Dead.Active)
        {
            m_PlayerDead = true;
            m_EventHandler.Reload.TryStart();
            m_EventHandler.Attacking.Stop();
        }
    }
Exemple #23
0
	private void Awake()
	{
		this.trPlayer = GameObject.Find("LocalPlayer").transform;
		this.trCamera = Camera.main.transform;
		this.csUPlayer = (UnityEngine.Object.FindObjectOfType(typeof(vp_FPPlayerEventHandler)) as vp_FPPlayerEventHandler);
		RegularSend.sendtime = Time.realtimeSinceStartup;
	}
 // Use this for initialization
 void Start()
 {
     if (m_Player == null)
     {
         m_Player = GameObject.Find("Gringan").GetComponent <vp_FPPlayerEventHandler>();
     }
 }
Exemple #25
0
    /// <summary>
    /// Gets properties for the specified AI and player
    /// and adds the properties if none exist
    /// </summary>
    public static vp_FPPlayerEventHandler GetPlayer(vp_AIEventHandler ai, Transform t)
    {
        vp_FPPlayerEventHandler player = null;

        // if the AI is not registered, return
        if (!Instance.AIs.ContainsKey(ai))
        {
            return(null);
        }

        // if a dictionary hasn't been created for some reason, create it and then add the player
        Dictionary <Transform, vp_FPPlayerEventHandler> dict = null;

        if (!Instance.AIs.TryGetValue(ai, out dict))
        {
            dict = new Dictionary <Transform, vp_FPPlayerEventHandler>();
            goto Add;
        }

        // if the player doesn't exist, add it
        if (!dict.TryGetValue(t, out player))
        {
            goto Add;
        }

        // if player was found, return the properties
        return(player);

        // add the player for this AI
Add:
        return(Instance.AddPlayerForAI(ai, t));
    }
Exemple #26
0
    void Awake()
    {
        // GETTING THE PLAYER'S EVENT HANDLER
        m_Player = transform.GetComponent<vp_FPPlayerEventHandler>();

        // GETTING THE PLAYER'S CHARACTER CONTROLLER
        character = GetComponent<CharacterController>();
    }
 /// <summary>
 ///
 /// </summary>
 void Start()
 {
     Player = transform.root.GetComponent <vp_FPPlayerEventHandler>();
     if (Player == null)
     {
         this.enabled = false;
     }
 }
	/// <summary>
	/// 
	/// </summary>
	void Start()
	{

		Player = transform.root.GetComponent<vp_FPPlayerEventHandler>();
		if (Player == null)
			this.enabled = false;

	}
		void Awake() {
			if (fpController == null) fpController = GetComponentInChildren<vp_FPController>();
			if (fpCamera == null) fpCamera = GetComponentInChildren<vp_FPCamera>();
			if (fpPlayerEventHandler == null) fpPlayerEventHandler = GetComponentInChildren<vp_FPPlayerEventHandler>();
			if (fpInput == null) fpInput = GetComponentInChildren<vp_FPInput>();
			if (fpHUD == null) fpHUD = GetComponentInChildren<vp_SimpleHUD>();
			if (fpCrosshair == null) fpCrosshair = GetComponentInChildren<vp_SimpleCrosshair>();
		}
Exemple #30
0
    private void Awake()
    {
        Transform transform = base.transform;

        this.m_Audio = base.GetComponent <AudioSource>();
        foreach (GameObject current in this.FXPrefabs)
        {
            Component[] components = current.GetComponents <vp_Explosion>();
            if (components.Length == 0)
            {
                UnityEngine.Object.Instantiate(current, transform.position, transform.rotation);
            }
            else
            {
                Debug.LogError("Error: vp_Explosion->FXPrefab must not be a vp_Explosion (risk of infinite loop).");
            }
        }
        Collider[] array  = Physics.OverlapSphere(transform.position, this.Radius, -746586133);
        Collider[] array2 = array;
        for (int i = 0; i < array2.Length; i++)
        {
            Collider collider = array2[i];
            if (collider != base.GetComponent <Collider>())
            {
                float num = 1f - Vector3.Distance(transform.position, collider.transform.position) / this.Radius;
                if (collider.GetComponent <Rigidbody>())
                {
                    Ray        ray = new Ray(collider.transform.position, -Vector3.up);
                    RaycastHit raycastHit;
                    if (!Physics.Raycast(ray, out raycastHit, 1f))
                    {
                        this.UpForce = 0f;
                    }
                    collider.GetComponent <Rigidbody>().AddExplosionForce(this.Force / Time.timeScale, transform.position, this.Radius, this.UpForce);
                }
                else if (collider.gameObject.layer == 30)
                {
                    vp_FPPlayerEventHandler component = collider.GetComponent <vp_FPPlayerEventHandler>();
                    if (component)
                    {
                        component.ForceImpact.Send((collider.transform.position - transform.position).normalized * this.Force * 0.001f * num);
                        component.BombShake.Send(num * this.CameraShake);
                    }
                }
                if (collider.gameObject.layer != 29)
                {
                    collider.gameObject.BroadcastMessage(this.DamageMessageName, num * this.Damage, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        this.m_Audio.clip  = this.Sound;
        this.m_Audio.pitch = UnityEngine.Random.Range(this.SoundMinPitch, this.SoundMaxPitch) * Time.timeScale;
        if (!this.m_Audio.playOnAwake)
        {
            this.m_Audio.Play();
        }
    }
Exemple #31
0
 public override void OnEnter()
 {
     player = ((GameObject)gameObject.Value).GetComponent <vp_FPPlayerEventHandler> ();
     DoGetHealth();
     if (!everyFrame)
     {
         Finish();
     }
 }
	protected AudioClip m_LastPlayedSound = null;			// used to make sure we don't place the same sound twice in a row
	
	
	/// <summary>
	/// cache all the necessary properties here
	/// </summary>
	protected virtual void Awake()
	{
		
		m_Player = transform.root.GetComponentInChildren<vp_FPPlayerEventHandler>();
		m_Camera = transform.root.GetComponentInChildren<vp_FPCamera>();
		m_Controller = transform.root.GetComponentInChildren<vp_FPController>();
		m_Audio = gameObject.AddComponent<AudioSource>(); // add a new audio source for this class to use
		
	}
 /// <summary>
 /// Sends an OnUse message to this object. Add a Dialogue System Conversation Trigger to
 /// the object that will listen for OnUse and start a conversation.
 /// </summary>
 public override bool TryInteract(vp_FPPlayerEventHandler player)
 {
     if (!enabled)
     {
         return(false);
     }
     gameObject.SendMessage("OnUse", player.transform, SendMessageOptions.DontRequireReceiver);
     return(true);
 }
Exemple #34
0
 //On awake sets the values of the variables to point to the right objects.
 protected virtual void Awake()
 {
     Player    = GameObject.FindObjectOfType(typeof(vp_FPPlayerEventHandler)) as vp_FPPlayerEventHandler;
     cross     = GameObject.FindObjectOfType(typeof(vp_SimpleCrosshair)) as vp_SimpleCrosshair;
     Gun       = GameObject.FindObjectOfType(typeof(vp_FPWeapon)) as vp_FPWeapon;
     camera    = GameObject.FindObjectOfType(typeof(vp_FPCamera)) as vp_FPCamera;
     myCam     = camera.GetComponent <Camera>();
     BaseFOV   = camera.RenderingFieldOfView; //Replaces the value of BaseFOV to whatever the actual Base FOV is.
     BaseShake = camera.ShakeSpeed;           //Does the same to the base shake value.
 }
Exemple #35
0
    /// <summary>
    /// tries to add 'InventoryName' to the inventory and returns
    /// the result. this method should typically be overridden
    /// by the implementing pickup class.
    /// </summary>
    protected virtual bool TryGive(vp_FPPlayerEventHandler player)
    {
        // try adding item to the inventory
        if (!player.AddItem.Try(new object[] { InventoryName, 1 }))
        {
            return(false);
        }

        return(true);
    }
Exemple #36
0
 //On awake sets the values of the variables to point to the right objects.
 protected virtual void Awake()
 {
     Player = GameObject.FindObjectOfType(typeof(vp_FPPlayerEventHandler)) as vp_FPPlayerEventHandler;
     cross = GameObject.FindObjectOfType(typeof(vp_SimpleCrosshair)) as vp_SimpleCrosshair;
     Gun = GameObject.FindObjectOfType(typeof(vp_FPWeapon)) as vp_FPWeapon;
     camera = GameObject.FindObjectOfType(typeof(vp_FPCamera)) as vp_FPCamera;
     myCam=camera.GetComponent<Camera>();
     BaseFOV=camera.RenderingFieldOfView;//Replaces the value of BaseFOV to whatever the actual Base FOV is.
     BaseShake=camera.ShakeSpeed;//Does the same to the base shake value.
 }
Exemple #37
0
    /// <summary>
    ///
    /// </summary>
    void Awake()
    {
        // store the first player event handler found in the top of our transform hierarchy
        m_Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));

        // sort the weapon types alphabetically
        IComparer comparer = new InventoryWeaponStatusComparer();

        m_WeaponTypes.Sort(comparer.Compare);
    }
Exemple #38
0
    /// <summary>
    ///
    /// </summary>
    protected virtual void Awake()
    {
        m_Audio = GetComponent <AudioSource>();

        // store the first player event handler found in the top of our transform hierarchy
        m_Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));

        // TEMP: store reference to a possible 'vp_SimpleInventory' in case
        // game uses the old inventory system
        m_SimpleInventory = (vp_SimpleInventory)transform.root.GetComponent(typeof(vp_SimpleInventory));
    }
    /// <summary>
    /// tries to add 'Health' to the player (range is 0-1)
    /// </summary>
    protected override bool TryGive(vp_FPPlayerEventHandler player)
    {
        if (player.Health.Get() < 0.0f)
            return false;

        if (player.Health.Get() >= 1.0f)
            return false;

        player.Health.Set(Mathf.Min(1, (player.Health.Get() + Health)));

        return true;
    }
Exemple #40
0
 /// <summary>
 /// if needed, caches the local player event handler in the current scene (as opposed
 /// to a potentially null player from the previous scene) along with all of its most
 /// common UFPS components. NOTE: 'vp_LocalPlayer' assumes that the supported components
 /// are not added or removed from the player at runtime: each player event handler and
 /// additionals components are cached only on startup and level load. NOTE: this method
 /// is called by vp_FPPlayerEventHandler on Awake, and OnLevelLoad, which should hopefully
 /// spare you from ever having to call it
 /// </summary>
 public static void Refresh()
 {
     // only refresh player if null, or if player is set but a new level has been loaded
     if (!((m_FPEventHandler == null) || (m_LevelOfLocalPlayer != vp_Gameplay.CurrentLevel)))
     {
         return;             // if we return here, player seems up-to-date
     }
     // we should most rarely end up here
     m_FPEventHandler     = GameObject.FindObjectOfType(typeof(vp_FPPlayerEventHandler)) as vp_FPPlayerEventHandler;
     m_LevelOfLocalPlayer = ((m_FPEventHandler != null) ? vp_Gameplay.CurrentLevel : -99999);
     RefreshPlayerComponents();
 }
Exemple #41
0
    /// <summary>
    /// try to interact with this object
    /// </summary>
    public override bool TryInteract(vp_FPPlayerEventHandler player)
    {
        if(Target == null)
            return false;

        if(m_Player == null)
            m_Player = player;

        PlaySound();

        Target.SendMessage(TargetMessage, SendMessageOptions.DontRequireReceiver);

        return true;
    }
	/// <summary>
	/// 
	/// </summary>
	protected virtual void Awake()
	{

		m_Audio = audio;

		// store the first player event handler found in the top of our transform hierarchy
		m_Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));

		// TEMP: store reference to a possible 'vp_SimpleInventory' in case
		// game uses the old inventory system
		m_SimpleInventory = (vp_SimpleInventory)transform.root.GetComponent(typeof(vp_SimpleInventory));


	}
    /// <summary>
    ///
    /// </summary>
    protected override void Awake()
    {
        m_PlayerEventHandler = transform.root.GetComponentInChildren<vp_FPPlayerEventHandler>();

        if(AmmoLabel != null)	m_AmmoLabel = AmmoLabel.GetComponentInChildren<TextMesh>();
        if(HealthLabel != null)	m_HealthLabel = HealthLabel.GetComponentInChildren<TextMesh>();
        if(HintsLabel != null)	m_HintsLabel = HintsLabel.GetComponentInChildren<TextMesh>();

        if(m_HintsLabel != null)
        {
            m_HintsLabel.text = "";
            m_HintsLabel.GetComponent<Renderer>().material.color = Color.clear;
        }
    }
	// BLUR: uncomment to enable on Unity Pro
	//protected MotionBlur m_PainBlur = null;


	/// <summary>
	///
	/// </summary>
	void Awake()
	{

		m_Player = transform.GetComponent<vp_FPPlayerEventHandler>();

		// BLUR: uncomment to enable on Unity Pro
		//m_PainBlur = (MotionBlur)Camera.main.GetComponentInChildren(typeof(MotionBlur));
		//if (m_PainBlur != null)
		//{
		//	m_PainBlur.enabled = false;
		//	m_PainBlur.extraBlur = true;
		//	m_PainBlur.blurAmount = 0.0f;
		//}

	}
    /// </summary>
    ///
    /// </summary>
    public vp_FPSDemoManager(GameObject player)
    {
        Player = player;

        Controller = Player.GetComponent<vp_FPController>();
        Camera = Player.GetComponentInChildren<vp_FPCamera>();
        WeaponHandler = Player.GetComponentInChildren<vp_FPWeaponHandler>();
        PlayerEventHandler = (vp_FPPlayerEventHandler)Player.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));
        Input = Player.GetComponent<vp_FPInput>();
        Earthquake = (vp_Earthquake)Component.FindObjectOfType(typeof(vp_Earthquake));

        // on small screen resolutions the editor preview screenshot
        // panel is minimized by default, otherwise expanded
        if (Screen.width < 1024)
            EditorPreviewSectionExpanded = false;
    }
	/// <summary>
	/// tries to enable the 'MegaSpeed' state on the player
	/// </summary>
	protected override bool TryGive(vp_FPPlayerEventHandler player)
	{

		// prevent the player from picking up the item again until any
		// currently running speed timer has run its course
		if (m_Timer.Active)
			return false;

		// --- proper way of doing it ---

		// for something like this we use the State Manager and vp_Timer!
		// in the pickup demo folder you will find a controller preset
		// named 'ControllerMegaSpeed.txt' which boosts player acceleration
		// and increases its push force on rigidbodies.
		// in the pickup demo scene this has been added as a state named
		// 'MegaSpeed' to the controller component

		player.SetState("MegaSpeed");

		// restore speed after 'Value' seconds
		vp_Timer.In(RespawnDuration, delegate()
		{
			player.SetState("MegaSpeed", false);
		}, m_Timer);

		// NOTE: binding the 'm_Timer' handle above makes sure this timer
		// is canceled and restarted if it's already running. if you allow
		// players to pick up multiple powerups, this will prevent a depleted
		// pickup from disabling the state if the player has enabled a new one
		// while the previous one is active (i.e. the timer will be restarted)

		// --- buggy way of doing it ---

		// the below would also be a way of adding speed, but it would get messed up
		// if player pressed or released the 'Run' modifier key. speed would multiply
		// in case of several pickups and we would have to store the original controller
		// acceleration value in a 'Start' method. messy and error-prone. use states.

		//Player.Controller.MotorAcceleration *= 4.0f;
		//vp_Timer.In(Value, delegate()
		//{
		//    Player.Controller.MotorAcceleration *= 0.25f;	// ... or a stored original speed
		//});

		return true;

	}
	/// <summary>
	/// determines if this pickup is allowed to start slow motion.
	/// NOTE: actual slomo implementation occurs in Update
	/// </summary>
	protected override bool TryGive(vp_FPPlayerEventHandler player)
	{

		m_Player = player;

		// prevent the player from picking up the item again until any
		// currently running slomo timer has run its course
		if (m_Depleted || Time.timeScale != 1.0f)
			return false;

		// nothing more happens here the actual slomo logic is done in
		// Update, since it needs to call 'vp_TimeUtility.FadeTimeScale'
		// every frame

		return true;

	}
Exemple #48
0
    /// <summary>
    /// tries to reload if the current player weapon is out of ammo
    /// </summary>
    bool TryReloadIfEmpty(vp_FPPlayerEventHandler player)
    {
        // don't auto-reload if the wielded weapon has ammo
        if (player.CurrentWeaponAmmoCount.Get() > 0)
            return false;

        // only auto-reload with compatible ammo pickups
        if (player.CurrentWeaponClipType.Get() != InventoryName)
            return false;

        // try reloading
        if (!player.Reload.TryStart())
            return false;

        // success!
        return true;
    }
	/// <summary>
	/// tries to add weapon 'InventoryName' to the inventory
	/// </summary>
	protected override bool TryGive(vp_FPPlayerEventHandler player)
	{

		if (player.Dead.Active)
			return false;

		if (!base.TryGive(player))
			return false;

		// try wielding the new weapon (if it fails that's ok)
		player.SetWeaponByName.Try(InventoryName);

		// try setting ammo on the new weapon to 'AmmoIncluded'
		if (AmmoIncluded > 0)
			player.AddAmmo.Try(new object[] { InventoryName, AmmoIncluded });

		return true;

	}
	/// <summary>
	/// 
	/// </summary>
	public override bool TryInteract(vp_FPPlayerEventHandler player){
		
		if(!enabled)
			return false;
		
		if(Time.time < m_CanClimbAgain)
			return false;
		
		if(m_IsClimbing)
		{
			m_Player.Climb.TryStop();
			return false;
		}
		
		if(m_Player == null)
			m_Player = player;
		
		if(m_Player.Interactable.Get() != null)
			return false;
		
		if(m_Controller == null)
			m_Controller = m_Player.GetComponent<vp_FPController>();

		if (m_Player.Velocity.Get().magnitude > MinVelocityToClimb)
			return false;
		
		if(m_Camera == null)
			m_Camera = m_Player.GetComponentInChildren<vp_FPCamera>();
		
		float angle = Vector3.Angle(-m_Transform.forward, m_Transform.position - m_Camera.Transform.position);
		if (Mathf.Abs(angle) > 75 && m_Controller.Transform.position.y < GetTopOfCollider(m_Transform))
    		return false;
		
		if(Sounds.AudioSource == null)
			Sounds.AudioSource = m_Player.audio;
		
		m_Player.Register(this);
		
		m_Player.Interactable.Set(this); // sets what the player is currently interacting with
		
		return m_Player.Climb.TryStart();
		
	}
	/// <summary>
	/// 
	/// </summary>
	protected virtual void Awake()
	{

		m_Player = GameObject.FindObjectOfType(typeof(vp_FPPlayerEventHandler)) as vp_FPPlayerEventHandler;
		if(m_Player != null)
			m_PlayerAudioSource = m_Player.GetComponent<AudioSource>();

		m_DeviceAudioSource = GetComponent<AudioSource>();

		if (Button != null)
		{
			m_OriginalButtonPos = Button.transform.localPosition;
			m_OriginalButtonColor = ButtonRenderer.material.color;
			m_PulsingLight = Button.GetComponentInChildren<vp_PulsingLight>();
		}

		if (m_PulsingLight != null)
			m_OriginalPulsingLightMaxIntensity = m_PulsingLight.m_MaxIntensity;

	}
    /// <summary>
    /// try to interact with this object
    /// </summary>
    public override bool TryInteract(vp_FPPlayerEventHandler player)
    {
        if(Platform == null)
            return false;

        if(m_Player == null)
            m_Player = player;

        if(Time.time < m_Timeout)
            return false;

        PlaySound();

        Platform.SendMessage("GoTo", Platform.TargetedWaypoint == 0 ? 1 : 0, SendMessageOptions.DontRequireReceiver);

        m_Timeout = Time.time + SwitchTimeout;

        m_IsSwitched = !m_IsSwitched;

        return true;
    }
Exemple #53
0
	/// <summary>
	/// 
	/// </summary>
	public override bool TryInteract(vp_FPPlayerEventHandler player){
		
		if(!enabled)
			return false;
		
		if(Time.time < m_CanClimbAgain)
			return false;
		
		if(m_IsClimbing)
		{
			m_Player.Climb.TryStop();
			return false;
		}
		
		if(m_Player == null)
			m_Player = player;
		
		if(m_Player.Interactable.Get() != null)
			return false;
		
		if(m_Controller == null)
			m_Controller = m_Player.GetComponent<vp_FPController>();

		if (m_Player.Velocity.Get().magnitude > MinVelocityToClimb)
			return false;
		
		if(m_Camera == null)
			m_Camera = m_Player.GetComponentInChildren<vp_FPCamera>();
		
		if(Sounds.AudioSource == null)
			Sounds.AudioSource = m_Player.audio;
		
		m_Player.Register(this);
		
		m_Player.Interactable.Set(this); // sets what the player is currently interacting with
		
		return m_Player.Climb.TryStart();
		
	}
Exemple #54
0
    /// <summary>
    /// try to interact with this object
    /// </summary>
    public override bool TryInteract(vp_FPPlayerEventHandler player)
    {
        if(m_Player == null)
            m_Player = player;

        //Target.SendMessage(TargetMessage, SendMessageOptions.DontRequireReceiver);

        if (!is_Client)
        {
            int toAdd = 10 - m_Player.GetItemCount.Send("AmmoClip");

            m_Player.AddItem.Try(new object[] { "AmmoClip", toAdd });

            m_Player.Health.Set(100f);

            m_Player.transform.GetComponent<NetworkEvents>().SupplySpotStart();

        }
        else
            Debug.Log ("CLIENT INTERACTED");

        return true;
    }
Exemple #55
0
    protected virtual void Awake()
    {
        Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));
        walkTimeLimit=Random.Range(2,4);
        stopTimeLimit=Random.Range (9,12);
        walkTime=Time.time;

        seeker = GetComponent<Seeker>();

        //This is a simple optimization, cache the transform component lookup
        tr = transform;

        //Make sure we receive callbacks when paths complete
        seeker.pathCallback += OnPathComplete;

        //Cache some other components (not all are necessarily there)
        controller = GetComponent<CharacterController>();
        navController = GetComponent<NavmeshController>();
        rigid = rigidbody;
    }
Exemple #56
0
	/// <summary>
	/// Checks to see if we have a player capable of interacting
	/// with this object, and if so starts or stops grabbing.
	/// </summary>
	public override bool TryInteract(vp_FPPlayerEventHandler player)
	{

		if (m_Player == null)
			m_Player = player;

		if (player == null)
			return false;

		if (m_Controller == null)
			m_Controller = m_Player.GetComponent<vp_FPController>();

		if (m_Controller == null)
			return false;

		if (m_Camera == null)
			m_Camera = m_Player.GetComponentInChildren<vp_FPCamera>();

		if (m_Camera == null)
			return false;

		if (m_WeaponHandler == null)
			m_WeaponHandler = m_Player.GetComponentInChildren<vp_FPWeaponHandler>();

		if (m_Audio == null)
			m_Audio = m_Player.audio;

		m_Player.Register(this);

		if (!m_IsGrabbed)
			StartGrab(); // start the grab
		else
			StopGrab(); // if object grabbed, stop the grab

		// set this object as the one the player is currently
		// interacting with
		m_Player.Interactable.Set(this);

		// if we have a grab state crosshair, set it
		if (GrabStateCrosshair != null)
			m_Player.Crosshair.Set(GrabStateCrosshair);
		else
			m_Player.Crosshair.Set(new Texture2D(0, 0));

		return true;

	}
	/// <summary>
	/// 
	/// </summary>
	protected virtual void Awake()
	{

		Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));

		m_FPCamera = GetComponentInChildren<vp_FPCamera>();

	}
Exemple #58
0
    /// <summary>
    ///
    /// </summary>
    void Awake()
    {
        m_Player = transform.GetComponent<vp_FPPlayerEventHandler>();

        // TEAM SCORES INITIALIZATION
        VampireTeamScore = 0;
        SlayerTeamScore = 0;

        // TIMER INITIALIZATION
        remainingMinutes = 0;
        remainingSeconds = 0;
    }
    /// <summary>
    /// 
    /// </summary>
    protected override void Awake()
    {
        base.Awake();

        m_Player = transform.GetComponent<vp_FPPlayerEventHandler>();
    }
Exemple #60
0
	/// <summary>
	///
	/// </summary>
	protected virtual void Awake()
	{

		m_Player = transform.GetComponent<vp_FPPlayerEventHandler>();
		m_Audio = m_Player.transform.audio;

	}