Exemple #1
0
    /// <summary>
    /// this is used to prevent remote players from spawning with a
    /// falling animation. when they spawn at their temp (free fall)
    /// position, animators will get immediately paused and forcibly
    /// 'grounded' and unpaused as soon as they spawn properly
    /// </summary>
    public virtual void SetAnimated(bool value)
    {
        m_IsAnimated = value;

        vp_RagdollHandler v = transform.root.GetComponentInChildren <vp_RagdollHandler>();

        if (v != null)
        {
            v.enabled = value;
        }

        vp_BodyAnimator b = transform.root.GetComponentInChildren <vp_BodyAnimator>();

        if (b != null)
        {
            b.enabled = value;
        }

        Animator a = transform.root.GetComponentInChildren <Animator>();

        if (a != null)
        {
            a.SetBool("IsGrounded", true);
            a.enabled = value;
        }
    }
Exemple #2
0
    /// <summary>
    /// demo screen to list some included example scripts
    /// </summary>
    private void DemoIntro()
    {
        if (m_Demo.FirstFrame)
        {
            m_Demo.FirstFrame    = false;
            m_Demo.DrawCrosshair = false;
            m_Demo.FreezePlayer(m_OverviewPos, m_OverviewAngle, true);
            m_Demo.Input.MouseCursorForced = true;

            m_BodyAnimator = (vp_BodyAnimator)Component.FindObjectOfType(typeof(vp_BodyAnimator));
            if (m_BodyAnimator != null)
            {
                m_BodyAnimator.gameObject.SetActive(false);
            }
        }

        m_Demo.DrawBoxes("welcome", "Featuring the SMOOTHEST CONTROLS and the most POWERFUL FPS CAMERA\navailable for Unity, Ultimate FPS is an awesome script pack for achieving that special\n 'AAA FPS' feeling. This demo will walk you through some of its core features ...\n", null, ImageRightArrow, null, null);
        m_Demo.ForceCameraShake();
    }
	/// <summary>
	/// demo screen to list some included example scripts
	/// </summary>
	private void DemoIntro()
	{

		if (m_Demo.FirstFrame)
		{
			m_Demo.FirstFrame = false;
			m_Demo.DrawCrosshair = false;
			m_Demo.FreezePlayer(m_OverviewPos, m_OverviewAngle, true);
			m_Demo.Input.MouseCursorForced = true;

			m_BodyAnimator = (vp_BodyAnimator)Component.FindObjectOfType(typeof(vp_BodyAnimator));
			if (m_BodyAnimator != null)
				m_BodyAnimator.gameObject.SetActive(false);

		}

		m_Demo.DrawBoxes("welcome", "Featuring the SMOOTHEST CONTROLS and the most POWERFUL FPS CAMERA\navailable for Unity, Ultimate FPS is an awesome script pack for achieving that special\n 'AAA FPS' feeling. This demo will walk you through some of its core features ...\n", null, ImageRightArrow, null, null);
		m_Demo.ForceCameraShake();

	}
    /// <summary>
    /// creates a copy of the currently selected UFPS player gameobject
    /// - stripped of all its 1st person functionality. the new object
    /// can be used for AI or multiplayer remote players
    /// </summary>
    public static void Generate()
    {
        GameObject target = Selection.activeObject as GameObject;

        if ((target == null) || (!vp_Utility.IsActive(target)) || (target.GetComponentInChildren <vp_FPController>() == null) && (target.GetComponentInChildren <vp_FPCamera>() == null))
        {
            EditorUtility.DisplayDialog("Failed to run wizard", "Please select the main gameobject of a 1st person player in the Hierarchy view (make sure it's active) and try again.", "OK");
            return;
        }

        if (!EditorUtility.DisplayDialog("Generate Remote Player?", "This wizard will create a copy of the selected player object - stripped of all its 1st person functionality. This new object can be used for AI or multiplayer remote players.\n\nNOTE: Only default UFPS classes will be processed.", "OK", "Cancel"))
        {
            return;
        }

        DecideCopyStates(target);

        string name = target.name + "(Remote)";

        // generate - and operate upon - a copy of the target
        target      = (GameObject)GameObject.Instantiate(target);
        target.name = target.name.Replace("(Clone)", "");

        try
        {
            // layer likely should no longer be 'LocalPlayer', so default to 'RemotePlayer'
            target.gameObject.layer = vp_Layer.RemotePlayer;

            // convert weapons
            ConvertWeaponsTo3rdPerson(target);

            // find any charactercontroller and convert it into a capsulecollider with a rigidbody
            CharacterController ch = target.GetComponentInChildren <CharacterController>();
            if (ch != null)
            {
                if (ch.transform.GetComponent <Rigidbody>() == null)
                {
                    CapsuleCollider ca = ch.gameObject.AddComponent <CapsuleCollider>();
                    ca.radius = ch.radius;
                    ca.height = ch.height;
                    ca.center = ca.center;
                    Rigidbody r = ch.gameObject.AddComponent <Rigidbody>();
                    r.useGravity             = false;
                    r.isKinematic            = true;
                    r.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
                }
            }

            // convert 1st person controller
            vp_FPController fpController = target.GetComponent <vp_FPController>();
            if (fpController != null)
            {
                vp_CapsuleController cController = target.AddComponent <vp_CapsuleController>();
                vp_EditorUtility.CopyValuesFromDerivedComponent(fpController, cController, true, false, null);                  // TEST: fpcontroller is not derived from capsulecontroller! see note in 'GenerateStatesAndPresetsFromDerivedComponent'
                if (m_CopyStates && !string.IsNullOrEmpty(m_StatePath))
                {
                    vp_EditorUtility.GenerateStatesAndPresetsFromDerivedComponent(fpController, cController, m_StatePath);
                }
            }

            // convert weapon handler
            vp_FPWeaponHandler fpWHandler = target.GetComponent <vp_FPWeaponHandler>();
            if (fpWHandler != null)
            {
                vp_WeaponHandler wHandler = target.AddComponent <vp_WeaponHandler>();
                vp_EditorUtility.CopyValuesFromDerivedComponent(fpWHandler, wHandler, true, false, null);
            }

            // convert damage handler
            vp_FPPlayerDamageHandler fpDHandler = target.GetComponent <vp_FPPlayerDamageHandler>();
            if (fpDHandler != null)
            {
                vp_PlayerDamageHandler dHandler = target.AddComponent <vp_PlayerDamageHandler>();
                vp_EditorUtility.CopyValuesFromDerivedComponent(fpDHandler, dHandler, true, true, null);
            }

            // convert event handler
            vp_FPPlayerEventHandler fpEHandler = target.GetComponent <vp_FPPlayerEventHandler>();
            if (fpEHandler != null)
            {
                vp_PlayerEventHandler eHandler = target.AddComponent <vp_PlayerEventHandler>();
                vp_EditorUtility.CopyValuesFromDerivedComponent(fpEHandler, eHandler, true, false, null);
            }

            // convert body animator
            vp_FPBodyAnimator fpBAnimator = target.GetComponentInChildren <vp_FPBodyAnimator>();
            if (fpBAnimator != null)
            {
                vp_BodyAnimator bAnimator = fpBAnimator.gameObject.AddComponent <vp_BodyAnimator>();
                vp_EditorUtility.CopyValuesFromDerivedComponent(fpBAnimator, bAnimator, true, true, null);
            }

            // delete 'remoteplayer-illegal' components
            DeleteComponentsOfType(target.transform, typeof(vp_FPCamera));                      // these first due to dependencies
            DeleteComponentsOfType(target.transform, typeof(vp_FPController));                  // these first due to dependencies
            DeleteComponentsOfTypes(target.transform, new System.Type[]
            {
                typeof(Camera),
                typeof(AudioListener),
                typeof(vp_FPInput),
                typeof(vp_SimpleCrosshair),
                typeof(vp_FootstepManager),
                typeof(vp_FPInteractManager),
                typeof(vp_SimpleHUD),
                typeof(vp_PainHUD),
                typeof(vp_FPEarthquake),
                typeof(CharacterController),
                typeof(vp_FPWeaponHandler),
                typeof(vp_FPPlayerDamageHandler),
                typeof(vp_FPPlayerEventHandler),
                typeof(vp_FPBodyAnimator)
            });

            Transform weaponCamera = vp_Utility.GetTransformByNameInChildren(target.transform, "WeaponCamera", true);
            if (weaponCamera != null)
            {
                GameObject.DestroyImmediate(weaponCamera.gameObject);
            }

            target.name = name;
        }
        catch (System.Exception e)
        {
            Debug.Log(e);
            target.name = target.name + " (CONVERSION FAILED - see error log)";
        }
    }