private void UpdateTetherInput()
    {
        float rightBumperValue = Input.GetAxisRaw("RightBumper");
        float leftBumperValue  = Input.GetAxisRaw("LeftBumper");

        //bumper events
        if (rightBumperValue == 1f && tetherMode == tetherType.Invalid && !bumperInUse)
        {
            ChangeTetherMode(tetherType.PullPlayerToObject);
            shouldCreateTether = !shouldCreateTether;
            bumperInUse        = true;
        }

        if (leftBumperValue == 1f && tetherMode == tetherType.Invalid && !bumperInUse)
        {
            ChangeTetherMode(tetherType.PullObjectToPlayer);
            shouldCreateTether = !shouldCreateTether;
            bumperInUse        = true;
        }

        if (rightBumperValue == 0f && leftBumperValue == 0f && bumperInUse)
        {
            bumperInUse = false;
            tetherMode  = tetherType.Invalid;
        }
    }
 private void ChangeTetherMode(tetherType mode)
 {
     if (mode == tetherType.Invalid)
     {
         shouldCreateTether = false;
     }
     tetherMode = mode;
 }
Ejemplo n.º 3
0
 public void DestroyTether()
 {
     DestroyImmediate(m_tether);
     DestroyImmediate(m_tetherHook);
     m_tether         = null;
     m_startObject    = null;
     m_attachedObject = null;
     m_tetherMode     = tetherType.Invalid;
     ChangeState(stateType.Idle);
 }
Ejemplo n.º 4
0
 public void TryInitialize(GameObject startObj, Vector3 destination, tetherType tetherM)
 {
     if (m_tether != null || startObj == null)
     {
         return;
     }
     m_tether     = Instantiate(m_tetherBase);
     m_tetherHook = Instantiate(m_tetherEnd);
     m_tetherHook.GetComponent <HookBehaviour>().SetTetherInstance(this);
     m_tetherMode = tetherM;
     ChangeState(stateType.Launched);
     m_startObject          = startObj;
     m_tetherDestination    = destination;
     m_tetherAnimationStart = Time.time;
 }
Ejemplo n.º 5
0
    public bool Initialize(GameObject startObj, GameObject endObj, GameObject tetherBase, tetherType tetherM)
    {
        if (startObj == null || endObj == null)
        {
            return(false);
        }
        Vector3 startPos = startObj.transform.position;
        Vector3 endPos   = endObj.transform.position;
        float   length   = (endPos - startPos).magnitude / 2;

        if (length > m_maximumLength)
        {
            return(false);
        }

        m_startObject    = startObj;
        m_attachedObject = endObj;
        m_tether         = Instantiate(tetherBase);
        m_tetherMode     = tetherM;
        return(true);
    }