// Start is called before the first frame update
 void Start()
 {
     gun                   = GetComponentInChildren <gun_logic>();
     fpcam                 = GameObject.Find("Main Camera").GetComponent <cameralogic_reboot>();
     m_animator            = GetComponent <Animator>();
     m_charactercontroller = GetComponent <CharacterController>();
 }
Exemplo n.º 2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         gun_logic gun = other.GetComponentInChildren <gun_logic>();
         if (gun)
         {
             gun.refill_ammo();
             Destroy(gameObject);
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        m_horizontalaxis = Input.GetAxis("Horizontal");
        m_verticalaxis   = Input.GetAxis("Vertical");
        total_move       = new Vector3(-m_verticalaxis, 0, m_horizontalaxis);

        if (Input.GetButtonDown("Jump") && !isjumping)
        {
            isjumping = true;
        }
        if (m_interactableobject && Input.GetButtonDown("Fire2"))
        {
            if (!m_equppedobject)
            {
                gun_logic gun = m_interactableobject.GetComponent <gun_logic>();
                if (gun)
                {
                    //sets the position of the gun
                    m_interactableobject.transform.rotation = equipposition.rotation;
                    m_interactableobject.transform.position = equipposition.position;
                    m_interactableobject.transform.parent   = gameObject.transform;
                    m_equppedobject = m_interactableobject;

                    //deactivate gravity and deactivate collider
                    gun.equip_weapon();
                }
            }
            else if (m_equppedobject == m_interactableobject)
            {
                gun_logic gun = m_interactableobject.GetComponent <gun_logic>();
                if (gun)
                {
                    //sets the position of the gun
                    m_interactableobject.transform.parent = null;
                    m_equppedobject = null;
                    //activate gravity and activate collider
                    gun.unequip_weapon();
                }
            }
            else if (m_equppedobject != m_interactableobject)
            {
                gun_logic gun = m_equppedobject.GetComponent <gun_logic>();
                if (gun)
                {
                    //sets the position of the gun
                    m_equppedobject.transform.parent = null;
                    m_equppedobject = null;
                    //activate gravity and activate collider
                    gun.unequip_weapon();
                }
                gun_logic gunn = m_interactableobject.GetComponent <gun_logic>();
                if (gunn)
                {
                    //sets the position of the gun
                    m_interactableobject.transform.rotation = equipposition.rotation;
                    m_interactableobject.transform.position = equipposition.position;
                    m_interactableobject.transform.parent   = gameObject.transform;
                    m_equppedobject = m_interactableobject;
                    gunn.refill_ammo();
                    //deactivate gravity and deactivate collider
                    gunn.equip_weapon();
                }
            }
        }
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        gun_logic gun_logic = animator.GetComponentInChildren <gun_logic>();

        gun_logic.reload_state(false);
    }