82 lines
2.1 KiB
C#
82 lines
2.1 KiB
C#
using UnityEngine;
|
|
|
|
public class BoatRow : MonoBehaviour
|
|
{
|
|
public enum RowSide
|
|
{
|
|
Left = 0,
|
|
Right = 1
|
|
}
|
|
|
|
public RowSide rowSide;
|
|
|
|
public Transform rowWaterPoint;
|
|
|
|
public Transform rowHandPoint;
|
|
|
|
public float rowForcePower = 10f;
|
|
|
|
public bool isUse;
|
|
|
|
public Boat currentBoat;
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
public void AddMove(Vector2 input)
|
|
{
|
|
if (input.y > 0f && input.x == 0f)
|
|
{
|
|
currentBoat.animator.SetBool("wioslowanie", value: true);
|
|
currentBoat.animator.SetBool("wioslowanie_left", value: false);
|
|
currentBoat.animator.SetBool("wioslowanie_right", value: false);
|
|
isUse = true;
|
|
}
|
|
else if ((input.y > 0f && input.x > 0f) || (input.y == 0f && input.x > 0f))
|
|
{
|
|
currentBoat.animator.SetBool("wioslowanie", value: false);
|
|
currentBoat.animator.SetBool("wioslowanie_left", value: false);
|
|
currentBoat.animator.SetBool("wioslowanie_right", value: true);
|
|
isUse = true;
|
|
}
|
|
else if ((input.y > 0f && input.x < 0f) || (input.y == 0f && input.x < 0f))
|
|
{
|
|
currentBoat.animator.SetBool("wioslowanie", value: false);
|
|
currentBoat.animator.SetBool("wioslowanie_left", value: true);
|
|
currentBoat.animator.SetBool("wioslowanie_right", value: false);
|
|
isUse = true;
|
|
}
|
|
else
|
|
{
|
|
currentBoat.animator.SetBool("wioslowanie", value: false);
|
|
currentBoat.animator.SetBool("wioslowanie_left", value: false);
|
|
currentBoat.animator.SetBool("wioslowanie_right", value: false);
|
|
isUse = false;
|
|
}
|
|
if (!(rowWaterPoint.position.y > 0f))
|
|
{
|
|
if (input.y > 0f && input.x == 0f)
|
|
{
|
|
currentBoat.rigidbody.AddForce(currentBoat.transform.forward * rowForcePower);
|
|
currentBoat.rigidbody.AddTorque(-currentBoat.transform.right * rowForcePower);
|
|
}
|
|
switch (rowSide)
|
|
{
|
|
case RowSide.Left:
|
|
currentBoat.rigidbody.AddTorque(currentBoat.transform.up * rowForcePower);
|
|
currentBoat.rigidbody.AddTorque(currentBoat.transform.forward * rowForcePower * 0.5f);
|
|
break;
|
|
case RowSide.Right:
|
|
currentBoat.rigidbody.AddTorque(-currentBoat.transform.up * rowForcePower);
|
|
currentBoat.rigidbody.AddTorque(-currentBoat.transform.forward * rowForcePower * 0.5f);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|