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,10 +174,14 @@ public class NoPlayablePlayer : Player
if (currentField.placedItem != null)
{
Trap t = currentField.placedItem.GetComponent<Trap>();
AddCoins(-3);
t.target.AddCoins(3);
currentField.placedItem = null;
Destroy(t.gameObject);
if(t.target.index != index)
{
AddCoins(-3);
t.target.AddCoins(3);
currentField.placedItem = null;
Destroy(t.gameObject);
}
}
}
@@ -177,11 +177,15 @@ public class PlayablePlayer : Player
if (currentField.placedItem != null)
{
Trap t = currentField.placedItem.GetComponent<Trap>();
AddCoins(-3);
Debug.Log(t.name);
t.target.AddCoins(3);
currentField.placedItem = null;
Destroy(t.gameObject);
if(t.target.index != index)
{
AddCoins(-3);
Debug.Log(t.name);
t.target.AddCoins(3);
currentField.placedItem = null;
Destroy(t.gameObject);
}
}
}
Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation);
@@ -16,6 +16,7 @@ public abstract class Player : MonoBehaviour
protected Field currentField;
protected Vector3 cameraOffset = new Vector3(-2.81f, 8.13f, 5.6f);
//players ID
public int index;
public int coins = 0;
public int stars = 0;