private void Start()
    {
        activeWeaponIndex   = -1;
        m_WeaponSwitchState = WeaponSwitchState.Down;

        m_InputHandler = GetComponent <PlayerInputHandler> ();
        DebugUtility.HandleErrorIfNullGetComponent <PlayerInputHandler, PlayerWeaponsManager> (m_InputHandler, this, gameObject);

        m_PlayerCharacterController = GetComponent <PlayerCharacterController> ();
        DebugUtility.HandleErrorIfNullGetComponent <PlayerCharacterController, PlayerWeaponsManager> (m_PlayerCharacterController, this, gameObject);

        m_PlayerWalkController = GetComponent <PlayerWalkController> ();
        DebugUtility.HandleErrorIfNullGetComponent <PlayerWalkController, PlayerWeaponsManager> (m_PlayerWalkController, this, gameObject);

        SetFOV(defaultFOV);

        onSwitchedToWeapon += OnWeaponSwitched;

        // Add starting weapons
        foreach (var weapon in startingWeapons)
        {
            AddWeapon(weapon);
        }
        SwitchWeapon(true);
    }
    void Start()
    {
        // fetch components on the same gameObject
        m_Controller = GetComponent <CharacterController> ();
        DebugUtility.HandleErrorIfNullGetComponent <CharacterController, PlayerCharacterController> (m_Controller, this, gameObject);

        m_ClimbController = GetComponent <PlayerClimbController> ();
        DebugUtility.HandleErrorIfNullGetComponent <PlayerClimbController, PlayerCharacterController> (m_ClimbController, this, gameObject);

        m_WalkController = GetComponent <PlayerWalkController> ();
        DebugUtility.HandleErrorIfNullGetComponent <PlayerWalkController, PlayerCharacterController> (m_WalkController, this, gameObject);

        m_InputHandler = GetComponent <PlayerInputHandler> ();
        DebugUtility.HandleErrorIfNullGetComponent <PlayerInputHandler, PlayerCharacterController> (m_InputHandler, this, gameObject);

        m_WeaponsManager = GetComponent <PlayerWeaponsManager> ();
        DebugUtility.HandleErrorIfNullGetComponent <PlayerWeaponsManager, PlayerCharacterController> (m_WeaponsManager, this, gameObject);

        m_Health = GetComponent <Health> ();
        DebugUtility.HandleErrorIfNullGetComponent <Health, PlayerCharacterController> (m_Health, this, gameObject);

        m_Actor = GetComponent <Actor> ();
        DebugUtility.HandleErrorIfNullGetComponent <Actor, PlayerCharacterController> (m_Actor, this, gameObject);

        mainCamera      = Camera.main;
        interactionText = GameObject.Find("InteractionCanvas/InteractionText").GetComponent <Text> ();

        m_Health.onDie += OnDie;

        // force the crouch state to false when starting
        SetCrouchingState(false, true);
    }
Esempio n. 3
0
 void Start()
 {
     m_Controller       = GetComponent <CharacterController> ();
     m_PlayerController = GetComponent <PlayerCharacterController> ();
     m_WalkController   = GetComponent <PlayerWalkController> ();
     useCounter         = GameObject.Find("TeleportCounter").GetComponent <TextMeshProUGUI> ();
     useCounter.SetText("»» " + teleportUses.ToString());
 }
Esempio n. 4
0
    private void Start()
    {
        character = FindObjectOfType <PlayerCharacterController> ();
        DebugUtility.HandleErrorIfNullFindObject <PlayerCharacterController, StanceHUD> (character, this);
        walkController = FindObjectOfType <PlayerWalkController> ();

        character.onStanceChanged += OnStanceChanged;
        OnStanceChanged();
    }