2024-02-03 14:07:03 +01:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.InputSystem;
|
2024-02-03 15:21:45 +01:00
|
|
|
using System.Linq;
|
2024-02-03 14:07:03 +01:00
|
|
|
|
|
|
|
public class RopeWhipAttack : MonoBehaviour
|
|
|
|
{
|
|
|
|
public RopeWhipAttack otherPlayerAttack;
|
|
|
|
public PlayerMovement playerMovement;
|
|
|
|
public RopeJoint joint;
|
|
|
|
|
2024-02-03 15:21:45 +01:00
|
|
|
Gamepad controller;
|
2024-02-03 14:07:03 +01:00
|
|
|
public bool IsWhippingOtherPlayer => joint.locked;
|
|
|
|
public bool IsBeingWhipped => otherPlayerAttack.joint.locked;
|
|
|
|
|
|
|
|
public float initialDrag;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
initialDrag = joint.body.drag;
|
2024-02-03 15:21:45 +01:00
|
|
|
controller = Gamepad.all.ElementAtOrDefault(playerMovement.player);
|
2024-02-03 14:07:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
// Other player is whip attacking
|
|
|
|
if (otherPlayerAttack.joint.locked) return;
|
2024-02-03 15:21:45 +01:00
|
|
|
if (controller == null)
|
|
|
|
return;
|
|
|
|
if (controller.rightShoulder.IsPressed())
|
2024-02-03 14:07:03 +01:00
|
|
|
{
|
|
|
|
joint.locked = true;
|
|
|
|
otherPlayerAttack.joint.body.drag = 0f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
joint.locked = false;
|
|
|
|
otherPlayerAttack.joint.body.drag = otherPlayerAttack.initialDrag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|