animation is linked to speed slider
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public class CellMesh : MonoBehaviour
|
||||
{
|
||||
@@ -11,6 +12,8 @@ public class CellMesh : MonoBehaviour
|
||||
Vector2[] m_uv;
|
||||
int[] m_triangles;
|
||||
|
||||
Stack<Node> animateData;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mesh = new Mesh();
|
||||
@@ -78,24 +81,32 @@ public class CellMesh : MonoBehaviour
|
||||
mesh.triangles = triangles;
|
||||
}
|
||||
|
||||
|
||||
public void Animate(Stack<Node> result)
|
||||
{
|
||||
int count = result.Count;
|
||||
animateData = result;
|
||||
StartCoroutine("AnimateGrid");
|
||||
}
|
||||
|
||||
|
||||
IEnumerator AnimateGrid()
|
||||
{
|
||||
int count = animateData.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Node n = result.Pop();
|
||||
Node n = animateData.Pop();
|
||||
//Debug.Log("Agent at: " + n.agent.x + ", " + n.agent.y);
|
||||
Debug.Log(n.lastMove);
|
||||
|
||||
grid.SetValue(n.agent.x, n.agent.y, 3);
|
||||
//grid.SetValue(n.parent.agent.x, n.parent.agent.y, 0);
|
||||
grid.SetValue(n.parent.agent.x, n.parent.agent.y, 0);
|
||||
|
||||
yield return new WaitForSeconds(nMain.speed);
|
||||
|
||||
UpdateCellVisual();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user