Ejemplo n.º 1
0
    void TryCreatingHiddenAgent()
    {
        if (HiddenAgent == null || !HiddenAgent.IsLinkedWith(this))
        {
            var hiddenObject = new GameObject("(Hidden) " + name);
            hiddenObject.hideFlags = HideFlags.NotEditable;
            hiddenObject.transform.SetParent(transform.parent);

#if UNITY_EDITOR
            var staticFlags = GameObjectUtility.GetStaticEditorFlags(gameObject);
            GameObjectUtility.SetStaticEditorFlags(hiddenObject, staticFlags);
#else
            hiddenObject.isStatic = gameObject.isStatic;
#endif
            HiddenAgent = hiddenObject.AddComponent <HiddenNavMeshAgent>();

#if UNITY_EDITOR
            // set dirty; otherwise, if it's part of a prefab instance and scripts are
            // reloaded, the hiddenAgentGameObject reference will be lost
            EditorUtility.SetDirty(this);
#endif

            HiddenAgent.LinkWithCustomAgent(this);
        }
    }
Ejemplo n.º 2
0
    // Define the agent properties
    void createPlayers()
    {
        GameObject[] playerListGO = GameObject.FindGameObjectsWithTag("PlayerHide");
        m_nbHiddenPlayersAlive = PlayerSelection_Persistent.nbHidePlayers;
        _hiddenPlayersList     = new HiddenAgent[m_nbHiddenPlayersAlive];

        for (int i = 0; i < m_nbHiddenPlayersAlive; i++)
        {
            HiddenAgent hiddenAgent = playerListGO[i].GetComponent <HiddenAgent>();
            hiddenAgent.defineAgent(_playerMass, _playerSpeed, _playerSteer, Random.Range(0.0f, 360.0f));

            if (PlayerSelection_Persistent.keyboardControl)
            {
                hiddenAgent.m_controller = new KeyboardController();
            }
            else
            {
                hiddenAgent.m_controller = new GamepadController(PlayerSelection_Persistent.hiddenPlayerGamepadID[i]);
            }

            _hiddenPlayersList[i] = hiddenAgent;
        }

        for (int i = m_nbHiddenPlayersAlive; i < 3; i++)
        {
            playerListGO[i].gameObject.SetActive(false);
        }

        m_shooterPlayer.m_nbShoot = m_nbHiddenPlayersAlive * 3;
    }
Ejemplo n.º 3
0
    void TryCreatingHiddenAgent()
    {
        if (HiddenAgent == null || !HiddenAgent.IsLinkedWith(this))
        {
            var hiddenObject = new GameObject("(Hidden) " + name);
            hiddenObject.hideFlags = HideFlags.NotEditable;
            hiddenObject.transform.SetParent(transform.parent);

#if UNITY_EDITOR
            var staticFlags = GameObjectUtility.GetStaticEditorFlags(gameObject);
            GameObjectUtility.SetStaticEditorFlags(hiddenObject, staticFlags);
#else
            hiddenObject.isStatic = gameObject.isStatic;
#endif
            HiddenAgent = hiddenObject.AddComponent <HiddenNavMeshAgent>();
            HiddenAgent.LinkWithCustomAgent(this);
        }
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets or updates the destination thus triggering the calculation for a new path.
 /// </summary>
 /// <param name="target">The target point to navigate to.</param>
 /// <returns>True if the destination was requested successfully, otherwise false.</returns>
 public bool SetDestination(Vector3 target)
 {
     return(HiddenAgent.SetDestination(target + CustomNavMesh.HiddenTranslation));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Clears the current path. When the path is cleared, the agent will
 /// not start looking for a new path until SetDestination is called.
 /// </summary>
 public void ResetPath()
 {
     HiddenAgent.ResetPath();
 }