mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 00:50:59 +00:00
Fix the lava damage taken when jumping a lot in it
This commit is contained in:
parent
d439d7dce5
commit
d7092b4af6
@ -162,6 +162,25 @@ public class Child : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Debug.Log("Player " + _index + " entered lava. Lose one life.");
|
Debug.Log("Player " + _index + " entered lava. Lose one life.");
|
||||||
TakeLavaDamage();
|
TakeLavaDamage();
|
||||||
|
ActivateVibration(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Setup for the next time the player falls on the lava
|
||||||
|
_invulnerableTime = MaxInvulnerableTime;
|
||||||
|
|
||||||
|
if (collision.gameObject.tag == "Floor")
|
||||||
|
{
|
||||||
|
ActivateVibration(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnCollisionExit(Collision collision)
|
||||||
|
{
|
||||||
|
if (collision.gameObject.tag == "Lava" || collision.gameObject.tag == "Floor")
|
||||||
|
{
|
||||||
|
ActivateVibration(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,6 +195,12 @@ public class Child : MonoBehaviour
|
|||||||
Debug.Log("Player " + _index + " is still standing on lava. Lose one life.");
|
Debug.Log("Player " + _index + " is still standing on lava. Lose one life.");
|
||||||
TakeLavaDamage();
|
TakeLavaDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActivateVibration(true);
|
||||||
|
}
|
||||||
|
else if (collision.gameObject.tag == "Floor")
|
||||||
|
{
|
||||||
|
ActivateVibration(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,10 +210,21 @@ public class Child : MonoBehaviour
|
|||||||
_rb.AddForce(force);
|
_rb.AddForce(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ActivateVibration(bool activate)
|
||||||
|
{
|
||||||
|
float intensity = activate ? 0.3f : 0f;
|
||||||
|
|
||||||
|
XInputDotNetPure.GamePad.SetVibration((XInputDotNetPure.PlayerIndex)_index, intensity, intensity);
|
||||||
|
}
|
||||||
|
|
||||||
private void TakeLavaDamage()
|
private void TakeLavaDamage()
|
||||||
{
|
{
|
||||||
// TODO: Lose a life (probably) and become immune for ~ 2 or 3 seconds
|
// TODO: Lose a life (probably) and become immune for ~ 2 or 3 seconds
|
||||||
|
|
||||||
_invulnerableTime = 0f;
|
_invulnerableTime = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnDestroy()
|
||||||
|
{
|
||||||
|
XInputDotNetPure.GamePad.SetVibration((XInputDotNetPure.PlayerIndex)_index, 0f, 0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user