silverua / slay-the-spire-map-in-unity

Implementation of the Slay the Spire Map in Unity3d
MIT License
273 stars 65 forks source link

[Help] i want to do if i lose current node enemy and set current node to attainable state. what shoud i do #15

Open Zynchronous opened 2 years ago

Zynchronous commented 2 years ago

I'm learning c# coding and I'm not good at English. Thanks for reading.

silverua commented 2 years ago

Hi! I've looked at the code and I am not 100% sure if something like this is supported. When you travel along the map, the nodes that you can travel to next are defined by your previous path: mapManager.CurrentMap.path You can travel to "outgoing"nodes from the last point of the path. If you want to allow traveling to the node where you lost a battle with the enemy, I think, the easiest thing to do is - return the player to the previous node. You can do that by removing the last element from mapManager.CurrentMap.path. This way it will revert the player to where he was originally before he reached the node where he lost. Would this work?

Twenty94470 commented 11 months ago

Hello,

Generally if you loose it's a GameOver, but If the player quit and relaunch the game, he will pass the level without fighting. So It important to rollback if we detect this situation

I use this function to do that :

var currentPoint = mapManager.CurrentMap.path[mapManager.CurrentMap.path.Count - 1];
var currentNode = mapManager.CurrentMap.GetNode(currentPoint);
mapManager.CurrentMap.path.Remove(currentNode.point);

mapManager.SaveMap();
view.SetAttainableNodes();
view.SetLineColors();

Thanks for your great project !