Commit 3e099fa9 authored by Sebastian's avatar Sebastian

player scales correctly

parent 07b8f5b2
......@@ -74,6 +74,7 @@ public class PlayerAnimation : MonoBehaviour
switch (r_State.GetCurrentElement())
{
case InfusedElement.None:
print("RESET");
if(m_ScalingActive)ScaleReset();
if (m_RotationActive)
......@@ -84,8 +85,12 @@ public class PlayerAnimation : MonoBehaviour
break;
case InfusedElement.Air:
print("AIR");
m_CurrentAirCharges = r_State.GetCharges();
if (m_ScalingActive) ScalePlayer();
if (m_ScalingActive)
{
ScalePlayer();
}
/*if(m_isRotating) {
SetRotationOrbsActive(true, r_State.GetCharges());
......@@ -147,22 +152,28 @@ public class PlayerAnimation : MonoBehaviour
public void ScalePlayer()
{
m_CurrentAirCharges = r_State.GetCharges();
int diff = m_CurrentAirCharges - m_PreviousAirCharges;
//Debug.Log("current: " + currentCharges + " previous: " + m_PreviousCharges + " difference: " + diff);
if (!m_isAnimating || m_isAnimating)
{
if (diff > 0)
{
StartCoroutine(ScaleUp(m_PreviousAirCharges, m_CurrentAirCharges));
}
else
{
StartCoroutine(ScaleDown(m_PreviousAirCharges, m_CurrentAirCharges));
}
}
m_CurrentAirCharges = r_State.GetCharges();
var scaleFactor = 1.0f + m_CurrentAirCharges * 0.2f;
var direction = Mathf.Sign(this.gameObject.transform.localScale.x);
var newScale = new Vector3(direction * scaleFactor * m_OriginScale.x, scaleFactor * m_OriginScale.x, 0.0f);
this.gameObject.transform.localScale = newScale;
m_PreviousAirCharges = m_CurrentAirCharges;
// m_CurrentAirCharges = r_State.GetCharges();
// int diff = m_CurrentAirCharges - m_PreviousAirCharges;
// //Debug.Log("current: " + currentCharges + " previous: " + m_PreviousCharges + " difference: " + diff);
// if (!m_isAnimating || m_isAnimating)
// {
// if (diff > 0)
// {
// StartCoroutine(ScaleUp(m_PreviousAirCharges, m_CurrentAirCharges));
// }
// else
// {
// StartCoroutine(ScaleDown(m_PreviousAirCharges, m_CurrentAirCharges));
// }
// }
//
// m_PreviousAirCharges = m_CurrentAirCharges;
}
private void ScaleReset()
......@@ -172,23 +183,23 @@ public class PlayerAnimation : MonoBehaviour
transform.localScale = s;
}
private IEnumerator ScaleUp(float from, float to)
{
m_isAnimating = true;
float newSize = m_SizePerCharge * Mathf.Abs((to - from));
transform.localScale += new Vector3(newSize * Mathf.Sign(transform.localScale.x), newSize, newSize);
yield return null;
m_isAnimating = false;
}
private IEnumerator ScaleDown(float from, float to)
{
m_isAnimating = true;
float newSize = m_SizePerCharge * Mathf.Abs((to - from));
transform.localScale -= new Vector3(newSize * Mathf.Sign(transform.localScale.x), newSize, newSize);
yield return null;
m_isAnimating = false;
}
// private IEnumerator ScaleUp(float from, float to)
// {
// m_isAnimating = true;
// float newSize = m_SizePerCharge * Mathf.Abs((to - from));
// transform.localScale += new Vector3(newSize * Mathf.Sign(transform.localScale.x), newSize, newSize);
// yield return null;
// m_isAnimating = false;
// }
//
// private IEnumerator ScaleDown(float from, float to)
// {
// m_isAnimating = true;
// float newSize = m_SizePerCharge * Mathf.Abs((to - from));
// transform.localScale -= new Vector3(newSize * Mathf.Sign(transform.localScale.x), newSize, newSize);
// yield return null;
// m_isAnimating = false;
// }
/*private IEnumerator ScaleUp(float from, float to)
......
......@@ -45,6 +45,11 @@ namespace _Game.Scripts.Player
_waterAttack.enabled = false;
}
private void OnDisable()
{
state.UpdateElement(InfusedElement.None);
}
private void Update()
{
if (Input.GetButtonDown("Fire1"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment