Post by MW on Jul 28, 2022 2:30:16 GMT
Hello,
I seem to be running into a coroutine issue when trying to play the viewer side of things.
I am migrating the tactics project into the CCG project in order to take advantage of the action system, when performing a 'moveAction', the action takes place but the coroutines do not play in succession one after the other. instead, they all seem to be called all at once. (one walk coroutine for each tile traversed)
I made a video to help better illustrate the issue.
I thought I could ask here and see if maybe anyone would have any leads.
Thank you and have a great day!
Videos help a lot in showing the problem
youtu.be/eMdBVowp3bM
private void OnPrepareMoveAction(object sender, object args)
{
//Debug.Log("On prepare move action - should be 1");
var action = args as MoveAction;
//action.point = new TheLiquidFire.DataTypes.Point(1, 1);
action.perform.viewer = Traverse;
}
public IEnumerator Traverse(IContainer game, GameAction action) //(TileView tile)
{
var moveAction = action as MoveAction;
List<TileView> tiles = moveAction.tiles;
TileView tile = tiles[0];
unitView.Place(tile); // takes him off and back on again? completely pointless?
// Build a list of way points from the unit's
// starting tile to the destination tile
List<TileView> targets = new List<TileView>();
while (tile != null)
{
targets.Insert(0, tile);
tile = tile.prev;
}
// Move to each way point in succession
for (int i = 1; i < targets.Count; ++i)
{
Debug.Log("Target.point : " + targets.point);
TileView from = targets;
TileView to = targets;
Directions dir = from.GetDirection(to);
//if (unitView.dir != dir)
//yield return StartCoroutine(Turn(dir));
if (from.height == to.height)
yield return StartCoroutine(Walk(to));
//else
//yield return StartCoroutine(Jump(to));
}
yield return null;
}
IEnumerator Walk(TileView target)
{
Debug.Log("Walk called");
Tweener tweener = transform.MoveTo(target.Center(), 5f, EasingEquations.Linear);
while (tweener != null)
yield return null;
}
I seem to be running into a coroutine issue when trying to play the viewer side of things.
I am migrating the tactics project into the CCG project in order to take advantage of the action system, when performing a 'moveAction', the action takes place but the coroutines do not play in succession one after the other. instead, they all seem to be called all at once. (one walk coroutine for each tile traversed)
I made a video to help better illustrate the issue.
I thought I could ask here and see if maybe anyone would have any leads.
Thank you and have a great day!
Videos help a lot in showing the problem
youtu.be/eMdBVowp3bM
private void OnPrepareMoveAction(object sender, object args)
{
//Debug.Log("On prepare move action - should be 1");
var action = args as MoveAction;
//action.point = new TheLiquidFire.DataTypes.Point(1, 1);
action.perform.viewer = Traverse;
}
public IEnumerator Traverse(IContainer game, GameAction action) //(TileView tile)
{
var moveAction = action as MoveAction;
List<TileView> tiles = moveAction.tiles;
TileView tile = tiles[0];
unitView.Place(tile); // takes him off and back on again? completely pointless?
// Build a list of way points from the unit's
// starting tile to the destination tile
List<TileView> targets = new List<TileView>();
while (tile != null)
{
targets.Insert(0, tile);
tile = tile.prev;
}
// Move to each way point in succession
for (int i = 1; i < targets.Count; ++i)
{
Debug.Log("Target.point : " + targets.point);
TileView from = targets;
TileView to = targets;
Directions dir = from.GetDirection(to);
//if (unitView.dir != dir)
//yield return StartCoroutine(Turn(dir));
if (from.height == to.height)
yield return StartCoroutine(Walk(to));
//else
//yield return StartCoroutine(Jump(to));
}
yield return null;
}
IEnumerator Walk(TileView target)
{
Debug.Log("Walk called");
Tweener tweener = transform.MoveTo(target.Center(), 5f, EasingEquations.Linear);
while (tweener != null)
yield return null;
}