Beispiel #1
0
    void RetractHookshot()
    {
        hookshotObj.position -= transform.forward * retractingSpeed;

        Vector3 retractPoint  = new Vector3(transform.position.x, transform.position.y, transform.position.z + shootingLength);
        float   distance      = Vector3.Distance(altweapons.altWeaponPos, hookshotObj.position);
        float   resetDistance = Vector3.Distance(retractPoint, hookshotObj.position);

        if (distance <= 1)
        {
            altweapons.canUseAltWeapon       = true;
            altweapons.swordAndShieldShowing = true;
            altweapons.tpc.canMove           = true;
            altweapons.tpc.canLookAround     = true;
            currentState = HookshotState.Idle;
            Destroy(hookshotObj.gameObject);
        }
        else if (resetDistance >= 15f)
        {
            altweapons.canUseAltWeapon       = true;
            altweapons.swordAndShieldShowing = true;
            altweapons.tpc.canMove           = true;
            altweapons.tpc.canLookAround     = true;
            currentState = HookshotState.Idle;
            Destroy(hookshotObj.gameObject);
        }
    }
Beispiel #2
0
    void ShootHookshot()
    {
        hookshotObj.position += transform.forward * shootingSpeed;
        float distance = Vector3.Distance(altweapons.altWeaponPos, hookshotObj.position);

        if (distance > shootingLength)
        {
            currentState = HookshotState.Retract;
        }
    }
Beispiel #3
0
 void ChangeState(HookshotState newState)
 {
     state           = newState;
     stateSwitchTime = Time.time;
     if (CanMouseAim())
     {
         mouseAimer.ToggleAiming(true);
     }
     else
     {
         mouseAimer.ToggleAiming(false);
     }
 }
Beispiel #4
0
    void Update()
    {
        if (active)
        {
            switch (currentState)
            {
            case HookshotState.Idle:
                rb.useGravity  = true;
                rb.isKinematic = false;
                if (Input.GetButtonDown("AltWeapon") && altweapons.canUseAltWeapon)
                {
                    GameObject altWeaponInUse = Instantiate(altweapons.altWeapons[1], altweapons.altWeaponPos, Quaternion.identity) as GameObject;
                    hookshotObj = altWeaponInUse.transform;
                    altweapons.canUseAltWeapon       = false;
                    altweapons.swordAndShieldShowing = false;
                    altweapons.tpc.canMove           = false;
                    altweapons.tpc.canLookAround     = false;
                    currentState = HookshotState.Shoot;
                }
                break;

            case HookshotState.Shoot:
                rb.useGravity  = false;
                rb.isKinematic = true;
                ShootHookshot();
                break;

            case HookshotState.Retract:
                rb.useGravity  = false;
                rb.isKinematic = true;
                RetractHookshot();
                break;

            case HookshotState.HookedOnTarget:
                rb.useGravity  = false;
                rb.isKinematic = true;
                HookedOnTarget();
                break;

            default:
                break;
            }
        }
    }
    IEnumerator HookshotStartCO()
    {
        // Récupère la cible du grappin désigné dans le script HookPosDetection
        m_HookshotTarget = m_HookPosDetection.m_HookTarget;

        ResetProjectionPoint();

        m_HookshotState = HookshotState.HookshotLaunch;
        m_HookshotOrigin.gameObject.SetActive(true);
        m_CanInteract = false;
        HookshotStartFeedback();

        yield return(new WaitForSeconds(m_HookshotLag));

        m_CanInteract      = true;
        m_HookshotPosition = m_HookshotTarget.position;

        // Change d'état (permet d'amorcer la propulsion du grappin)
        m_HookshotState = HookshotState.HookshotFlyingPlayer;
    }
Beispiel #6
0
    void Hookshot()
    {
        lineRenderer.SetPosition(0, transform.position);
        currentToungeCooldown -= Time.deltaTime;

        switch (currentHookshotState) {
            case HookshotState.Available:
                lineRenderer.SetPosition(1, (new Vector3(0, .01f) + joystickRight).normalized + transform.position);

                if (Input.GetAxis(rightTrigger) < 0) {
                    savedJoystickRight = (new Vector3(0, .01f) + joystickRight).normalized;
                    savedPlayerPos = transform.position;
                    toungeLength = 1;
                    audioSource.PlayOneShot(soundShoot);
                    currentHookshotState = HookshotState.Shooting;
                }
                break;

            case HookshotState.Unavailable:
                lineRenderer.SetPosition(1, transform.position);
                if (currentToungeCooldown <= 0) {
                    currentHookshotState = HookshotState.Available;
                }
                break;

            case HookshotState.Shooting:
                currentToungeCooldown = toungeCooldown;
                toungeLength = toungeLength + Time.deltaTime * toungeSpeed;
                Vector3 lineEnd = savedJoystickRight * toungeLength + savedPlayerPos;
                lineRenderer.SetPosition(1, lineEnd);
                toungeRaycast = Physics2D.CircleCast(transform.position, .2f, savedJoystickRight, toungeLength, toungeLayer);
                if (toungeRaycast.collider != null) { //Träffar ngt

                    audioSource.PlayOneShot(soundHit, 5f);

                    if ((toungeRaycast.collider.tag == "Player" || toungeRaycast.collider.tag == "TpBox") && toungeRaycast.collider.name != this.name) {
                        currentHookshotState = HookshotState.Switch;
                    }
                    else {
                        savedJoystickRight = transform.position;
                        currentHookshotState = HookshotState.Dragging;
                    }

                }
                else if ((transform.position - lineEnd).magnitude > maxRange) { //Max range
                    currentHookshotState = HookshotState.Unavailable;
                }
                break;

            case HookshotState.Dragging:
                transform.position = Vector3.Lerp(transform.position, toungeRaycast.point, Time.deltaTime * dragSpeed);
                if (Vector2.Distance(new Vector2(transform.position.x, transform.position.y), toungeRaycast.point) < .5f) {
                    rb.velocity = Vector3.zero;
                    currentHookshotState = HookshotState.Unavailable;
                }
                break;

            case HookshotState.Switch:
                Vector3 myPosition = transform.position;
                transform.position = toungeRaycast.collider.transform.position;
                toungeRaycast.collider.transform.position = myPosition;
                rb.velocity = new Vector2(rb.velocity.x, wallRunSpeed);
                toungeRaycast.collider.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
                if (toungeRaycast.collider.tag == "Player") {
                    gc.SetSlowMotion();
                }

                currentHookshotState = HookshotState.Unavailable;
                break;

            case HookshotState.Hurt:
                lineRenderer.SetPosition(1, transform.position);
                hurtTime -= Time.deltaTime;

                rb.velocity = Vector3.zero;

                if (hurtTime <= 0) {
                    currentHookshotState = HookshotState.Unavailable;
                }

                break;

            default:
                break;
        }
    }
Beispiel #7
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Hurt") {
         Destroy(other.gameObject, .5f);
         hurtTime = .5f;
         currentHookshotState = HookshotState.Hurt;
     }
 }
Beispiel #8
0
 void ChangeState(HookshotState newState)
 {
     state = newState;
     stateSwitchTime = Time.time;
     if (CanMouseAim()) {
         mouseAimer.ToggleAiming(true);
     } else {
         mouseAimer.ToggleAiming(false);
     }
 }
 private void StopHookshot()
 {
     m_HookshotState = HookshotState.Neutral;
     ResetGravityEffect();
     // m_HookShotOrigin.gameObject.SetActive(false);
 }
Beispiel #10
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Hurt") {
         hurtTime = .5f;
         currentHookshotState = HookshotState.Hurt;
     }
 }