Improved script allowing to move tombstones

This commit is contained in:
Alicja 2023-01-11 14:14:33 +01:00
parent 032689eeca
commit 6c380faeab

View File

@ -23,13 +23,45 @@ public class MoveTombstone : MonoBehaviour
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
speed = 100f;
x = transform.position.x; x = transform.position.x;
y = transform.position.y; y = transform.position.y;
position = PlayerPrefs.GetString(tombstone);
if(position == "top")
{
temp.x = x;
temp.y = y + 1;
goal = "set";
pos = "top";
}
else if (position == "bottom")
{
temp.x = x;
temp.y = y - 1;
goal = "set";
pos = "bottom";
}
else if (position == "right")
{
temp.x = x + 1;
temp.y = y;
goal = "set";
pos = "right";
}
else if (position == "left")
{
temp.y = y;
temp.x = x - 1;
goal = "set";
pos = "left";
}
if (x == transform.position.x && y == transform.position.y) if (x == transform.position.x && y == transform.position.y)
{ {
PlayerPrefs.SetString(tombstone, "start"); PlayerPrefs.SetString(tombstone, "start");
} }
player = GameObject.FindWithTag("Player"); player = GameObject.FindWithTag("Player");
speed = 3f;
} }