Ejemplo n.º 1
0
    private void LaunchFishingRod()
    {
        if (hook == null && characterController.isGrounded && Physics2D.OverlapCircle(hookPosition.transform.position, 0.25f, whatIsGround) == null)
        {
            playerController.SetPlayerState(PlayerController2.PlayerState.DontMove);

            GameObject newHook = Instantiate(hookPrefab, hookPosition.transform.position, new Quaternion());
            hook = newHook.GetComponent <HookBehavior>();

            hook.LaunchHook(this, cableLength, cableSpeed);
        }
    }
Ejemplo n.º 2
0
 public void HookCheck(Vector2 target, HookBehavior hoke)
 {
     hookHit = Physics2D.Raycast(transform.position, new Vector2(target.x - transform.position.x, target.y - transform.position.y), hookDistance, mask);
     if (hookHit)
     {
         joint.enabled         = true;
         joint.connectedAnchor = hookHit.point;
         joint.distance        = hookHit.distance;
         ropeTargets.Add(hookHit.point);
         rope.enabled = true;
         currentHook  = hoke;
         SetCurrentState(ControlState.HOOKSHOT);
     }
 }
Ejemplo n.º 3
0
    public void CancelFishingRod(GameObject hookedItem = null)
    {
        playerController.SetPlayerState(PlayerController2.PlayerState.Default);

        if (hookedItem != null)
        {
            hookedItem.transform.SetParent(null, true);

            PlayerController2 hookedPlayer = hookedItem.GetComponent <PlayerController2>();
            if (hookedPlayer != null)
            {
                hookedPlayer.SetPlayerState(PlayerController2.PlayerState.Default);
            }
        }

        if (hook != null)
        {
            Destroy(hook.gameObject);
            hook = null;
        }
    }
Ejemplo n.º 4
0
    void SpawnHook(Vector2 target)
    {
        HookBehavior hoke = Instantiate(hook);

        hoke.SetBehavior(transform.position, target, target - new Vector2(transform.position.x, transform.position.y), 15f);
    }