Player Trap ID fix

This commit is contained in:
brausjonas
2023-04-07 00:09:36 +02:00
parent 93147cd67e
commit 248059113a
3 changed files with 18 additions and 9 deletions
@@ -174,12 +174,16 @@ public class NoPlayablePlayer : Player
if (currentField.placedItem != null) if (currentField.placedItem != null)
{ {
Trap t = currentField.placedItem.GetComponent<Trap>(); Trap t = currentField.placedItem.GetComponent<Trap>();
if(t.target.index != index)
{
AddCoins(-3); AddCoins(-3);
t.target.AddCoins(3); t.target.AddCoins(3);
currentField.placedItem = null; currentField.placedItem = null;
Destroy(t.gameObject); Destroy(t.gameObject);
} }
} }
}
Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation); Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation);
currentRotation.y = -34; currentRotation.y = -34;
@@ -177,6 +177,9 @@ public class PlayablePlayer : Player
if (currentField.placedItem != null) if (currentField.placedItem != null)
{ {
Trap t = currentField.placedItem.GetComponent<Trap>(); Trap t = currentField.placedItem.GetComponent<Trap>();
if(t.target.index != index)
{
AddCoins(-3); AddCoins(-3);
Debug.Log(t.name); Debug.Log(t.name);
t.target.AddCoins(3); t.target.AddCoins(3);
@@ -184,6 +187,7 @@ public class PlayablePlayer : Player
Destroy(t.gameObject); Destroy(t.gameObject);
} }
} }
}
Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation); Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation);
currentRotation.y = -34; currentRotation.y = -34;
transform.rotation = Quaternion.Euler(currentRotation); transform.rotation = Quaternion.Euler(currentRotation);
@@ -16,6 +16,7 @@ public abstract class Player : MonoBehaviour
protected Field currentField; protected Field currentField;
protected Vector3 cameraOffset = new Vector3(-2.81f, 8.13f, 5.6f); protected Vector3 cameraOffset = new Vector3(-2.81f, 8.13f, 5.6f);
//players ID
public int index; public int index;
public int coins = 0; public int coins = 0;
public int stars = 0; public int stars = 0;